aboutsummaryrefslogtreecommitdiff
path: root/libpod
diff options
context:
space:
mode:
authorUrvashi Mohnani <umohnani@redhat.com>2022-07-24 19:44:41 -0400
committerUrvashi Mohnani <umohnani@redhat.com>2022-08-30 10:34:45 -0400
commit98169c20ddc09d8fa14d556e93cad3259b5ccca9 (patch)
tree693394b009dcd1b81425dcf5a8f9474ed333409a /libpod
parent57441b4c7127b30d9327cb4dfa189c8b9fc33ac5 (diff)
downloadpodman-98169c20ddc09d8fa14d556e93cad3259b5ccca9.tar.gz
podman-98169c20ddc09d8fa14d556e93cad3259b5ccca9.tar.bz2
podman-98169c20ddc09d8fa14d556e93cad3259b5ccca9.zip
Add emptyDir volume support to kube play
When a kube yaml has a volume set as empty dir, podman will create an anonymous volume with the empty dir name and attach it to the containers running in the pod. When the pod is removed, the empy dir volume created is also removed. Add tests and docs for this as well. Signed-off-by: Urvashi Mohnani <umohnani@redhat.com>
Diffstat (limited to 'libpod')
-rw-r--r--libpod/container.go3
-rw-r--r--libpod/options.go7
-rw-r--r--libpod/runtime_ctr.go11
3 files changed, 15 insertions, 6 deletions
diff --git a/libpod/container.go b/libpod/container.go
index 6c05b1084..44a8669fd 100644
--- a/libpod/container.go
+++ b/libpod/container.go
@@ -237,6 +237,9 @@ type ContainerNamedVolume struct {
Dest string `json:"dest"`
// Options are fstab style mount options
Options []string `json:"options,omitempty"`
+ // IsAnonymous sets the named volume as anonymous even if it has a name
+ // This is used for emptyDir volumes from a kube yaml
+ IsAnonymous bool `json:"setAnonymous,omitempty"`
}
// ContainerOverlayVolume is a overlay volume that will be mounted into the
diff --git a/libpod/options.go b/libpod/options.go
index d31741094..56d5265d2 100644
--- a/libpod/options.go
+++ b/libpod/options.go
@@ -1413,9 +1413,10 @@ func WithNamedVolumes(volumes []*ContainerNamedVolume) CtrCreateOption {
}
ctr.config.NamedVolumes = append(ctr.config.NamedVolumes, &ContainerNamedVolume{
- Name: vol.Name,
- Dest: vol.Dest,
- Options: mountOpts,
+ Name: vol.Name,
+ Dest: vol.Dest,
+ Options: mountOpts,
+ IsAnonymous: vol.IsAnonymous,
})
}
diff --git a/libpod/runtime_ctr.go b/libpod/runtime_ctr.go
index 703ae5cbe..b43114fab 100644
--- a/libpod/runtime_ctr.go
+++ b/libpod/runtime_ctr.go
@@ -474,6 +474,11 @@ func (r *Runtime) setupContainer(ctx context.Context, ctr *Container) (_ *Contai
return nil, fmt.Errorf("error retrieving named volume %s for new container: %w", vol.Name, err)
}
}
+ if vol.IsAnonymous {
+ // If SetAnonymous is true, make this an anonymous volume
+ // this is needed for emptyDir volumes from kube yamls
+ isAnonymous = true
+ }
logrus.Debugf("Creating new volume %s for container", vol.Name)
@@ -814,11 +819,11 @@ func (r *Runtime) removeContainer(ctx context.Context, c *Container, force, remo
// Ignore error, since podman will report original error
volumesFrom, _ := c.volumesFrom()
if len(volumesFrom) > 0 {
- logrus.Debugf("Cleaning up volume not possible since volume is in use (%s)", v)
+ logrus.Debugf("Cleaning up volume not possible since volume is in use (%s)", v.Name)
continue
}
}
- logrus.Errorf("Cleaning up volume (%s): %v", v, err)
+ logrus.Errorf("Cleaning up volume (%s): %v", v.Name, err)
}
}
}
@@ -968,7 +973,7 @@ func (r *Runtime) evictContainer(ctx context.Context, idOrName string, removeVol
continue
}
if err := r.removeVolume(ctx, volume, false, timeout, false); err != nil && err != define.ErrNoSuchVolume && err != define.ErrVolumeBeingUsed {
- logrus.Errorf("Cleaning up volume (%s): %v", v, err)
+ logrus.Errorf("Cleaning up volume (%s): %v", v.Name, err)
}
}
}