mirror of
https://github.com/containers/podman.git
synced 2025-09-19 12:56:57 +08:00
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>
This commit is contained in:
@ -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)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user