summaryrefslogtreecommitdiff
path: root/libpod
diff options
context:
space:
mode:
Diffstat (limited to 'libpod')
-rw-r--r--libpod/boltdb_state.go2
-rw-r--r--libpod/config/config.go19
-rw-r--r--libpod/container_internal.go5
-rw-r--r--libpod/container_internal_linux.go7
-rw-r--r--libpod/events/config.go2
-rw-r--r--libpod/healthcheck.go2
-rw-r--r--libpod/image/image.go130
-rw-r--r--libpod/image/pull.go2
-rw-r--r--libpod/kube.go2
-rw-r--r--libpod/lock/shm/shm_lock.c4
-rw-r--r--libpod/options.go3
-rw-r--r--libpod/pod_api.go2
-rw-r--r--libpod/runtime_volume.go2
13 files changed, 75 insertions, 107 deletions
diff --git a/libpod/boltdb_state.go b/libpod/boltdb_state.go
index 608a279c3..4918bf57a 100644
--- a/libpod/boltdb_state.go
+++ b/libpod/boltdb_state.go
@@ -2235,7 +2235,7 @@ func (s *BoltState) RemovePodContainers(pod *Pod) error {
if ctr == nil {
// This should never happen
// State is inconsistent
- return errors.Wrapf(define.ErrNoSuchCtr, "pod %s referenced nonexistant container %s", pod.ID(), string(id))
+ return errors.Wrapf(define.ErrNoSuchCtr, "pod %s referenced nonexistent container %s", pod.ID(), string(id))
}
ctrDeps := ctr.Bucket(dependenciesBkt)
// This should never be nil, but if it is, we're
diff --git a/libpod/config/config.go b/libpod/config/config.go
index 5b4b57f3a..f1fa70fbc 100644
--- a/libpod/config/config.go
+++ b/libpod/config/config.go
@@ -469,6 +469,9 @@ func NewConfig(userConfigPath string) (*Config, error) {
if defaultConfig, err := defaultConfigFromMemory(); err != nil {
return nil, errors.Wrapf(err, "error generating default config from memory")
} else {
+ // Check if we need to switch to cgroupfs and logger=file on rootless.
+ defaultConfig.checkCgroupsAndLogger()
+
if err := config.mergeConfig(defaultConfig); err != nil {
return nil, errors.Wrapf(err, "error merging default config from memory")
}
@@ -487,9 +490,6 @@ func NewConfig(userConfigPath string) (*Config, error) {
return nil, errors.Wrapf(define.ErrInvalidArg, "volume path must be an absolute path - instead got %q", config.VolumePath)
}
- // Check if we need to switch to cgroupfs on rootless.
- config.checkCgroupsAndAdjustConfig()
-
return config, nil
}
@@ -524,11 +524,13 @@ func systemConfigs() ([]string, error) {
return configs, nil
}
-// checkCgroupsAndAdjustConfig checks if we're running rootless with the systemd
+// checkCgroupsAndLogger checks if we're running rootless with the systemd
// cgroup manager. In case the user session isn't available, we're switching the
-// cgroup manager to cgroupfs. Note, this only applies to rootless.
-func (c *Config) checkCgroupsAndAdjustConfig() {
- if !rootless.IsRootless() || c.CgroupManager != define.SystemdCgroupsManager {
+// cgroup manager to cgroupfs and the events logger backend to 'file'.
+// Note, this only applies to rootless.
+func (c *Config) checkCgroupsAndLogger() {
+ if !rootless.IsRootless() || (c.CgroupManager !=
+ define.SystemdCgroupsManager && c.EventsLogger == "file") {
return
}
@@ -543,7 +545,8 @@ func (c *Config) checkCgroupsAndAdjustConfig() {
logrus.Warningf("The cgroups manager is set to systemd but there is no systemd user session available")
logrus.Warningf("For using systemd, you may need to login using an user session")
logrus.Warningf("Alternatively, you can enable lingering with: `loginctl enable-linger %d` (possibly as root)", rootless.GetRootlessUID())
- logrus.Warningf("Falling back to --cgroup-manager=cgroupfs")
+ logrus.Warningf("Falling back to --cgroup-manager=cgroupfs and --events-backend=file")
c.CgroupManager = define.CgroupfsCgroupsManager
+ c.EventsLogger = "file"
}
}
diff --git a/libpod/container_internal.go b/libpod/container_internal.go
index 028d7601d..4ff1913b5 100644
--- a/libpod/container_internal.go
+++ b/libpod/container_internal.go
@@ -652,6 +652,11 @@ func (c *Container) removeConmonFiles() error {
return errors.Wrapf(err, "error removing container %s ctl file", c.ID())
}
+ winszFile := filepath.Join(c.bundlePath(), "winsz")
+ if err := os.Remove(winszFile); err != nil && !os.IsNotExist(err) {
+ return errors.Wrapf(err, "error removing container %s winsz file", c.ID())
+ }
+
oomFile := filepath.Join(c.bundlePath(), "oom")
if err := os.Remove(oomFile); err != nil && !os.IsNotExist(err) {
return errors.Wrapf(err, "error removing container %s OOM file", c.ID())
diff --git a/libpod/container_internal_linux.go b/libpod/container_internal_linux.go
index 26d6771b0..2ecd5911a 100644
--- a/libpod/container_internal_linux.go
+++ b/libpod/container_internal_linux.go
@@ -884,7 +884,12 @@ func (c *Container) restore(ctx context.Context, options ContainerCheckpointOpti
// We want to have the same network namespace as before.
if c.config.CreateNetNS {
- if err := g.AddOrReplaceLinuxNamespace(string(spec.NetworkNamespace), c.state.NetNS.Path()); err != nil {
+ netNSPath := ""
+ if !c.config.PostConfigureNetNS {
+ netNSPath = c.state.NetNS.Path()
+ }
+
+ if err := g.AddOrReplaceLinuxNamespace(string(spec.NetworkNamespace), netNSPath); err != nil {
return err
}
}
diff --git a/libpod/events/config.go b/libpod/events/config.go
index 453c64f8c..20c01baff 100644
--- a/libpod/events/config.go
+++ b/libpod/events/config.go
@@ -167,7 +167,7 @@ type EventFilter func(*Event) bool
var (
// ErrEventTypeBlank indicates the event log found something done by podman
- // but it isnt likely an event
+ // but it isn't likely an event
ErrEventTypeBlank = errors.New("event type blank")
// ErrEventNotFound indicates that the event was not found in the event log
diff --git a/libpod/healthcheck.go b/libpod/healthcheck.go
index e9c950713..b42e7d16a 100644
--- a/libpod/healthcheck.go
+++ b/libpod/healthcheck.go
@@ -31,7 +31,7 @@ const (
// HealthCheckNotDefined means the container has no health
// check defined in it
HealthCheckNotDefined HealthCheckStatus = iota
- // HealthCheckInternalError means somes something failed obtaining or running
+ // HealthCheckInternalError means some something failed obtaining or running
// a given health check
HealthCheckInternalError HealthCheckStatus = iota
// HealthCheckDefined means the healthcheck was found on the container
diff --git a/libpod/image/image.go b/libpod/image/image.go
index 5871c8a57..fa75be44d 100644
--- a/libpod/image/image.go
+++ b/libpod/image/image.go
@@ -770,109 +770,65 @@ func (i *Image) History(ctx context.Context) ([]*History, error) {
return nil, err
}
- // Use our layers list to find images that use any of them (or no
- // layer, since every base layer is derived from an empty layer) as its
- // topmost layer.
- interestingLayers := make(map[string]bool)
- var layer *storage.Layer
- if i.TopLayer() != "" {
- if layer, err = i.imageruntime.store.Layer(i.TopLayer()); err != nil {
- return nil, err
- }
+ // Build a mapping from top-layer to image ID.
+ images, err := i.imageruntime.GetImages()
+ if err != nil {
+ return nil, err
}
- interestingLayers[""] = true
- for layer != nil {
- interestingLayers[layer.ID] = true
- if layer.Parent == "" {
- break
+ topLayerMap := make(map[string]string)
+ for _, image := range images {
+ if _, exists := topLayerMap[image.TopLayer()]; !exists {
+ topLayerMap[image.TopLayer()] = image.ID()
}
- layer, err = i.imageruntime.store.Layer(layer.Parent)
+ }
+
+ var allHistory []*History
+ var layer *storage.Layer
+
+ // Check if we have an actual top layer to prevent lookup errors.
+ if i.TopLayer() != "" {
+ layer, err = i.imageruntime.store.Layer(i.TopLayer())
if err != nil {
return nil, err
}
}
- // Get the IDs of the images that share some of our layers. Hopefully
- // this step means that we'll be able to avoid reading the
- // configuration of every single image in local storage later on.
- images, err := i.imageruntime.GetImages()
- if err != nil {
- return nil, errors.Wrapf(err, "error getting images from store")
- }
- interestingImages := make([]*Image, 0, len(images))
- for i := range images {
- if interestingLayers[images[i].TopLayer()] {
- interestingImages = append(interestingImages, images[i])
- }
- }
+ // Iterate in reverse order over the history entries, and lookup the
+ // corresponding image ID, size and get the next later if needed.
+ numHistories := len(oci.History) - 1
+ for x := numHistories; x >= 0; x-- {
+ var size int64
- // Build a list of image IDs that correspond to our history entries.
- historyImages := make([]*Image, len(oci.History))
- if len(oci.History) > 0 {
- // The starting image shares its whole history with itself.
- historyImages[len(historyImages)-1] = i
- for i := range interestingImages {
- image, err := images[i].ociv1Image(ctx)
- if err != nil {
- return nil, errors.Wrapf(err, "error getting image configuration for image %q", images[i].ID())
+ id := "<missing>"
+ if x == numHistories {
+ id = i.ID()
+ } else if layer != nil {
+ if !oci.History[x].EmptyLayer {
+ size = layer.UncompressedSize
}
- // If the candidate has a longer history or no history
- // at all, then it doesn't share the portion of our
- // history that we're interested in matching with other
- // images.
- if len(image.History) == 0 || len(image.History) > len(historyImages) {
- continue
- }
- // If we don't include all of the layers that the
- // candidate image does (i.e., our rootfs didn't look
- // like its rootfs at any point), then it can't be part
- // of our history.
- if len(image.RootFS.DiffIDs) > len(oci.RootFS.DiffIDs) {
- continue
- }
- candidateLayersAreUsed := true
- for i := range image.RootFS.DiffIDs {
- if image.RootFS.DiffIDs[i] != oci.RootFS.DiffIDs[i] {
- candidateLayersAreUsed = false
- break
- }
- }
- if !candidateLayersAreUsed {
- continue
- }
- // If the candidate's entire history is an initial
- // portion of our history, then we're based on it,
- // either directly or indirectly.
- sharedHistory := historiesMatch(oci.History, image.History)
- if sharedHistory == len(image.History) {
- historyImages[sharedHistory-1] = images[i]
+ if imageID, exists := topLayerMap[layer.ID]; exists {
+ id = imageID
+ // Delete the entry to avoid reusing it for following history items.
+ delete(topLayerMap, layer.ID)
}
}
- }
- var (
- size int64
- sizeCount = 1
- allHistory []*History
- )
-
- for i := len(oci.History) - 1; i >= 0; i-- {
- imageID := "<missing>"
- if historyImages[i] != nil {
- imageID = historyImages[i].ID()
- }
- if !oci.History[i].EmptyLayer {
- size = img.LayerInfos()[len(img.LayerInfos())-sizeCount].Size
- sizeCount++
- }
allHistory = append(allHistory, &History{
- ID: imageID,
- Created: oci.History[i].Created,
- CreatedBy: oci.History[i].CreatedBy,
+ ID: id,
+ Created: oci.History[x].Created,
+ CreatedBy: oci.History[x].CreatedBy,
Size: size,
- Comment: oci.History[i].Comment,
+ Comment: oci.History[x].Comment,
})
+
+ if layer != nil && layer.Parent != "" && !oci.History[x].EmptyLayer {
+ layer, err = i.imageruntime.store.Layer(layer.Parent)
+ if err != nil {
+ return nil, err
+ }
+ }
}
+
return allHistory, nil
}
diff --git a/libpod/image/pull.go b/libpod/image/pull.go
index 99c11e3ff..326a23f4c 100644
--- a/libpod/image/pull.go
+++ b/libpod/image/pull.go
@@ -330,7 +330,7 @@ func (ir *Runtime) doPullImage(ctx context.Context, sc *types.SystemContext, goa
if goal.usedSearchRegistries && len(goal.searchedRegistries) == 0 {
return nil, errors.Errorf("image name provided is a short name and no search registries are defined in the registries config file.")
}
- // If the image passed in was fully-qualified, we will have 1 refpair. Bc the image is fq'd, we dont need to yap about registries.
+ // If the image passed in was fully-qualified, we will have 1 refpair. Bc the image is fq'd, we don't need to yap about registries.
if !goal.usedSearchRegistries {
if pullErrors != nil && len(pullErrors.Errors) > 0 { // this should always be true
return nil, errors.Wrap(pullErrors.Errors[0], "unable to pull image")
diff --git a/libpod/kube.go b/libpod/kube.go
index 47a77991e..6ae3e3d07 100644
--- a/libpod/kube.go
+++ b/libpod/kube.go
@@ -341,7 +341,7 @@ func libpodMountsToKubeVolumeMounts(c *Container) ([]v1.VolumeMount, []v1.Volume
return vms, vos, nil
}
-// generateKubeVolumeMount takes a user specfied mount and returns
+// generateKubeVolumeMount takes a user specified mount and returns
// a kubernetes VolumeMount (to be added to the container) and a kubernetes Volume
// (to be added to the pod)
func generateKubeVolumeMount(m specs.Mount) (v1.VolumeMount, v1.Volume, error) {
diff --git a/libpod/lock/shm/shm_lock.c b/libpod/lock/shm/shm_lock.c
index fbb3f57cc..95052c40f 100644
--- a/libpod/lock/shm/shm_lock.c
+++ b/libpod/lock/shm/shm_lock.c
@@ -145,7 +145,7 @@ shm_struct_t *setup_lock_shm(char *path, uint32_t num_locks, int *error_code) {
// Set mutexes to robust - if a process dies while holding a mutex, we'll get
// a special error code on the next attempt to lock it.
- // This should prevent panicing processes from leaving the state unusable.
+ // This should prevent panicking processes from leaving the state unusable.
ret_code = pthread_mutexattr_setrobust(&attr, PTHREAD_MUTEX_ROBUST);
if (ret_code != 0) {
*error_code = -1 * ret_code;
@@ -298,7 +298,7 @@ int32_t close_lock_shm(shm_struct_t *shm) {
// Allocate the first available semaphore
// Returns a positive integer guaranteed to be less than UINT32_MAX on success,
// or negative errno values on failure
-// On sucess, the returned integer is the number of the semaphore allocated
+// On success, the returned integer is the number of the semaphore allocated
int64_t allocate_semaphore(shm_struct_t *shm) {
int ret_code, i;
bitmap_t test_map;
diff --git a/libpod/options.go b/libpod/options.go
index 00b5626b4..bfbbb9e2d 100644
--- a/libpod/options.go
+++ b/libpod/options.go
@@ -386,8 +386,7 @@ func WithNamespace(ns string) RuntimeOption {
// WithVolumePath sets the path under which all named volumes
// should be created.
-// The path changes based on whethe rthe user is running as root
-// or not.
+// The path changes based on whether the user is running as root or not.
func WithVolumePath(volPath string) RuntimeOption {
return func(rt *Runtime) error {
if rt.valid {
diff --git a/libpod/pod_api.go b/libpod/pod_api.go
index 3a194f04b..b27257004 100644
--- a/libpod/pod_api.go
+++ b/libpod/pod_api.go
@@ -445,7 +445,7 @@ func (p *Pod) Inspect() (*PodInspect, error) {
}
for _, c := range containers {
containerStatus := "unknown"
- // Ignoring possible errors here because we dont want this to be
+ // Ignoring possible errors here because we don't want this to be
// catastrophic in nature
containerState, err := c.State()
if err == nil {
diff --git a/libpod/runtime_volume.go b/libpod/runtime_volume.go
index a6ab748e5..835dccf9c 100644
--- a/libpod/runtime_volume.go
+++ b/libpod/runtime_volume.go
@@ -59,7 +59,7 @@ func (r *Runtime) GetVolume(name string) (*Volume, error) {
return vol, nil
}
-// LookupVolume retrieves a volume by unambigious partial name.
+// LookupVolume retrieves a volume by unambiguous partial name.
func (r *Runtime) LookupVolume(name string) (*Volume, error) {
r.lock.RLock()
defer r.lock.RUnlock()