pod rm: do not log error if anonymous volume is still used

This is not really an error, if the anonymous volume is still used then
this likely means it was transferred to another container with
--volumes-from. This is what the user wants and it is not like the user
can act on the logged error anyway. Once the last user of the volume is
removed it will be removed correctly.

see https://github.com/containers/podman/pull/19637

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
This commit is contained in:
Paul Holzinger
2023-09-22 14:44:14 +02:00
parent 5a3a9ce9c7
commit af2665c28a
2 changed files with 8 additions and 1 deletions

View File

@ -327,7 +327,9 @@ func (r *Runtime) removePod(ctx context.Context, p *Pod, removeCtrs, force bool,
continue
}
if err := r.removeVolume(ctx, volume, false, timeout, false); err != nil {
if errors.Is(err, define.ErrNoSuchVolume) || errors.Is(err, define.ErrVolumeRemoved) {
// If the anonymous volume is still being used that means it was likely transferred
// to another container via --volumes-from so no need to log this as real error.
if errors.Is(err, define.ErrNoSuchVolume) || errors.Is(err, define.ErrVolumeRemoved) || errors.Is(err, define.ErrVolumeBeingUsed) {
continue
}
logrus.Errorf("Removing volume %s: %v", volName, err)

View File

@ -5704,6 +5704,11 @@ spec:
Expect(inspectCtr1).Should(ExitCleanly())
Expect(inspectCtr2.OutputToString()).To(Equal(inspectCtr1.OutputToString()))
// see https://github.com/containers/podman/pull/19637, we should not see any warning/errors here
podrm := podmanTest.Podman([]string{"kube", "down", outputFile})
podrm.WaitWithDefaultTimeout()
Expect(podrm).Should(ExitCleanly())
})
It("test with reserved autoremove annotation in yaml", func() {