summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.cirrus.yml7
-rw-r--r--.golangci.yml4
-rw-r--r--cmd/podman/common/completion_test.go2
-rw-r--r--cmd/podman/containers/cp.go2
-rw-r--r--cmd/podman/containers/stats.go4
-rw-r--r--cmd/podman/inspect/inspect.go4
-rw-r--r--cmd/podman/parse/net.go23
-rw-r--r--cmd/podman/parse/net_test.go2
-rw-r--r--cmd/podman/pods/ps.go4
-rw-r--r--cmd/podman/system/df.go2
-rw-r--r--cmd/podman/system/service_abi.go4
-rw-r--r--cmd/podman/validate/args.go2
-rw-r--r--cmd/rootlessport/main.go4
-rw-r--r--cmd/rootlessport/wsl_test.go2
-rwxr-xr-xhack/golangci-lint.sh5
-rw-r--r--libpod/container_exec.go4
-rw-r--r--libpod/container_internal_linux.go19
-rw-r--r--libpod/container_log_linux.go7
-rw-r--r--libpod/define/container_inspect.go4
-rw-r--r--libpod/events/journal_linux.go5
-rw-r--r--libpod/kube.go4
-rw-r--r--libpod/lock/file/file_lock.go2
-rw-r--r--libpod/lock/shm/shm_lock.go2
-rw-r--r--libpod/oci_conmon_linux.go4
-rw-r--r--libpod/plugin/volume_api.go2
-rw-r--r--pkg/api/handlers/compat/images.go6
-rw-r--r--pkg/api/handlers/compat/images_build.go18
-rw-r--r--pkg/api/handlers/compat/images_save.go2
-rw-r--r--pkg/api/handlers/libpod/images.go2
-rw-r--r--pkg/api/handlers/utils/images.go2
-rw-r--r--pkg/api/server/server.go2
-rw-r--r--pkg/bindings/connection.go5
-rw-r--r--pkg/bindings/containers/containers.go4
-rw-r--r--pkg/bindings/images/build.go2
-rw-r--r--pkg/bindings/images/build_unix.go2
-rw-r--r--pkg/ctime/ctime_linux.go2
-rw-r--r--pkg/domain/entities/containers.go32
-rw-r--r--pkg/domain/entities/images.go12
-rw-r--r--pkg/domain/entities/network.go2
-rw-r--r--pkg/domain/entities/pods.go24
-rw-r--r--pkg/domain/entities/reports/containers.go2
-rw-r--r--pkg/domain/entities/reports/prune.go2
-rw-r--r--pkg/domain/entities/types.go2
-rw-r--r--pkg/domain/entities/volumes.go6
-rw-r--r--pkg/domain/infra/abi/images.go2
-rw-r--r--pkg/domain/infra/abi/terminal/sigproxy_linux.go2
-rw-r--r--pkg/domain/infra/abi/volumes.go2
-rw-r--r--pkg/domain/infra/tunnel/containers.go4
-rw-r--r--pkg/errorhandling/errorhandling.go2
-rw-r--r--pkg/hooks/exec/runtimeconfigfilter_test.go2
-rw-r--r--pkg/k8s.io/apimachinery/pkg/api/resource/quantity.go9
-rw-r--r--pkg/machine/fcos.go2
-rw-r--r--pkg/machine/qemu/machine.go2
-rw-r--r--pkg/machine/qemu/options_darwin_arm64.go19
-rw-r--r--pkg/rootless/rootless.go2
-rw-r--r--pkg/specgen/generate/config_linux.go2
-rw-r--r--pkg/specgen/generate/container.go16
-rw-r--r--pkg/specgen/generate/oci.go2
-rw-r--r--pkg/util/utils_linux.go2
-rwxr-xr-xtest/apiv2/test-apiv221
-rwxr-xr-xtest/buildah-bud/apply-podman-deltas21
-rw-r--r--test/buildah-bud/buildah-tests.diff25
-rwxr-xr-xtest/buildah-bud/run-buildah-bud-tests6
-rw-r--r--test/e2e/common_test.go2
-rw-r--r--test/e2e/run_volume_test.go14
-rw-r--r--test/e2e/systemd_activate_test.go51
-rw-r--r--test/system/250-systemd.bats25
-rw-r--r--test/system/helpers.systemd.bash4
68 files changed, 309 insertions, 183 deletions
diff --git a/.cirrus.yml b/.cirrus.yml
index 460c5e049..d5298d62e 100644
--- a/.cirrus.yml
+++ b/.cirrus.yml
@@ -431,7 +431,7 @@ unit_test_task:
apiv2_test_task:
- name: "APIv2 test on $DISTRO_NV"
+ name: "APIv2 test on $DISTRO_NV ($PRIV_NAME)"
alias: apiv2_test
# Docs: ./contrib/cirrus/CIModes.md
only_if: *not_tag_branch_build_docs
@@ -445,6 +445,11 @@ apiv2_test_task:
env:
<<: *stdenvars
TEST_FLAVOR: apiv2
+ matrix:
+ - env:
+ PRIV_NAME: root
+ - env:
+ PRIV_NAME: rootless
clone_script: *get_gosrc
setup_script: *setup
main_script: *main
diff --git a/.golangci.yml b/.golangci.yml
index 15700cee7..31b0416fa 100644
--- a/.golangci.yml
+++ b/.golangci.yml
@@ -13,7 +13,6 @@ linters:
enable-all: true
disable:
# All these break for one reason or another
- - nolintlint # some linter must be disabled (see `nolint` in the code)
- tagliatelle # too many JSON keys cannot be changed due to compat
- gocognit
- testpackage
@@ -64,3 +63,6 @@ linters-settings:
errcheck:
check-blank: false
ignore: fmt:.*
+ nolintlint:
+ allow-leading-space: false
+ require-specific: true
diff --git a/cmd/podman/common/completion_test.go b/cmd/podman/common/completion_test.go
index ae23b02e2..d8be48ad7 100644
--- a/cmd/podman/common/completion_test.go
+++ b/cmd/podman/common/completion_test.go
@@ -50,7 +50,7 @@ func (c *Car) Color() string {
}
// This is for reflect testing required.
-// nolint:unused
+//nolint:unused
func (c Car) internal() int {
return 0
}
diff --git a/cmd/podman/containers/cp.go b/cmd/podman/containers/cp.go
index bf591cf65..a5842afc8 100644
--- a/cmd/podman/containers/cp.go
+++ b/cmd/podman/containers/cp.go
@@ -454,7 +454,7 @@ func resolvePathOnDestinationContainer(container string, containerPath string, i
containerInfo, err = registry.ContainerEngine().ContainerStat(registry.GetContext(), container, containerPath)
if err == nil {
baseName = filepath.Base(containerInfo.LinkTarget)
- return // nolint: nilerr
+ return //nolint: nilerr
}
if strings.HasSuffix(containerPath, "/") {
diff --git a/cmd/podman/containers/stats.go b/cmd/podman/containers/stats.go
index 02f8c6970..89c7f2b08 100644
--- a/cmd/podman/containers/stats.go
+++ b/cmd/podman/containers/stats.go
@@ -244,10 +244,10 @@ func combineBytesValues(a, b uint64) string {
func outputJSON(stats []containerStats) error {
type jstat struct {
- Id string `json:"id"` // nolint
+ Id string `json:"id"` //nolint:revive,stylecheck
Name string `json:"name"`
CPUTime string `json:"cpu_time"`
- CpuPercent string `json:"cpu_percent"` // nolint
+ CpuPercent string `json:"cpu_percent"` //nolint:revive,stylecheck
AverageCPU string `json:"avg_cpu"`
MemUsage string `json:"mem_usage"`
MemPerc string `json:"mem_percent"`
diff --git a/cmd/podman/inspect/inspect.go b/cmd/podman/inspect/inspect.go
index f6e3fca06..05a6de699 100644
--- a/cmd/podman/inspect/inspect.go
+++ b/cmd/podman/inspect/inspect.go
@@ -93,7 +93,7 @@ func newInspector(options entities.InspectOptions) (*inspector, error) {
// inspect inspects the specified container/image names or IDs.
func (i *inspector) inspect(namesOrIDs []string) error {
// data - dumping place for inspection results.
- var data []interface{} // nolint
+ var data []interface{}
var errs []error
ctx := context.Background()
@@ -249,7 +249,7 @@ func printTmpl(typ, row string, data []interface{}) error {
}
func (i *inspector) inspectAll(ctx context.Context, namesOrIDs []string) ([]interface{}, []error, error) {
- var data []interface{} // nolint
+ var data []interface{}
allErrs := []error{}
for _, name := range namesOrIDs {
ctrData, errs, err := i.containerEngine.ContainerInspect(ctx, []string{name}, i.options)
diff --git a/cmd/podman/parse/net.go b/cmd/podman/parse/net.go
index b616e1029..ba70c7ba5 100644
--- a/cmd/podman/parse/net.go
+++ b/cmd/podman/parse/net.go
@@ -1,4 +1,3 @@
-// nolint
// most of these validate and parse functions have been taken from projectatomic/docker
// and modified for cri-o
package parse
@@ -16,26 +15,10 @@ import (
)
const (
- Protocol_TCP Protocol = 0
- Protocol_UDP Protocol = 1
- LabelType string = "label"
- ENVType string = "env"
+ LabelType string = "label"
+ ENVType string = "env"
)
-type Protocol int32
-
-// PortMapping specifies the port mapping configurations of a sandbox.
-type PortMapping struct {
- // Protocol of the port mapping.
- Protocol Protocol `protobuf:"varint,1,opt,name=protocol,proto3,enum=runtime.Protocol" json:"protocol,omitempty"`
- // Port number within the container. Default: 0 (not specified).
- ContainerPort int32 `protobuf:"varint,2,opt,name=container_port,json=containerPort,proto3" json:"container_port,omitempty"`
- // Port number on the host. Default: 0 (not specified).
- HostPort int32 `protobuf:"varint,3,opt,name=host_port,json=hostPort,proto3" json:"host_port,omitempty"`
- // Host IP.
- HostIp string `protobuf:"bytes,4,opt,name=host_ip,json=hostIp,proto3" json:"host_ip,omitempty"`
-}
-
// Note: for flags that are in the form <number><unit>, use the RAMInBytes function
// from the units package in docker/go-units/size.go
@@ -48,7 +31,7 @@ var (
// validateExtraHost validates that the specified string is a valid extrahost and returns it.
// ExtraHost is in the form of name:ip where the ip has to be a valid ip (ipv4 or ipv6).
// for add-host flag
-func ValidateExtraHost(val string) (string, error) { // nolint
+func ValidateExtraHost(val string) (string, error) {
// allow for IPv6 addresses in extra hosts by only splitting on first ":"
arr := strings.SplitN(val, ":", 2)
if len(arr) != 2 || len(arr[0]) == 0 {
diff --git a/cmd/podman/parse/net_test.go b/cmd/podman/parse/net_test.go
index 51c8509df..a11edc2ca 100644
--- a/cmd/podman/parse/net_test.go
+++ b/cmd/podman/parse/net_test.go
@@ -1,4 +1,3 @@
-// nolint
// most of these validate and parse functions have been taken from projectatomic/docker
// and modified for cri-o
package parse
@@ -23,7 +22,6 @@ func createTmpFile(content []byte) (string, error) {
if _, err := tmpfile.Write(content); err != nil {
return "", err
-
}
if err := tmpfile.Close(); err != nil {
return "", err
diff --git a/cmd/podman/pods/ps.go b/cmd/podman/pods/ps.go
index aa42e1983..c98b4ef4e 100644
--- a/cmd/podman/pods/ps.go
+++ b/cmd/podman/pods/ps.go
@@ -211,7 +211,7 @@ func (l ListPodReporter) ID() string {
}
// Id returns the Pod id
-func (l ListPodReporter) Id() string { // nolint
+func (l ListPodReporter) Id() string { //nolint:revive,stylecheck
if noTrunc {
return l.ListPodsReport.Id
}
@@ -225,7 +225,7 @@ func (l ListPodReporter) InfraID() string {
// InfraId returns the infra container id for the pod
// depending on trunc
-func (l ListPodReporter) InfraId() string { // nolint
+func (l ListPodReporter) InfraId() string { //nolint:revive,stylecheck
if len(l.ListPodsReport.InfraId) == 0 {
return ""
}
diff --git a/cmd/podman/system/df.go b/cmd/podman/system/df.go
index dad14df6b..2fcc12feb 100644
--- a/cmd/podman/system/df.go
+++ b/cmd/podman/system/df.go
@@ -150,7 +150,7 @@ func printSummary(cmd *cobra.Command, reports *entities.SystemDfReport) error {
return writeTemplate(rpt, hdrs, dfSummaries)
}
-func printVerbose(cmd *cobra.Command, reports *entities.SystemDfReport) error { // nolint:interfacer
+func printVerbose(cmd *cobra.Command, reports *entities.SystemDfReport) error { //nolint:interfacer
rpt := report.New(os.Stdout, cmd.Name())
defer rpt.Flush()
diff --git a/cmd/podman/system/service_abi.go b/cmd/podman/system/service_abi.go
index 9dc9de1c8..7cb1b8084 100644
--- a/cmd/podman/system/service_abi.go
+++ b/cmd/podman/system/service_abi.go
@@ -46,6 +46,10 @@ func restService(flags *pflag.FlagSet, cfg *entities.PodmanConfig, opts entities
return fmt.Errorf("wrong number of file descriptors for socket activation protocol (%d != 1)", len(listeners))
}
listener = listeners[0]
+ // note that activation.Listeners() returns nil when it cannot listen on the fd (i.e. udp connection)
+ if listener == nil {
+ return fmt.Errorf("unexpected fd received from systemd: cannot listen on it")
+ }
libpodRuntime.SetRemoteURI(listeners[0].Addr().String())
} else {
uri, err := url.Parse(opts.URI)
diff --git a/cmd/podman/validate/args.go b/cmd/podman/validate/args.go
index b9b468d34..4c40581c6 100644
--- a/cmd/podman/validate/args.go
+++ b/cmd/podman/validate/args.go
@@ -27,7 +27,7 @@ func SubCommandExists(cmd *cobra.Command, args []string) error {
}
return errors.Errorf("unrecognized command `%[1]s %[2]s`\n\nDid you mean this?\n\t%[3]s\n\nTry '%[1]s --help' for more information", cmd.CommandPath(), args[0], strings.Join(suggestions, "\n\t"))
}
- cmd.Help() // nolint: errcheck
+ cmd.Help() //nolint: errcheck
return errors.Errorf("missing command '%[1]s COMMAND'", cmd.CommandPath())
}
diff --git a/cmd/rootlessport/main.go b/cmd/rootlessport/main.go
index 5bd35a985..f01b9e4a6 100644
--- a/cmd/rootlessport/main.go
+++ b/cmd/rootlessport/main.go
@@ -226,8 +226,8 @@ outer:
// https://github.com/containers/podman/issues/11248
// Copy /dev/null to stdout and stderr to prevent SIGPIPE errors
if f, err := os.OpenFile("/dev/null", os.O_WRONLY, 0755); err == nil {
- unix.Dup2(int(f.Fd()), 1) // nolint:errcheck
- unix.Dup2(int(f.Fd()), 2) // nolint:errcheck
+ unix.Dup2(int(f.Fd()), 1) //nolint:errcheck
+ unix.Dup2(int(f.Fd()), 2) //nolint:errcheck
f.Close()
}
// write and close ReadyFD (convention is same as slirp4netns --ready-fd)
diff --git a/cmd/rootlessport/wsl_test.go b/cmd/rootlessport/wsl_test.go
index 83d7e3717..2c95251cd 100644
--- a/cmd/rootlessport/wsl_test.go
+++ b/cmd/rootlessport/wsl_test.go
@@ -20,7 +20,7 @@ type SpecData struct {
}
func TestDualStackSplit(t *testing.T) {
- //nolint
+ //nolint:revive,stylecheck
const (
IP4_ALL = "0.0.0.0"
IP4__LO = "127.0.0.1"
diff --git a/hack/golangci-lint.sh b/hack/golangci-lint.sh
index 8b80bd9c9..2eaf206d7 100755
--- a/hack/golangci-lint.sh
+++ b/hack/golangci-lint.sh
@@ -4,10 +4,9 @@
set -e
declare -A BUILD_TAGS
-# TODO: add systemd tag
BUILD_TAGS[default]="apparmor,seccomp,selinux,linter"
-BUILD_TAGS[abi]="${BUILD_TAGS[default]},!remoteclient"
-BUILD_TAGS[tunnel]="${BUILD_TAGS[default]},remote,remoteclient"
+BUILD_TAGS[abi]="${BUILD_TAGS[default]},systemd"
+BUILD_TAGS[tunnel]="${BUILD_TAGS[default]},remote"
declare -A SKIP_DIRS
SKIP_DIRS[abi]="pkg/machine/e2e"
diff --git a/libpod/container_exec.go b/libpod/container_exec.go
index 1e8fce4da..be00c6fbe 100644
--- a/libpod/container_exec.go
+++ b/libpod/container_exec.go
@@ -79,11 +79,11 @@ type ExecConfig struct {
type ExecSession struct {
// Id is the ID of the exec session.
// Named somewhat strangely to not conflict with ID().
- // nolint:stylecheck,revive
+ //nolint:stylecheck,revive
Id string `json:"id"`
// ContainerId is the ID of the container this exec session belongs to.
// Named somewhat strangely to not conflict with ContainerID().
- // nolint:stylecheck,revive
+ //nolint:stylecheck,revive
ContainerId string `json:"containerId"`
// State is the state of the exec session.
diff --git a/libpod/container_internal_linux.go b/libpod/container_internal_linux.go
index 41c0ac595..2f36995b3 100644
--- a/libpod/container_internal_linux.go
+++ b/libpod/container_internal_linux.go
@@ -2249,8 +2249,19 @@ func (c *Container) makeBindMounts() error {
}
}
+ _, hasRunContainerenv := c.state.BindMounts["/run/.containerenv"]
+ if !hasRunContainerenv {
+ // check in the spec mounts
+ for _, m := range c.config.Spec.Mounts {
+ if m.Destination == "/run/.containerenv" || m.Destination == "/run" {
+ hasRunContainerenv = true
+ break
+ }
+ }
+ }
+
// Make .containerenv if it does not exist
- if _, ok := c.state.BindMounts["/run/.containerenv"]; !ok {
+ if !hasRunContainerenv {
containerenv := c.runtime.graphRootMountedFlag(c.config.Spec.Mounts)
isRootless := 0
if rootless.IsRootless() {
@@ -2632,7 +2643,7 @@ func (c *Container) generateUserGroupEntry(addedGID int) (string, error) {
gid, err := strconv.ParseUint(group, 10, 32)
if err != nil {
- return "", nil // nolint: nilerr
+ return "", nil //nolint: nilerr
}
if addedGID != 0 && addedGID == int(gid) {
@@ -2788,7 +2799,7 @@ func (c *Container) generateUserPasswdEntry(addedUID int) (string, error) {
// If a non numeric User, then don't generate passwd
uid, err := strconv.ParseUint(userspec, 10, 32)
if err != nil {
- return "", nil // nolint: nilerr
+ return "", nil //nolint: nilerr
}
if addedUID != 0 && int(uid) == addedUID {
@@ -3213,7 +3224,7 @@ func (c *Container) fixVolumePermissions(v *ContainerNamedVolume) error {
return err
}
stat := st.Sys().(*syscall.Stat_t)
- atime := time.Unix(int64(stat.Atim.Sec), int64(stat.Atim.Nsec)) // nolint: unconvert
+ atime := time.Unix(int64(stat.Atim.Sec), int64(stat.Atim.Nsec)) //nolint: unconvert
if err := os.Chtimes(mountPoint, atime, st.ModTime()); err != nil {
return err
}
diff --git a/libpod/container_log_linux.go b/libpod/container_log_linux.go
index deb726526..7f90332c7 100644
--- a/libpod/container_log_linux.go
+++ b/libpod/container_log_linux.go
@@ -292,11 +292,12 @@ func formatterPrefix(entry *sdjournal.JournalEntry) (string, error) {
if !ok {
return "", errors.Errorf("no PRIORITY field present in journal entry")
}
- if priority == journaldLogOut {
+ switch priority {
+ case journaldLogOut:
output += "stdout "
- } else if priority == journaldLogErr {
+ case journaldLogErr:
output += "stderr "
- } else {
+ default:
return "", errors.Errorf("unexpected PRIORITY field in journal entry")
}
diff --git a/libpod/define/container_inspect.go b/libpod/define/container_inspect.go
index e7b82d654..ccc4ae00f 100644
--- a/libpod/define/container_inspect.go
+++ b/libpod/define/container_inspect.go
@@ -259,9 +259,7 @@ type HealthCheckLog struct {
// as possible from the spec and container config.
// Some things cannot be inferred. These will be populated by spec annotations
// (if available).
-// Field names are fixed for compatibility and cannot be changed.
-// As such, silence lint warnings about them.
-//nolint
+//nolint:revive,stylecheck // Field names are fixed for compatibility and cannot be changed.
type InspectContainerHostConfig struct {
// Binds contains an array of user-added mounts.
// Both volume mounts and named volumes are included.
diff --git a/libpod/events/journal_linux.go b/libpod/events/journal_linux.go
index 866042a4c..d21b60c68 100644
--- a/libpod/events/journal_linux.go
+++ b/libpod/events/journal_linux.go
@@ -64,7 +64,7 @@ func (e EventJournalD) Write(ee Event) error {
case Volume:
m["PODMAN_NAME"] = ee.Name
}
- return journal.Send(string(ee.ToHumanReadable(false)), journal.PriInfo, m)
+ return journal.Send(ee.ToHumanReadable(false), journal.PriInfo, m)
}
// Read reads events from the journal and sends qualified events to the event channel
@@ -167,10 +167,9 @@ func (e EventJournalD) Read(ctx context.Context, options ReadOptions) error {
}
}
return nil
-
}
-func newEventFromJournalEntry(entry *sdjournal.JournalEntry) (*Event, error) { //nolint
+func newEventFromJournalEntry(entry *sdjournal.JournalEntry) (*Event, error) {
newEvent := Event{}
eventType, err := StringToType(entry.Fields["PODMAN_TYPE"])
if err != nil {
diff --git a/libpod/kube.go b/libpod/kube.go
index 20c4612d1..bd4230d66 100644
--- a/libpod/kube.go
+++ b/libpod/kube.go
@@ -43,8 +43,8 @@ func GenerateForKube(ctx context.Context, ctrs []*Container) (*v1.Pod, error) {
func (p *Pod) GenerateForKube(ctx context.Context) (*v1.Pod, []v1.ServicePort, error) {
// Generate the v1.Pod yaml description
var (
- ports []v1.ContainerPort //nolint
- servicePorts []v1.ServicePort //nolint
+ ports []v1.ContainerPort
+ servicePorts []v1.ServicePort
)
allContainers, err := p.allContainers()
diff --git a/libpod/lock/file/file_lock.go b/libpod/lock/file/file_lock.go
index 4685872b6..145aa6e26 100644
--- a/libpod/lock/file/file_lock.go
+++ b/libpod/lock/file/file_lock.go
@@ -14,7 +14,7 @@ import (
// FileLocks is a struct enabling POSIX lock locking in a shared memory
// segment.
-type FileLocks struct { // nolint
+type FileLocks struct { //nolint:revive // struct name stutters
lockPath string
valid bool
}
diff --git a/libpod/lock/shm/shm_lock.go b/libpod/lock/shm/shm_lock.go
index c7f4d1bc5..6eaf37e48 100644
--- a/libpod/lock/shm/shm_lock.go
+++ b/libpod/lock/shm/shm_lock.go
@@ -28,7 +28,7 @@ var (
// SHMLocks is a struct enabling POSIX semaphore locking in a shared memory
// segment.
-type SHMLocks struct { // nolint
+type SHMLocks struct {
lockStruct *C.shm_struct_t
maxLocks uint32
valid bool
diff --git a/libpod/oci_conmon_linux.go b/libpod/oci_conmon_linux.go
index 0c1ee61d3..fde8624b0 100644
--- a/libpod/oci_conmon_linux.go
+++ b/libpod/oci_conmon_linux.go
@@ -1014,7 +1014,7 @@ func (r *ConmonOCIRuntime) getLogTag(ctr *Container) (string, error) {
data, err := ctr.inspectLocked(false)
if err != nil {
// FIXME: this error should probably be returned
- return "", nil // nolint: nilerr
+ return "", nil //nolint: nilerr
}
tmpl, err := template.New("container").Parse(logTag)
if err != nil {
@@ -1435,7 +1435,7 @@ func (r *ConmonOCIRuntime) moveConmonToCgroupAndSignal(ctr *Container, cmd *exec
}
// $INVOCATION_ID is set by systemd when running as a service.
- if os.Getenv("INVOCATION_ID") != "" {
+ if ctr.runtime.RemoteURI() == "" && os.Getenv("INVOCATION_ID") != "" {
mustCreateCgroup = false
}
diff --git a/libpod/plugin/volume_api.go b/libpod/plugin/volume_api.go
index 2818e70c1..f997ccf22 100644
--- a/libpod/plugin/volume_api.go
+++ b/libpod/plugin/volume_api.go
@@ -35,8 +35,6 @@ var (
hostVirtualPath = "/VolumeDriver.Path"
mountPath = "/VolumeDriver.Mount"
unmountPath = "/VolumeDriver.Unmount"
- // nolint
- capabilitiesPath = "/VolumeDriver.Capabilities"
)
const (
diff --git a/pkg/api/handlers/compat/images.go b/pkg/api/handlers/compat/images.go
index 76a28fadf..981a38c35 100644
--- a/pkg/api/handlers/compat/images.go
+++ b/pkg/api/handlers/compat/images.go
@@ -165,7 +165,7 @@ func CommitContainer(w http.ResponseWriter, r *http.Request) {
utils.Error(w, http.StatusInternalServerError, errors.Wrapf(err, "CommitFailure"))
return
}
- utils.WriteResponse(w, http.StatusCreated, entities.IDResponse{ID: commitImage.ID()}) // nolint
+ utils.WriteResponse(w, http.StatusCreated, entities.IDResponse{ID: commitImage.ID()})
}
func CreateImageFromSrc(w http.ResponseWriter, r *http.Request) {
@@ -237,7 +237,7 @@ func CreateImageFromSrc(w http.ResponseWriter, r *http.Request) {
Status string `json:"status"`
Progress string `json:"progress"`
ProgressDetail map[string]string `json:"progressDetail"`
- Id string `json:"id"` // nolint
+ Id string `json:"id"` //nolint:revive,stylecheck
}{
Status: report.Id,
ProgressDetail: map[string]string{},
@@ -333,7 +333,7 @@ loop: // break out of for/select infinite loop
Total int64 `json:"total,omitempty"`
} `json:"progressDetail,omitempty"`
Error string `json:"error,omitempty"`
- Id string `json:"id,omitempty"` // nolint
+ Id string `json:"id,omitempty"` //nolint:revive,stylecheck
}
select {
case e := <-progress:
diff --git a/pkg/api/handlers/compat/images_build.go b/pkg/api/handlers/compat/images_build.go
index 7e599f4d3..80fc17f56 100644
--- a/pkg/api/handlers/compat/images_build.go
+++ b/pkg/api/handlers/compat/images_build.go
@@ -78,15 +78,15 @@ func BuildImage(w http.ResponseWriter, r *http.Request) {
AppArmor string `schema:"apparmor"`
BuildArgs string `schema:"buildargs"`
CacheFrom string `schema:"cachefrom"`
- CgroupParent string `schema:"cgroupparent"` // nolint
+ CgroupParent string `schema:"cgroupparent"`
Compression uint64 `schema:"compression"`
ConfigureNetwork string `schema:"networkmode"`
CPPFlags string `schema:"cppflags"`
- CpuPeriod uint64 `schema:"cpuperiod"` // nolint
- CpuQuota int64 `schema:"cpuquota"` // nolint
- CpuSetCpus string `schema:"cpusetcpus"` // nolint
- CpuSetMems string `schema:"cpusetmems"` // nolint
- CpuShares uint64 `schema:"cpushares"` // nolint
+ CpuPeriod uint64 `schema:"cpuperiod"` //nolint:revive,stylecheck
+ CpuQuota int64 `schema:"cpuquota"` //nolint:revive,stylecheck
+ CpuSetCpus string `schema:"cpusetcpus"` //nolint:revive,stylecheck
+ CpuSetMems string `schema:"cpusetmems"` //nolint:revive,stylecheck
+ CpuShares uint64 `schema:"cpushares"` //nolint:revive,stylecheck
DNSOptions string `schema:"dnsoptions"`
DNSSearch string `schema:"dnssearch"`
DNSServers string `schema:"dnsservers"`
@@ -101,7 +101,7 @@ func BuildImage(w http.ResponseWriter, r *http.Request) {
IdentityLabel bool `schema:"identitylabel"`
Ignore bool `schema:"ignore"`
Isolation string `schema:"isolation"`
- Jobs int `schema:"jobs"` // nolint
+ Jobs int `schema:"jobs"`
LabelOpts string `schema:"labelopts"`
Labels string `schema:"labels"`
Layers bool `schema:"layers"`
@@ -367,7 +367,7 @@ func BuildImage(w http.ResponseWriter, r *http.Request) {
}
}
}
- var additionalTags []string // nolint
+ var additionalTags []string
for i := 1; i < len(tags); i++ {
possiblyNormalizedTag, err := utils.NormalizeToDockerHub(r, tags[i])
if err != nil {
@@ -801,7 +801,7 @@ func parseNetworkConfigurationPolicy(network string) buildah.NetworkConfiguratio
}
}
-func parseLibPodIsolation(isolation string) (buildah.Isolation, error) { // nolint
+func parseLibPodIsolation(isolation string) (buildah.Isolation, error) {
if val, err := strconv.Atoi(isolation); err == nil {
return buildah.Isolation(val), nil
}
diff --git a/pkg/api/handlers/compat/images_save.go b/pkg/api/handlers/compat/images_save.go
index b39c719a0..6314756f6 100644
--- a/pkg/api/handlers/compat/images_save.go
+++ b/pkg/api/handlers/compat/images_save.go
@@ -6,7 +6,7 @@ import (
"os"
)
-func SaveFromBody(f *os.File, r *http.Request) error { // nolint
+func SaveFromBody(f *os.File, r *http.Request) error {
if _, err := io.Copy(f, r.Body); err != nil {
return err
}
diff --git a/pkg/api/handlers/libpod/images.go b/pkg/api/handlers/libpod/images.go
index 60ed5feb3..a8a50ae58 100644
--- a/pkg/api/handlers/libpod/images.go
+++ b/pkg/api/handlers/libpod/images.go
@@ -562,7 +562,7 @@ func CommitContainer(w http.ResponseWriter, r *http.Request) {
utils.Error(w, http.StatusInternalServerError, errors.Wrapf(err, "CommitFailure"))
return
}
- utils.WriteResponse(w, http.StatusOK, entities.IDResponse{ID: commitImage.ID()}) // nolint
+ utils.WriteResponse(w, http.StatusOK, entities.IDResponse{ID: commitImage.ID()})
}
func UntagImage(w http.ResponseWriter, r *http.Request) {
diff --git a/pkg/api/handlers/utils/images.go b/pkg/api/handlers/utils/images.go
index 433231f59..77f6dcf1d 100644
--- a/pkg/api/handlers/utils/images.go
+++ b/pkg/api/handlers/utils/images.go
@@ -68,7 +68,7 @@ func IsRegistryReference(name string) error {
imageRef, err := alltransports.ParseImageName(name)
if err != nil {
// No supported transport -> assume a docker-stype reference.
- return nil // nolint: nilerr
+ return nil //nolint: nilerr
}
if imageRef.Transport().Name() == docker.Transport.Name() {
return nil
diff --git a/pkg/api/server/server.go b/pkg/api/server/server.go
index 7a7e35e8e..5482a8ec2 100644
--- a/pkg/api/server/server.go
+++ b/pkg/api/server/server.go
@@ -148,7 +148,7 @@ func newServer(runtime *libpod.Runtime, listener net.Listener, opts entities.Ser
if logrus.IsLevelEnabled(logrus.TraceLevel) {
// If in trace mode log request and response bodies
router.Use(loggingHandler())
- router.Walk(func(route *mux.Route, r *mux.Router, ancestors []*mux.Route) error { // nolint
+ _ = router.Walk(func(route *mux.Route, r *mux.Router, ancestors []*mux.Route) error {
path, err := route.GetPathTemplate()
if err != nil {
path = "<N/A>"
diff --git a/pkg/bindings/connection.go b/pkg/bindings/connection.go
index 3739ec404..c21834e35 100644
--- a/pkg/bindings/connection.go
+++ b/pkg/bindings/connection.go
@@ -315,7 +315,8 @@ func unixClient(_url *url.URL) Connection {
return connection
}
-// DoRequest assembles the http request and returns the response
+// DoRequest assembles the http request and returns the response.
+// The caller must close the response body.
func (c *Connection) DoRequest(ctx context.Context, httpBody io.Reader, httpMethod, endpoint string, queryParams url.Values, headers http.Header, pathValues ...string) (*APIResponse, error) {
var (
err error
@@ -361,7 +362,7 @@ func (c *Connection) DoRequest(ctx context.Context, httpBody io.Reader, httpMeth
// Give the Do three chances in the case of a comm/service hiccup
for i := 1; i <= 3; i++ {
- response, err = c.Client.Do(req) // nolint
+ response, err = c.Client.Do(req) //nolint:bodyclose // The caller has to close the body.
if err == nil {
break
}
diff --git a/pkg/bindings/containers/containers.go b/pkg/bindings/containers/containers.go
index be421cc8b..2d3422411 100644
--- a/pkg/bindings/containers/containers.go
+++ b/pkg/bindings/containers/containers.go
@@ -25,7 +25,7 @@ var (
// the most recent number of containers. The pod and size booleans indicate that pod information and rootfs
// size information should also be included. Finally, the sync bool synchronizes the OCI runtime and
// container state.
-func List(ctx context.Context, options *ListOptions) ([]entities.ListContainer, error) { // nolint:typecheck
+func List(ctx context.Context, options *ListOptions) ([]entities.ListContainer, error) {
if options == nil {
options = new(ListOptions)
}
@@ -339,7 +339,7 @@ func Unpause(ctx context.Context, nameOrID string, options *UnpauseOptions) erro
// Wait blocks until the given container reaches a condition. If not provided, the condition will
// default to stopped. If the condition is stopped, an exit code for the container will be provided. The
// nameOrID can be a container name or a partial/full ID.
-func Wait(ctx context.Context, nameOrID string, options *WaitOptions) (int32, error) { // nolint
+func Wait(ctx context.Context, nameOrID string, options *WaitOptions) (int32, error) {
if options == nil {
options = new(WaitOptions)
}
diff --git a/pkg/bindings/images/build.go b/pkg/bindings/images/build.go
index 72fed6bd5..f14f866dd 100644
--- a/pkg/bindings/images/build.go
+++ b/pkg/bindings/images/build.go
@@ -621,7 +621,7 @@ func nTar(excludes []string, sources ...string) (io.ReadCloser, error) {
}
name := filepath.ToSlash(strings.TrimPrefix(path, s+string(filepath.Separator)))
- excluded, err := pm.Matches(name) // nolint:staticcheck
+ excluded, err := pm.Matches(name) //nolint:staticcheck
if err != nil {
return errors.Wrapf(err, "error checking if %q is excluded", name)
}
diff --git a/pkg/bindings/images/build_unix.go b/pkg/bindings/images/build_unix.go
index 32e2ba9af..07bb8cbcd 100644
--- a/pkg/bindings/images/build_unix.go
+++ b/pkg/bindings/images/build_unix.go
@@ -11,7 +11,7 @@ import (
func checkHardLink(fi os.FileInfo) (devino, bool) {
st := fi.Sys().(*syscall.Stat_t)
return devino{
- Dev: uint64(st.Dev), // nolint: unconvert
+ Dev: uint64(st.Dev), //nolint: unconvert
Ino: st.Ino,
}, st.Nlink > 1
}
diff --git a/pkg/ctime/ctime_linux.go b/pkg/ctime/ctime_linux.go
index 7eb3caa6d..bf3cd5752 100644
--- a/pkg/ctime/ctime_linux.go
+++ b/pkg/ctime/ctime_linux.go
@@ -11,6 +11,6 @@ import (
func created(fi os.FileInfo) time.Time {
st := fi.Sys().(*syscall.Stat_t)
- //nolint
+ //nolint:unconvert // need to type cast on some cpu architectures
return time.Unix(int64(st.Ctim.Sec), int64(st.Ctim.Nsec))
}
diff --git a/pkg/domain/entities/containers.go b/pkg/domain/entities/containers.go
index 750f49590..17408f12f 100644
--- a/pkg/domain/entities/containers.go
+++ b/pkg/domain/entities/containers.go
@@ -56,7 +56,7 @@ type WaitOptions struct {
}
type WaitReport struct {
- Id string //nolint
+ Id string //nolint:revive,stylecheck
Error error
ExitCode int32
}
@@ -76,7 +76,7 @@ type PauseUnPauseOptions struct {
type PauseUnpauseReport struct {
Err error
- Id string //nolint
+ Id string //nolint:revive,stylecheck
}
type StopOptions struct {
@@ -88,7 +88,7 @@ type StopOptions struct {
type StopReport struct {
Err error
- Id string //nolint
+ Id string //nolint:revive,stylecheck
RawInput string
}
@@ -110,7 +110,7 @@ type KillOptions struct {
type KillReport struct {
Err error
- Id string //nolint
+ Id string //nolint:revive,stylecheck
RawInput string
}
@@ -123,7 +123,7 @@ type RestartOptions struct {
type RestartReport struct {
Err error
- Id string //nolint
+ Id string //nolint:revive,stylecheck
}
type RmOptions struct {
@@ -170,7 +170,7 @@ type CopyOptions struct {
}
type CommitReport struct {
- Id string //nolint
+ Id string //nolint:revive,stylecheck
}
type ContainerExportOptions struct {
@@ -196,7 +196,7 @@ type CheckpointOptions struct {
type CheckpointReport struct {
Err error `json:"-"`
- Id string `json:"Id` //nolint
+ Id string `json:"Id"` //nolint:revive,stylecheck
RuntimeDuration int64 `json:"runtime_checkpoint_duration"`
CRIUStatistics *define.CRIUCheckpointRestoreStatistics `json:"criu_statistics"`
}
@@ -222,13 +222,13 @@ type RestoreOptions struct {
type RestoreReport struct {
Err error `json:"-"`
- Id string `json:"Id` //nolint
+ Id string `json:"Id"` //nolint:revive,stylecheck
RuntimeDuration int64 `json:"runtime_restore_duration"`
CRIUStatistics *define.CRIUCheckpointRestoreStatistics `json:"criu_statistics"`
}
type ContainerCreateReport struct {
- Id string //nolint
+ Id string //nolint:revive,stylecheck
}
// AttachOptions describes the cli and other values
@@ -307,7 +307,7 @@ type ContainerStartOptions struct {
// ContainerStartReport describes the response from starting
// containers from the cli
type ContainerStartReport struct {
- Id string //nolint
+ Id string //nolint:revive,stylecheck
RawInput string
Err error
ExitCode int
@@ -351,7 +351,7 @@ type ContainerRunOptions struct {
// a container
type ContainerRunReport struct {
ExitCode int
- Id string //nolint
+ Id string //nolint:revive,stylecheck
}
// ContainerCleanupOptions are the CLI values for the
@@ -368,7 +368,7 @@ type ContainerCleanupOptions struct {
// container cleanup
type ContainerCleanupReport struct {
CleanErr error
- Id string //nolint
+ Id string //nolint:revive,stylecheck
RmErr error
RmiErr error
}
@@ -384,7 +384,7 @@ type ContainerInitOptions struct {
// container init
type ContainerInitReport struct {
Err error
- Id string //nolint
+ Id string //nolint:revive,stylecheck
}
// ContainerMountOptions describes the input values for mounting containers
@@ -406,7 +406,7 @@ type ContainerUnmountOptions struct {
// ContainerMountReport describes the response from container mount
type ContainerMountReport struct {
Err error
- Id string //nolint
+ Id string //nolint:revive,stylecheck
Name string
Path string
}
@@ -414,7 +414,7 @@ type ContainerMountReport struct {
// ContainerUnmountReport describes the response from umounting a container
type ContainerUnmountReport struct {
Err error
- Id string //nolint
+ Id string //nolint:revive,stylecheck
}
// ContainerPruneOptions describes the options needed
@@ -433,7 +433,7 @@ type ContainerPortOptions struct {
// ContainerPortReport describes the output needed for
// the CLI to output ports
type ContainerPortReport struct {
- Id string //nolint
+ Id string //nolint:revive,stylecheck
Ports []nettypes.PortMapping
}
diff --git a/pkg/domain/entities/images.go b/pkg/domain/entities/images.go
index 2bb4ceb5b..11f6e8687 100644
--- a/pkg/domain/entities/images.go
+++ b/pkg/domain/entities/images.go
@@ -46,14 +46,14 @@ type Image struct {
HealthCheck *manifest.Schema2HealthConfig `json:",omitempty"`
}
-func (i *Image) Id() string { // nolint
+func (i *Image) Id() string { //nolint:revive,stylecheck
return i.ID
}
// swagger:model LibpodImageSummary
type ImageSummary struct {
ID string `json:"Id"`
- ParentId string // nolint
+ ParentId string //nolint:revive,stylecheck
RepoTags []string
RepoDigests []string
Created int64
@@ -71,7 +71,7 @@ type ImageSummary struct {
History []string `json:",omitempty"`
}
-func (i *ImageSummary) Id() string { // nolint
+func (i *ImageSummary) Id() string { //nolint:revive,stylecheck
return i.ID
}
@@ -290,7 +290,7 @@ type ImageImportOptions struct {
}
type ImageImportReport struct {
- Id string // nolint
+ Id string //nolint:revive,stylecheck
}
// ImageSaveOptions provide options for saving images.
@@ -397,7 +397,7 @@ type ImageUnmountOptions struct {
// ImageMountReport describes the response from image mount
type ImageMountReport struct {
- Id string // nolint
+ Id string //nolint:revive,stylecheck
Name string
Repositories []string
Path string
@@ -406,5 +406,5 @@ type ImageMountReport struct {
// ImageUnmountReport describes the response from umounting an image
type ImageUnmountReport struct {
Err error
- Id string // nolint
+ Id string //nolint:revive,stylecheck
}
diff --git a/pkg/domain/entities/network.go b/pkg/domain/entities/network.go
index 0f901c7f1..d375c2e20 100644
--- a/pkg/domain/entities/network.go
+++ b/pkg/domain/entities/network.go
@@ -22,7 +22,7 @@ type NetworkReloadOptions struct {
// NetworkReloadReport describes the results of reloading a container network.
type NetworkReloadReport struct {
- // nolint:stylecheck,revive
+ //nolint:stylecheck,revive
Id string
Err error
}
diff --git a/pkg/domain/entities/pods.go b/pkg/domain/entities/pods.go
index 9cbbe2bf1..3318fe7e1 100644
--- a/pkg/domain/entities/pods.go
+++ b/pkg/domain/entities/pods.go
@@ -20,15 +20,15 @@ type PodKillOptions struct {
type PodKillReport struct {
Errs []error
- Id string // nolint
+ Id string //nolint:revive,stylecheck
}
type ListPodsReport struct {
Cgroup string
Containers []*ListPodContainer
Created time.Time
- Id string // nolint
- InfraId string // nolint
+ Id string //nolint:revive,stylecheck
+ InfraId string //nolint:revive,stylecheck
Name string
Namespace string
// Network names connected to infra container
@@ -38,7 +38,7 @@ type ListPodsReport struct {
}
type ListPodContainer struct {
- Id string // nolint
+ Id string //nolint:revive,stylecheck
Names string
Status string
}
@@ -50,7 +50,7 @@ type PodPauseOptions struct {
type PodPauseReport struct {
Errs []error
- Id string // nolint
+ Id string //nolint:revive,stylecheck
}
type PodunpauseOptions struct {
@@ -60,7 +60,7 @@ type PodunpauseOptions struct {
type PodUnpauseReport struct {
Errs []error
- Id string // nolint
+ Id string //nolint:revive,stylecheck
}
type PodStopOptions struct {
@@ -72,7 +72,7 @@ type PodStopOptions struct {
type PodStopReport struct {
Errs []error
- Id string // nolint
+ Id string //nolint:revive,stylecheck
}
type PodRestartOptions struct {
@@ -82,7 +82,7 @@ type PodRestartOptions struct {
type PodRestartReport struct {
Errs []error
- Id string // nolint
+ Id string //nolint:revive,stylecheck
}
type PodStartOptions struct {
@@ -92,7 +92,7 @@ type PodStartOptions struct {
type PodStartReport struct {
Errs []error
- Id string // nolint
+ Id string //nolint:revive,stylecheck
}
type PodRmOptions struct {
@@ -105,7 +105,7 @@ type PodRmOptions struct {
type PodRmReport struct {
Err error
- Id string // nolint
+ Id string //nolint:revive,stylecheck
}
// PddSpec is an abstracted version of PodSpecGen designed to eventually accept options
@@ -287,7 +287,7 @@ func NewInfraContainerCreateOptions() ContainerCreateOptions {
}
type PodCreateReport struct {
- Id string // nolint
+ Id string //nolint:revive,stylecheck
}
func (p *PodCreateOptions) CPULimits() *specs.LinuxCPU {
@@ -389,7 +389,7 @@ type PodPruneOptions struct {
type PodPruneReport struct {
Err error
- Id string // nolint
+ Id string //nolint:revive,stylecheck
}
type PodTopOptions struct {
diff --git a/pkg/domain/entities/reports/containers.go b/pkg/domain/entities/reports/containers.go
index 54bcd092b..db9a66012 100644
--- a/pkg/domain/entities/reports/containers.go
+++ b/pkg/domain/entities/reports/containers.go
@@ -1,7 +1,7 @@
package reports
type RmReport struct {
- Id string `json:"Id"` //nolint
+ Id string `json:"Id"` //nolint:revive,stylecheck
Err error `json:"Err,omitempty"`
}
diff --git a/pkg/domain/entities/reports/prune.go b/pkg/domain/entities/reports/prune.go
index 497e5d606..ac3d8e7ce 100644
--- a/pkg/domain/entities/reports/prune.go
+++ b/pkg/domain/entities/reports/prune.go
@@ -1,7 +1,7 @@
package reports
type PruneReport struct {
- Id string `json:"Id"` //nolint
+ Id string `json:"Id"` //nolint:revive,stylecheck
Err error `json:"Err,omitempty"`
Size uint64 `json:"Size"`
}
diff --git a/pkg/domain/entities/types.go b/pkg/domain/entities/types.go
index 3e6e54e7d..44df66498 100644
--- a/pkg/domain/entities/types.go
+++ b/pkg/domain/entities/types.go
@@ -21,7 +21,7 @@ type Volume struct {
}
type Report struct {
- Id []string // nolint
+ Id []string //nolint:revive,stylecheck
Err map[string]error
}
diff --git a/pkg/domain/entities/volumes.go b/pkg/domain/entities/volumes.go
index 84f85b83f..556df16c1 100644
--- a/pkg/domain/entities/volumes.go
+++ b/pkg/domain/entities/volumes.go
@@ -33,7 +33,7 @@ type VolumeRmOptions struct {
type VolumeRmReport struct {
Err error
- Id string // nolint
+ Id string //nolint:revive,stylecheck
}
type VolumeInspectReport struct {
@@ -61,7 +61,7 @@ type VolumeListReport struct {
// VolumeMountReport describes the response from volume mount
type VolumeMountReport struct {
Err error
- Id string // nolint
+ Id string //nolint:revive,stylecheck
Name string
Path string
}
@@ -69,5 +69,5 @@ type VolumeMountReport struct {
// VolumeUnmountReport describes the response from umounting a volume
type VolumeUnmountReport struct {
Err error
- Id string // nolint
+ Id string //nolint:revive,stylecheck
}
diff --git a/pkg/domain/infra/abi/images.go b/pkg/domain/infra/abi/images.go
index d469fa0ca..d63de2424 100644
--- a/pkg/domain/infra/abi/images.go
+++ b/pkg/domain/infra/abi/images.go
@@ -593,7 +593,7 @@ func (ir *ImageEngine) Remove(ctx context.Context, images []string, opts entitie
rmErrors = libimageErrors
- return //nolint
+ return
}
// Shutdown Libpod engine
diff --git a/pkg/domain/infra/abi/terminal/sigproxy_linux.go b/pkg/domain/infra/abi/terminal/sigproxy_linux.go
index fe2c268c0..e02c0532c 100644
--- a/pkg/domain/infra/abi/terminal/sigproxy_linux.go
+++ b/pkg/domain/infra/abi/terminal/sigproxy_linux.go
@@ -20,7 +20,7 @@ const signalBufferSize = 2048
func ProxySignals(ctr *libpod.Container) {
// Stop catching the shutdown signals (SIGINT, SIGTERM) - they're going
// to the container now.
- shutdown.Stop() // nolint: errcheck
+ shutdown.Stop() //nolint: errcheck
sigBuffer := make(chan os.Signal, signalBufferSize)
signal.CatchAll(sigBuffer)
diff --git a/pkg/domain/infra/abi/volumes.go b/pkg/domain/infra/abi/volumes.go
index f59f11e20..a9c53c140 100644
--- a/pkg/domain/infra/abi/volumes.go
+++ b/pkg/domain/infra/abi/volumes.go
@@ -172,7 +172,7 @@ func (ic *ContainerEngine) VolumeMounted(ctx context.Context, nameOrID string) (
mountCount, err := vol.MountCount()
if err != nil {
// FIXME: this error should probably be returned
- return &entities.BoolReport{Value: false}, nil // nolint: nilerr
+ return &entities.BoolReport{Value: false}, nil //nolint: nilerr
}
if mountCount > 0 {
return &entities.BoolReport{Value: true}, nil
diff --git a/pkg/domain/infra/tunnel/containers.go b/pkg/domain/infra/tunnel/containers.go
index b68bc46d4..fb0be629c 100644
--- a/pkg/domain/infra/tunnel/containers.go
+++ b/pkg/domain/infra/tunnel/containers.go
@@ -570,7 +570,7 @@ func (ic *ContainerEngine) ContainerExecDetached(ctx context.Context, nameOrID s
return sessionID, nil
}
-func startAndAttach(ic *ContainerEngine, name string, detachKeys *string, input, output, errput *os.File) error { //nolint
+func startAndAttach(ic *ContainerEngine, name string, detachKeys *string, input, output, errput *os.File) error {
attachErr := make(chan error)
attachReady := make(chan bool)
options := new(containers.AttachOptions).WithStream(true)
@@ -863,7 +863,7 @@ func (ic *ContainerEngine) ContainerRun(ctx context.Context, opts entities.Conta
if eventsErr != nil || lastEvent == nil {
logrus.Errorf("Cannot get exit code: %v", err)
report.ExitCode = define.ExecErrorCodeNotFound
- return &report, nil // nolint: nilerr
+ return &report, nil //nolint: nilerr
}
report.ExitCode = lastEvent.ContainerExitCode
diff --git a/pkg/errorhandling/errorhandling.go b/pkg/errorhandling/errorhandling.go
index 6ee1e7e86..fc6772c08 100644
--- a/pkg/errorhandling/errorhandling.go
+++ b/pkg/errorhandling/errorhandling.go
@@ -86,7 +86,7 @@ func Contains(err error, sub error) bool {
// PodConflictErrorModel is used in remote connections with podman
type PodConflictErrorModel struct {
Errs []string
- Id string // nolint
+ Id string //nolint:revive,stylecheck
}
// ErrorModel is used in remote connections with podman
diff --git a/pkg/hooks/exec/runtimeconfigfilter_test.go b/pkg/hooks/exec/runtimeconfigfilter_test.go
index f4b6cf86a..5c13a76e1 100644
--- a/pkg/hooks/exec/runtimeconfigfilter_test.go
+++ b/pkg/hooks/exec/runtimeconfigfilter_test.go
@@ -13,7 +13,7 @@ import (
)
func TestRuntimeConfigFilter(t *testing.T) {
- unexpectedEndOfJSONInput := json.Unmarshal([]byte("{\n"), nil) //nolint
+ unexpectedEndOfJSONInput := json.Unmarshal([]byte("{\n"), nil) //nolint:govet // this should force the error
fileMode := os.FileMode(0600)
rootUint32 := uint32(0)
binUser := int(1)
diff --git a/pkg/k8s.io/apimachinery/pkg/api/resource/quantity.go b/pkg/k8s.io/apimachinery/pkg/api/resource/quantity.go
index dcc5df219..588a189bf 100644
--- a/pkg/k8s.io/apimachinery/pkg/api/resource/quantity.go
+++ b/pkg/k8s.io/apimachinery/pkg/api/resource/quantity.go
@@ -138,7 +138,6 @@ const (
var (
// Errors that could happen while parsing a string.
- //nolint:revive
ErrFormatWrong = errors.New("quantities must match the regular expression '" + splitREString + "'")
ErrNumeric = errors.New("unable to parse numeric part of quantity")
ErrSuffix = errors.New("unable to parse quantity's suffix")
@@ -258,7 +257,7 @@ Suffix:
// we encountered a non decimal in the Suffix loop, but the last character
// was not a valid exponent
err = ErrFormatWrong
- // nolint:nakedret
+ //nolint:nakedret
return
}
@@ -579,9 +578,9 @@ func (q Quantity) MarshalJSON() ([]byte, error) {
// if CanonicalizeBytes needed more space than our slice provided, we may need to allocate again so use
// append
result = result[:1]
- result = append(result, number...) // nolint: makezero
- result = append(result, suffix...) // nolint: makezero
- result = append(result, '"') // nolint: makezero
+ result = append(result, number...) //nolint: makezero
+ result = append(result, suffix...) //nolint: makezero
+ result = append(result, '"') //nolint: makezero
return result, nil
}
diff --git a/pkg/machine/fcos.go b/pkg/machine/fcos.go
index 77427139a..59ef6d975 100644
--- a/pkg/machine/fcos.go
+++ b/pkg/machine/fcos.go
@@ -139,7 +139,7 @@ func getStreamURL(streamType string) url2.URL {
// This should get Exported and stay put as it will apply to all fcos downloads
// getFCOS parses fedoraCoreOS's stream and returns the image download URL and the release version
-func GetFCOSDownload(imageStream string) (*FcosDownloadInfo, error) { //nolint:staticcheck
+func GetFCOSDownload(imageStream string) (*FcosDownloadInfo, error) {
var (
fcosstable stream.Stream
altMeta release.Release
diff --git a/pkg/machine/qemu/machine.go b/pkg/machine/qemu/machine.go
index 1b0d63986..f27e40043 100644
--- a/pkg/machine/qemu/machine.go
+++ b/pkg/machine/qemu/machine.go
@@ -770,7 +770,7 @@ func (v *MachineVM) Stop(_ string, _ machine.StopOptions) error {
if err := qmpMonitor.Disconnect(); err != nil {
// FIXME: this error should probably be returned
- return nil // nolint: nilerr
+ return nil //nolint: nilerr
}
disconnected = true
diff --git a/pkg/machine/qemu/options_darwin_arm64.go b/pkg/machine/qemu/options_darwin_arm64.go
index 8930041b7..d75237938 100644
--- a/pkg/machine/qemu/options_darwin_arm64.go
+++ b/pkg/machine/qemu/options_darwin_arm64.go
@@ -4,6 +4,8 @@ import (
"os"
"os/exec"
"path/filepath"
+
+ "github.com/containers/common/pkg/config"
)
var (
@@ -38,6 +40,22 @@ func getOvmfDir(imagePath, vmName string) string {
}
/*
+ * When QEmu is installed in a non-default location in the system
+ * we can use the qemu-system-* binary path to figure the install
+ * location for Qemu and use it to look for edk2-code-fd
+ */
+func getEdk2CodeFdPathFromQemuBinaryPath() string {
+ cfg, err := config.Default()
+ if err == nil {
+ execPath, err := cfg.FindHelperBinary(QemuCommand, true)
+ if err == nil {
+ return filepath.Clean(filepath.Join(filepath.Dir(execPath), "..", "share", "qemu"))
+ }
+ }
+ return ""
+}
+
+/*
* QEmu can be installed in multiple locations on MacOS, especially on
* Apple Silicon systems. A build from source will likely install it in
* /usr/local/bin, whereas Homebrew package management standard is to
@@ -45,6 +63,7 @@ func getOvmfDir(imagePath, vmName string) string {
*/
func getEdk2CodeFd(name string) string {
dirs := []string{
+ getEdk2CodeFdPathFromQemuBinaryPath(),
"/opt/homebrew/opt/podman/libexec/share/qemu",
"/usr/local/share/qemu",
"/opt/homebrew/share/qemu",
diff --git a/pkg/rootless/rootless.go b/pkg/rootless/rootless.go
index d7143f549..94535f45e 100644
--- a/pkg/rootless/rootless.go
+++ b/pkg/rootless/rootless.go
@@ -50,7 +50,7 @@ func TryJoinPauseProcess(pausePidPath string) (bool, int, error) {
if err != nil {
// It is still failing. We can safely remove it.
os.Remove(pausePidPath)
- return false, -1, nil // nolint: nilerr
+ return false, -1, nil //nolint: nilerr
}
return became, ret, err
}
diff --git a/pkg/specgen/generate/config_linux.go b/pkg/specgen/generate/config_linux.go
index 4c3748e67..60d87a8fd 100644
--- a/pkg/specgen/generate/config_linux.go
+++ b/pkg/specgen/generate/config_linux.go
@@ -164,7 +164,7 @@ func addDevice(g *generate.Generator, device string) error {
}
// ParseDevice parses device mapping string to a src, dest & permissions string
-func ParseDevice(device string) (string, string, string, error) { //nolint
+func ParseDevice(device string) (string, string, string, error) {
var src string
var dst string
permissions := "rwm"
diff --git a/pkg/specgen/generate/container.go b/pkg/specgen/generate/container.go
index cc376125f..e68abf3d1 100644
--- a/pkg/specgen/generate/container.go
+++ b/pkg/specgen/generate/container.go
@@ -303,8 +303,8 @@ func FinishThrottleDevices(s *specgen.SpecGenerator) error {
if err := unix.Stat(k, &statT); err != nil {
return err
}
- v.Major = (int64(unix.Major(uint64(statT.Rdev)))) // nolint: unconvert
- v.Minor = (int64(unix.Minor(uint64(statT.Rdev)))) // nolint: unconvert
+ v.Major = (int64(unix.Major(uint64(statT.Rdev)))) //nolint: unconvert
+ v.Minor = (int64(unix.Minor(uint64(statT.Rdev)))) //nolint: unconvert
if s.ResourceLimits.BlockIO == nil {
s.ResourceLimits.BlockIO = new(spec.LinuxBlockIO)
}
@@ -317,8 +317,8 @@ func FinishThrottleDevices(s *specgen.SpecGenerator) error {
if err := unix.Stat(k, &statT); err != nil {
return err
}
- v.Major = (int64(unix.Major(uint64(statT.Rdev)))) // nolint: unconvert
- v.Minor = (int64(unix.Minor(uint64(statT.Rdev)))) // nolint: unconvert
+ v.Major = (int64(unix.Major(uint64(statT.Rdev)))) //nolint: unconvert
+ v.Minor = (int64(unix.Minor(uint64(statT.Rdev)))) //nolint: unconvert
s.ResourceLimits.BlockIO.ThrottleWriteBpsDevice = append(s.ResourceLimits.BlockIO.ThrottleWriteBpsDevice, v)
}
}
@@ -328,8 +328,8 @@ func FinishThrottleDevices(s *specgen.SpecGenerator) error {
if err := unix.Stat(k, &statT); err != nil {
return err
}
- v.Major = (int64(unix.Major(uint64(statT.Rdev)))) // nolint: unconvert
- v.Minor = (int64(unix.Minor(uint64(statT.Rdev)))) // nolint: unconvert
+ v.Major = (int64(unix.Major(uint64(statT.Rdev)))) //nolint: unconvert
+ v.Minor = (int64(unix.Minor(uint64(statT.Rdev)))) //nolint: unconvert
s.ResourceLimits.BlockIO.ThrottleReadIOPSDevice = append(s.ResourceLimits.BlockIO.ThrottleReadIOPSDevice, v)
}
}
@@ -339,8 +339,8 @@ func FinishThrottleDevices(s *specgen.SpecGenerator) error {
if err := unix.Stat(k, &statT); err != nil {
return err
}
- v.Major = (int64(unix.Major(uint64(statT.Rdev)))) // nolint: unconvert
- v.Minor = (int64(unix.Minor(uint64(statT.Rdev)))) // nolint: unconvert
+ v.Major = (int64(unix.Major(uint64(statT.Rdev)))) //nolint: unconvert
+ v.Minor = (int64(unix.Minor(uint64(statT.Rdev)))) //nolint: unconvert
s.ResourceLimits.BlockIO.ThrottleWriteIOPSDevice = append(s.ResourceLimits.BlockIO.ThrottleWriteIOPSDevice, v)
}
}
diff --git a/pkg/specgen/generate/oci.go b/pkg/specgen/generate/oci.go
index 716960024..19f55c9d8 100644
--- a/pkg/specgen/generate/oci.go
+++ b/pkg/specgen/generate/oci.go
@@ -371,7 +371,7 @@ func SpecGenToOCI(ctx context.Context, s *specgen.SpecGenerator, rt *libpod.Runt
if err := unix.Stat(k, &statT); err != nil {
return nil, errors.Wrapf(err, "failed to inspect '%s' in --blkio-weight-device", k)
}
- g.AddLinuxResourcesBlockIOWeightDevice((int64(unix.Major(uint64(statT.Rdev)))), (int64(unix.Minor(uint64(statT.Rdev)))), *v.Weight) // nolint: unconvert
+ g.AddLinuxResourcesBlockIOWeightDevice((int64(unix.Major(uint64(statT.Rdev)))), (int64(unix.Minor(uint64(statT.Rdev)))), *v.Weight) //nolint: unconvert
}
BlockAccessToKernelFilesystems(s.Privileged, s.PidNS.IsHost(), s.Mask, s.Unmask, &g)
diff --git a/pkg/util/utils_linux.go b/pkg/util/utils_linux.go
index 871303f64..bc522361f 100644
--- a/pkg/util/utils_linux.go
+++ b/pkg/util/utils_linux.go
@@ -176,7 +176,7 @@ func DeviceFromPath(path string) (*spec.LinuxDevice, error) {
var (
devType string
mode = stat.Mode
- devNumber = uint64(stat.Rdev) // nolint: unconvert
+ devNumber = uint64(stat.Rdev) //nolint: unconvert
m = os.FileMode(mode)
)
diff --git a/test/apiv2/test-apiv2 b/test/apiv2/test-apiv2
index 8ecc2aa2d..25f648d93 100755
--- a/test/apiv2/test-apiv2
+++ b/test/apiv2/test-apiv2
@@ -380,6 +380,17 @@ function start_service() {
die "Cannot start service on non-localhost ($HOST)"
fi
+ # FIXME: EXPERIMENTAL: 2022-06-13: podman rootless needs a namespace. If
+ # system-service is the first podman command run (as is the case in CI)
+ # this will happen as a fork-exec, where the parent podman creates the
+ # namespace and the child is the server. Then, when stop_service() kills
+ # the parent, the child (server) happily stays alive and ruins subsequent
+ # tests that try to restart service with different settings.
+ # Workaround: run an unshare to get namespaces initialized.
+ if [[ $(id -u) != 0 ]]; then
+ $PODMAN_BIN unshare true
+ fi
+
$PODMAN_BIN \
--root $WORKDIR/server_root --syslog=true \
system service \
@@ -387,6 +398,7 @@ function start_service() {
tcp:127.0.0.1:$PORT \
&> $WORKDIR/server.log &
service_pid=$!
+ echo "# started service, pid $service_pid"
wait_for_port $HOST $PORT
}
@@ -396,7 +408,14 @@ function stop_service() {
if [[ -n $service_pid ]]; then
kill $service_pid || :
wait $service_pid || :
+ echo "# stopped service, pid $service_pid"
fi
+ service_pid=
+
+ if { exec 3<> /dev/tcp/$HOST/$PORT; } &>/dev/null; then
+ echo "# WARNING: stop_service: Service still running on port $PORT"
+ fi
+
}
####################
@@ -468,6 +487,7 @@ function start_registry() {
${REGISTRY_IMAGE}
wait_for_port localhost $REGISTRY_PORT 10
+ echo "# started registry (auth=$auth) on port $PORT"
}
function stop_registry() {
@@ -482,6 +502,7 @@ function stop_registry() {
if [[ "$1" = "--cleanup" ]]; then
podman $OPTS rmi -f -a
fi
+ echo "# stopped registry on port $PORT"
fi
REGISTRY_PORT=
diff --git a/test/buildah-bud/apply-podman-deltas b/test/buildah-bud/apply-podman-deltas
index 0bde060ed..0b691dd0e 100755
--- a/test/buildah-bud/apply-podman-deltas
+++ b/test/buildah-bud/apply-podman-deltas
@@ -155,13 +155,7 @@ errmsg "checking authfile: stat /tmp/nonexistent: no such file or directory" \
###############################################################################
# BEGIN tests that don't make sense under podman due to fundamental differences
-# TODO
-# Normally, when buildah exits 1 on error, podman exits 125.
-# These tests are the exception. They exit 1 under podman.
-skip "these tests exit 1 under podman, not 125" \
- "bud with --add-host" \
- "bud - invalid runtime flags test"
-
+# Fails with "Error: no context directory and no Containerfile specified"
skip "does not work under podman" \
"bud without any arguments should succeed"
@@ -172,8 +166,9 @@ skip "does not work under podman" \
skip "FIXME FIXME FIXME: argument-order incompatible with podman" \
"bud-squash-hardlinks"
-skip "FIXME FIXME FIXME: this passes on Ed's laptop, fails in CI??" \
- "bud-multi-stage-nocache-nocommit"
+# Fails with "Error: context must be a directory: /path/to/Dockerfile"
+skip "podman-build fails with 'context must be a directory'" \
+ "bud with specified context should succeed if context contains existing Dockerfile"
###############################################################################
# BEGIN tests which are skipped because they make no sense under podman-remote
@@ -240,4 +235,12 @@ skip_if_remote "FIXME FIXME FIXME: find a way to clean up their podman calls" \
"bud with run should not leave mounts behind cleanup test" \
"bud with custom files in /run/ should persist cleanup test"
+# Under podman-remote, the "Ignoring <stdin>:5:2: error: #error" message
+# is never seen. (Not even as stdout/stderr on the server; Ed checked).
+skip_if_remote "FIXME FIXME FIXME: 'Ignoring' warning is never seen" \
+ "bud with preprocessor error"
+
+# END tests which are skipped due to actual podman or podman-remote bugs.
+###############################################################################
+
exit $RC
diff --git a/test/buildah-bud/buildah-tests.diff b/test/buildah-bud/buildah-tests.diff
index 6fa36d904..399042240 100644
--- a/test/buildah-bud/buildah-tests.diff
+++ b/test/buildah-bud/buildah-tests.diff
@@ -1,15 +1,15 @@
-From 8a8fa1a75e0fa3261263afbc8c2504feb430df6a Mon Sep 17 00:00:00 2001
+From 6508e3df2a129554fdf8336d8a6f0cdcc6fd4832 Mon Sep 17 00:00:00 2001
From: Ed Santiago <santiago@redhat.com>
Date: Tue, 9 Feb 2021 17:28:05 -0700
Subject: [PATCH] tweaks for running buildah tests under podman
Signed-off-by: Ed Santiago <santiago@redhat.com>
---
- tests/helpers.bash | 69 ++++++++++++++++++++++++++++++++++++++++++++--
- 1 file changed, 66 insertions(+), 3 deletions(-)
+ tests/helpers.bash | 70 ++++++++++++++++++++++++++++++++++++++++++++--
+ 1 file changed, 67 insertions(+), 3 deletions(-)
diff --git a/tests/helpers.bash b/tests/helpers.bash
-index e3087063..b3a8f5ee 100644
+index e3087063..178a486e 100644
--- a/tests/helpers.bash
+++ b/tests/helpers.bash
@@ -51,6 +51,23 @@ EOF
@@ -60,13 +60,13 @@ index e3087063..b3a8f5ee 100644
# There are various scenarios where we would like to execute `tests` as rootless user, however certain commands like `buildah mount`
# do not work in rootless session since a normal user cannot mount a filesystem unless they're in a user namespace along with its
# own mount namespace. In order to run such specific commands from a rootless session we must perform `buildah unshare`.
-@@ -247,8 +274,35 @@ function run_buildah() {
+@@ -247,8 +274,36 @@ function run_buildah() {
--retry) retry=3; shift;; # retry network flakes
esac
+ local podman_or_buildah=${BUILDAH_BINARY}
+ local _opts="${ROOTDIR_OPTS} ${BUILDAH_REGISTRY_OPTS}"
-+ if [[ $1 == "build" || $1 == "build-using-dockerfile" ]]; then
++ if [[ $1 == "build" || $1 == "build-using-dockerfile" || $1 == "bud" ]]; then
+ shift
+ # podman defaults to --layers=true; buildah to --false.
+ # If command line includes explicit --layers, leave it untouched,
@@ -82,10 +82,11 @@ index e3087063..b3a8f5ee 100644
+ _opts=
+ fi
+
-+ # podman always exits 125 where buildah exits 1 or 2 (or, in the
-+ # case of git, 128, which is a bug in git, but I won't harp on that).
++ # Special case: there's one test that invokes git in such
++ # a way that it exits 128 (which IMO is a bug in git).
++ # podman exits 125 in that case.
+ case $expected_rc in
-+ 1|2|128) expected_rc=125 ;;
++ 128) expected_rc=125 ;;
+ esac
+ fi
+ local cmd_basename=$(basename ${podman_or_buildah})
@@ -97,7 +98,7 @@ index e3087063..b3a8f5ee 100644
# If session is rootless and `buildah mount` is invoked, perform unshare,
# since normal user cannot mount a filesystem unless they're in a user namespace along with its own mount namespace.
-@@ -262,8 +316,8 @@ function run_buildah() {
+@@ -262,8 +317,8 @@ function run_buildah() {
retry=$(( retry - 1 ))
# stdout is only emitted upon error; this echo is to help a debugger
@@ -108,7 +109,7 @@ index e3087063..b3a8f5ee 100644
# without "quotes", multiple lines are glommed together into one
if [ -n "$output" ]; then
echo "$output"
-@@ -595,6 +649,15 @@ function skip_if_no_docker() {
+@@ -595,6 +650,15 @@ function skip_if_no_docker() {
fi
}
@@ -125,5 +126,5 @@ index e3087063..b3a8f5ee 100644
daemondir=${TEST_SCRATCH_DIR}/git-daemon
mkdir -p ${daemondir}/repo
--
-2.35.1
+2.35.3
diff --git a/test/buildah-bud/run-buildah-bud-tests b/test/buildah-bud/run-buildah-bud-tests
index eb8de5618..4ff062496 100755
--- a/test/buildah-bud/run-buildah-bud-tests
+++ b/test/buildah-bud/run-buildah-bud-tests
@@ -93,6 +93,12 @@ fi
# From here on out, any error is fatal
set -e
+# Run sudo early, to refresh the credentials cache. This is a NOP under CI,
+# but might be appreciated by developers who run this script, step away
+# during the git-checkout-buildah step, then come back twenty minutes later
+# to an expired sudo prompt and no tests have run.
+sudo --validate
+
# Before pulling buildah (while still cd'ed to podman repo), try to determine
# if this is a PR, and if so if it's a revendoring of buildah. We use this to
# try to offer a helpful hint on failure.
diff --git a/test/e2e/common_test.go b/test/e2e/common_test.go
index db194b777..194d592f4 100644
--- a/test/e2e/common_test.go
+++ b/test/e2e/common_test.go
@@ -41,7 +41,7 @@ var (
CGROUP_MANAGER = "systemd" //nolint:revive,stylecheck
RESTORE_IMAGES = []string{ALPINE, BB, nginx} //nolint:revive,stylecheck
defaultWaitTimeout = 90
- CGROUPSV2, _ = cgroups.IsCgroup2UnifiedMode() //nolint:revive,stylecheck
+ CGROUPSV2, _ = cgroups.IsCgroup2UnifiedMode()
)
// PodmanTestIntegration struct for command line options
diff --git a/test/e2e/run_volume_test.go b/test/e2e/run_volume_test.go
index 1c0480407..f31e62e42 100644
--- a/test/e2e/run_volume_test.go
+++ b/test/e2e/run_volume_test.go
@@ -908,6 +908,20 @@ USER testuser`, fedoraMinimal)
Expect(session.OutputToString()).To(Equal(perms))
})
+ It("podman run with -v $SRC:/run does not create /run/.containerenv", func() {
+ mountSrc := filepath.Join(podmanTest.TempDir, "vol-test1")
+ err := os.MkdirAll(mountSrc, 0755)
+ Expect(err).To(BeNil())
+
+ session := podmanTest.Podman([]string{"run", "-v", mountSrc + ":/run", ALPINE, "true"})
+ session.WaitWithDefaultTimeout()
+ Expect(session).Should(Exit(0))
+
+ // the file should not have been created
+ _, err = os.Stat(filepath.Join(mountSrc, ".containerenv"))
+ Expect(err).To(Not(BeNil()))
+ })
+
It("podman volume with uid and gid works", func() {
volName := "testVol"
volCreate := podmanTest.Podman([]string{"volume", "create", "--opt", "o=uid=1000", volName})
diff --git a/test/e2e/systemd_activate_test.go b/test/e2e/systemd_activate_test.go
index aeea4f932..c50e43b8d 100644
--- a/test/e2e/systemd_activate_test.go
+++ b/test/e2e/systemd_activate_test.go
@@ -4,6 +4,7 @@ import (
"errors"
"fmt"
"io/fs"
+ "net"
"os"
"os/exec"
"path/filepath"
@@ -21,6 +22,7 @@ var _ = Describe("Systemd activate", func() {
var tempDir string
var err error
var podmanTest *PodmanTestIntegration
+ var activate string
BeforeEach(func() {
tempDir, err = testUtils.CreateTempDirInTempDir()
@@ -31,17 +33,10 @@ var _ = Describe("Systemd activate", func() {
podmanTest = PodmanTestCreate(tempDir)
podmanTest.Setup()
- })
- AfterEach(func() {
- podmanTest.Cleanup()
- processTestResult(CurrentGinkgoTestDescription())
- })
-
- It("stop podman.service", func() {
SkipIfRemote("Testing stopped service requires both podman and podman-remote binaries")
- activate, err := exec.LookPath("systemd-socket-activate")
+ activate, err = exec.LookPath("systemd-socket-activate")
if err != nil {
activate = "/usr/bin/systemd-socket-activate"
}
@@ -54,7 +49,14 @@ var _ = Describe("Systemd activate", func() {
case err != nil:
Skip(err.Error())
}
+ })
+ AfterEach(func() {
+ podmanTest.Cleanup()
+ processTestResult(CurrentGinkgoTestDescription())
+ })
+
+ It("stop podman.service", func() {
// systemd-socket-activate does not support DNS lookups
host := "127.0.0.1"
port, err := podmanUtils.GetRandomPort()
@@ -103,4 +105,37 @@ var _ = Describe("Systemd activate", func() {
Expect(abiSession).To(Exit(0))
Expect(abiSession.OutputToString()).To(Equal("true"))
})
+
+ It("invalid systemd file descriptor", func() {
+ host := "127.0.0.1"
+ port, err := podmanUtils.GetRandomPort()
+ Expect(err).ToNot(HaveOccurred())
+
+ addr := fmt.Sprintf("%s:%d", host, port)
+
+ // start systemd activation with datagram socket
+ activateSession := testUtils.StartSystemExec(activate, []string{
+ "--datagram", "--listen", addr,
+ podmanTest.PodmanBinary,
+ "--root=" + filepath.Join(tempDir, "server_root"),
+ "system", "service",
+ "--time=0",
+ })
+ Expect(activateSession.Exited).ShouldNot(Receive(), "Failed to start podman service")
+
+ // we have to wait for systemd-socket-activate to become ready
+ time.Sleep(1 * time.Second)
+
+ // now dial the socket to start podman
+ conn, err := net.Dial("udp", addr)
+ Expect(err).ToNot(HaveOccurred())
+ defer conn.Close()
+ _, err = conn.Write([]byte("test"))
+ Expect(err).ToNot(HaveOccurred())
+
+ // wait for podman to exit
+ activateSession.Wait(10)
+ Expect(activateSession).To(Exit(125))
+ Expect(activateSession.ErrorToString()).To(ContainSubstring("Error: unexpected fd received from systemd: cannot listen on it"))
+ })
})
diff --git a/test/system/250-systemd.bats b/test/system/250-systemd.bats
index 110d425d2..cf57d2589 100644
--- a/test/system/250-systemd.bats
+++ b/test/system/250-systemd.bats
@@ -362,4 +362,29 @@ EOF
run_podman 1 pod exists test_pod
}
+@test "podman-system-service containers survive service stop" {
+ skip_if_remote "N/A under podman-remote"
+
+ SERVICE_NAME=podman-service-$(random_string)
+ port=$(random_free_port)
+ URL=tcp://127.0.0.1:$port
+
+ systemd-run --unit=$SERVICE_NAME $PODMAN system service $URL --time=0
+ wait_for_port 127.0.0.1 $port
+
+ # Start a long-running container.
+ cname=keeps-running
+ run_podman --url $URL run -d --name $cname $IMAGE top -d 2
+
+ run_podman container inspect -l --format "{{.State.Running}}"
+ is "$output" "true" "This should never fail"
+
+ systemctl stop $SERVICE_NAME
+
+ run_podman container inspect $cname --format "{{.State.Running}}"
+ is "$output" "true" "Container is still running after podman server stops"
+
+ run_podman rm -f -t 0 $cname
+}
+
# vim: filetype=sh
diff --git a/test/system/helpers.systemd.bash b/test/system/helpers.systemd.bash
index 4bde912a4..d9abc087d 100644
--- a/test/system/helpers.systemd.bash
+++ b/test/system/helpers.systemd.bash
@@ -28,3 +28,7 @@ systemctl() {
journalctl() {
command journalctl $_DASHUSER "$@"
}
+
+systemd-run() {
+ command systemd-run $_DASHUSER "$@";
+}