diff options
Diffstat (limited to 'libpod')
-rw-r--r-- | libpod/container.go | 8 | ||||
-rw-r--r-- | libpod/container_api.go | 1 | ||||
-rw-r--r-- | libpod/container_attach_linux.go | 6 | ||||
-rw-r--r-- | libpod/container_internal.go | 3 | ||||
-rw-r--r-- | libpod/container_internal_linux.go | 6 | ||||
-rw-r--r-- | libpod/define/errors.go | 2 | ||||
-rw-r--r-- | libpod/healthcheck.go | 2 | ||||
-rw-r--r-- | libpod/image/search.go | 3 | ||||
-rw-r--r-- | libpod/kube.go | 1 | ||||
-rw-r--r-- | libpod/oci.go | 3 | ||||
-rw-r--r-- | libpod/oci_linux.go | 2 | ||||
-rw-r--r-- | libpod/runtime_ctr.go | 12 | ||||
-rw-r--r-- | libpod/runtime_pod_linux.go | 6 | ||||
-rw-r--r-- | libpod/stats.go | 2 |
14 files changed, 22 insertions, 35 deletions
diff --git a/libpod/container.go b/libpod/container.go index b71c0b2be..2d96b1120 100644 --- a/libpod/container.go +++ b/libpod/container.go @@ -445,7 +445,7 @@ func (c *Container) specFromState() (*spec.Spec, error) { if err != nil { return nil, errors.Wrapf(err, "error reading container config") } - if err := json.Unmarshal([]byte(content), &returnSpec); err != nil { + if err := json.Unmarshal(content, &returnSpec); err != nil { return nil, errors.Wrapf(err, "error unmarshalling container config") } } else { @@ -1030,7 +1030,7 @@ func (c *Container) StoppedByUser() (bool, error) { // NamespacePath returns the path of one of the container's namespaces // If the container is not running, an error will be returned -func (c *Container) NamespacePath(ns LinuxNS) (string, error) { +func (c *Container) NamespacePath(linuxNS LinuxNS) (string, error) { //nolint:interfacer if !c.batched { c.lock.Lock() defer c.lock.Unlock() @@ -1043,11 +1043,11 @@ func (c *Container) NamespacePath(ns LinuxNS) (string, error) { return "", errors.Wrapf(define.ErrCtrStopped, "cannot get namespace path unless container %s is running", c.ID()) } - if ns == InvalidNS { + if linuxNS == InvalidNS { return "", errors.Wrapf(define.ErrInvalidArg, "invalid namespace requested from container %s", c.ID()) } - return fmt.Sprintf("/proc/%d/ns/%s", c.state.PID, ns.String()), nil + return fmt.Sprintf("/proc/%d/ns/%s", c.state.PID, linuxNS.String()), nil } // CGroupPath returns a cgroups "path" for a given container. diff --git a/libpod/container_api.go b/libpod/container_api.go index 6f530f75f..50fa1759d 100644 --- a/libpod/container_api.go +++ b/libpod/container_api.go @@ -115,7 +115,6 @@ func (c *Container) StartAndAttach(ctx context.Context, streams *AttachStreams, if err := c.prepareToStart(ctx, recursive); err != nil { return nil, err } - attachChan := make(chan error) // We need to ensure that we don't return until start() fired in attach. diff --git a/libpod/container_attach_linux.go b/libpod/container_attach_linux.go index 43dd7d579..837cbf916 100644 --- a/libpod/container_attach_linux.go +++ b/libpod/container_attach_linux.go @@ -88,7 +88,11 @@ func (c *Container) attachContainerSocket(resize <-chan remotecommand.TerminalSi if err != nil { return errors.Wrapf(err, "failed to connect to container's attach socket: %v", socketPath) } - defer conn.Close() + defer func() { + if err := conn.Close(); err != nil { + logrus.Errorf("unable to close socket: %q", err) + } + }() // If starting was requested, start the container and notify when that's // done. diff --git a/libpod/container_internal.go b/libpod/container_internal.go index 47b425c0a..ca27f5814 100644 --- a/libpod/container_internal.go +++ b/libpod/container_internal.go @@ -1264,6 +1264,7 @@ func (c *Container) postDeleteHooks(ctx context.Context) (err error) { return err } for i, hook := range extensionHooks { + hook := hook logrus.Debugf("container %s: invoke poststop hook %d, path %s", c.ID(), i, hook.Path) var stderr, stdout bytes.Buffer hookErr, err := exec.Run(ctx, &hook, state, &stdout, &stderr, exec.DefaultPostKillTimeout) @@ -1513,7 +1514,7 @@ func (c *Container) prepareCheckpointExport() (err error) { logrus.Debugf("generating spec for container %q failed with %v", c.ID(), err) return err } - if err := c.writeJSONFile(g.Spec(), "spec.dump"); err != nil { + if err := c.writeJSONFile(g.Config, "spec.dump"); err != nil { return err } diff --git a/libpod/container_internal_linux.go b/libpod/container_internal_linux.go index 399220b9a..3dfd4c9e9 100644 --- a/libpod/container_internal_linux.go +++ b/libpod/container_internal_linux.go @@ -686,8 +686,8 @@ func (c *Container) importCheckpoint(input string) (err error) { } // Make sure the newly created config.json exists on disk - g := generate.NewFromSpec(c.config.Spec) - if err = c.saveSpec(g.Spec()); err != nil { + g := generate.Generator{Config: c.config.Spec} + if err = c.saveSpec(g.Config); err != nil { return errors.Wrap(err, "Saving imported container specification for restore failed") } @@ -814,7 +814,7 @@ func (c *Container) restore(ctx context.Context, options ContainerCheckpointOpti } // Save the OCI spec to disk - if err := c.saveSpec(g.Spec()); err != nil { + if err := c.saveSpec(g.Config); err != nil { return err } diff --git a/libpod/define/errors.go b/libpod/define/errors.go index 14643ced1..3b8313855 100644 --- a/libpod/define/errors.go +++ b/libpod/define/errors.go @@ -95,7 +95,7 @@ var ( // ErrOSNotSupported indicates the function is not available on the particular // OS. - ErrOSNotSupported = errors.New("No support for this OS yet") + ErrOSNotSupported = errors.New("no support for this OS yet") // ErrOCIRuntime indicates an error from the OCI runtime ErrOCIRuntime = errors.New("OCI runtime error") diff --git a/libpod/healthcheck.go b/libpod/healthcheck.go index 8ed2b12e1..1a19b88bb 100644 --- a/libpod/healthcheck.go +++ b/libpod/healthcheck.go @@ -230,7 +230,7 @@ func (c *Container) updateHealthCheckLog(hcl HealthCheckLog, inStartPeriod bool) // increment failing streak healthCheck.FailingStreak = healthCheck.FailingStreak + 1 // if failing streak > retries, then status to unhealthy - if int(healthCheck.FailingStreak) >= c.HealthCheckConfig().Retries { + if healthCheck.FailingStreak >= c.HealthCheckConfig().Retries { healthCheck.Status = HealthCheckUnhealthy } } diff --git a/libpod/image/search.go b/libpod/image/search.go index 9984e5234..e557431c6 100644 --- a/libpod/image/search.go +++ b/libpod/image/search.go @@ -217,21 +217,18 @@ func ParseSearchFilter(filter []string) (*SearchFilter, error) { return nil, errors.Wrapf(err, "incorrect value type for stars filter") } sFilter.Stars = stars - break case "is-automated": if len(arr) == 2 && arr[1] == "false" { sFilter.IsAutomated = types.OptionalBoolFalse } else { sFilter.IsAutomated = types.OptionalBoolTrue } - break case "is-official": if len(arr) == 2 && arr[1] == "false" { sFilter.IsOfficial = types.OptionalBoolFalse } else { sFilter.IsOfficial = types.OptionalBoolTrue } - break default: return nil, errors.Errorf("invalid filter type %q", f) } diff --git a/libpod/kube.go b/libpod/kube.go index b114cda72..084a3df4f 100644 --- a/libpod/kube.go +++ b/libpod/kube.go @@ -155,6 +155,7 @@ func (p *Pod) podWithContainers(containers []*Container, ports []v1.ContainerPor // Deduplicate volumes, so if containers in the pod share a volume, it's only // listed in the volumes section once for _, vol := range volumes { + vol := vol deDupPodVolumes[vol.Name] = &vol } } diff --git a/libpod/oci.go b/libpod/oci.go index 566cbd821..3daf9f834 100644 --- a/libpod/oci.go +++ b/libpod/oci.go @@ -169,7 +169,6 @@ func bindPorts(ports []ocicni.PortMapping) ([]*os.File, error) { return nil, errors.Wrapf(err, "cannot get file for UDP socket") } files = append(files, f) - break case "tcp": addr, err := net.ResolveTCPAddr("tcp4", fmt.Sprintf("%s:%d", i.HostIP, i.HostPort)) @@ -186,13 +185,11 @@ func bindPorts(ports []ocicni.PortMapping) ([]*os.File, error) { return nil, errors.Wrapf(err, "cannot get file for TCP socket") } files = append(files, f) - break case "sctp": if !notifySCTP { notifySCTP = true logrus.Warnf("port reservation for SCTP is not supported") } - break default: return nil, fmt.Errorf("unknown protocol %s", i.Protocol) diff --git a/libpod/oci_linux.go b/libpod/oci_linux.go index 1182457f4..9ce836cb5 100644 --- a/libpod/oci_linux.go +++ b/libpod/oci_linux.go @@ -89,7 +89,7 @@ func makeAccessible(path string, uid, gid int) error { continue } if st.Mode()&0111 != 0111 { - if err := os.Chmod(path, os.FileMode(st.Mode()|0111)); err != nil { + if err := os.Chmod(path, st.Mode()|0111); err != nil { return err } } diff --git a/libpod/runtime_ctr.go b/libpod/runtime_ctr.go index 4b3aeaa37..e57ab4634 100644 --- a/libpod/runtime_ctr.go +++ b/libpod/runtime_ctr.go @@ -432,20 +432,12 @@ func (r *Runtime) removeContainer(ctx context.Context, c *Container, force bool, // from the state elsewhere if !removePod { if err := r.state.RemoveContainerFromPod(pod, c); err != nil { - if cleanupErr == nil { - cleanupErr = err - } else { - logrus.Errorf("removing container from pod: %v", err) - } + cleanupErr = err } } } else { if err := r.state.RemoveContainer(c); err != nil { - if cleanupErr == nil { - cleanupErr = err - } else { - logrus.Errorf("removing container: %v", err) - } + cleanupErr = err } } diff --git a/libpod/runtime_pod_linux.go b/libpod/runtime_pod_linux.go index d667d3a25..f38e6e7c1 100644 --- a/libpod/runtime_pod_linux.go +++ b/libpod/runtime_pod_linux.go @@ -201,11 +201,7 @@ func (r *Runtime) removePod(ctx context.Context, p *Pod, removeCtrs, force bool) conmonCgroupPath := filepath.Join(p.state.CgroupPath, "conmon") conmonCgroup, err := cgroups.Load(conmonCgroupPath) if err != nil && err != cgroups.ErrCgroupDeleted { - if removalErr == nil { - removalErr = errors.Wrapf(err, "error retrieving pod %s conmon cgroup %s", p.ID(), conmonCgroupPath) - } else { - logrus.Errorf("Error retrieving pod %s conmon cgroup %s: %v", p.ID(), conmonCgroupPath, err) - } + removalErr = errors.Wrapf(err, "error retrieving pod %s conmon cgroup %s", p.ID(), conmonCgroupPath) } // New resource limits diff --git a/libpod/stats.go b/libpod/stats.go index 52af824bb..8101fbbbd 100644 --- a/libpod/stats.go +++ b/libpod/stats.go @@ -86,7 +86,7 @@ func getMemLimit(cgroupLimit uint64) uint64 { return cgroupLimit } - physicalLimit := uint64(si.Totalram) + physicalLimit := si.Totalram if cgroupLimit > physicalLimit { return physicalLimit } |