service container: less verbose error logs

While manually playing with --service-container, I encountered a number
of too verbose logs.  For instance, there's no need to error-log when
the service-container has already been stopped.

For testing, add a new kube test with a multi-pod YAML which will
implicitly show that #17024 is now working.

Fixes: #17024
Signed-off-by: Valentin Rothberg <vrothberg@redhat.com>
This commit is contained in:
Valentin Rothberg
2023-01-10 15:36:45 +01:00
parent 4bbe2ee012
commit d2fb6cf05d
2 changed files with 73 additions and 2 deletions

View File

@ -135,7 +135,9 @@ func (p *Pod) maybeStopServiceContainer() error {
}
logrus.Debugf("Stopping service container %s", serviceCtr.ID())
if err := serviceCtr.Stop(); err != nil {
logrus.Errorf("Stopping service container %s: %v", serviceCtr.ID(), err)
if !errors.Is(err, define.ErrCtrStopped) {
logrus.Errorf("Stopping service container %s: %v", serviceCtr.ID(), err)
}
}
})
return nil
@ -239,7 +241,9 @@ func (p *Pod) maybeRemoveServiceContainer() error {
timeout := uint(0)
logrus.Debugf("Removing service container %s", serviceCtr.ID())
if err := p.runtime.RemoveContainer(context.Background(), serviceCtr, true, false, &timeout); err != nil {
logrus.Errorf("Removing service container %s: %v", serviceCtr.ID(), err)
if !errors.Is(err, define.ErrNoSuchCtr) {
logrus.Errorf("Removing service container %s: %v", serviceCtr.ID(), err)
}
}
})
return nil