Skip to content

Commit 5cb4fe3

Browse files
Merge pull request #17058 from vrothberg/fix-17024
service container: less verbose error logs
2 parents 4bbe2ee + d2fb6cf commit 5cb4fe3

File tree

2 files changed

+73
-2
lines changed

2 files changed

+73
-2
lines changed

libpod/service.go

+6-2
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,9 @@ func (p *Pod) maybeStopServiceContainer() error {
135135
}
136136
logrus.Debugf("Stopping service container %s", serviceCtr.ID())
137137
if err := serviceCtr.Stop(); err != nil {
138-
logrus.Errorf("Stopping service container %s: %v", serviceCtr.ID(), err)
138+
if !errors.Is(err, define.ErrCtrStopped) {
139+
logrus.Errorf("Stopping service container %s: %v", serviceCtr.ID(), err)
140+
}
139141
}
140142
})
141143
return nil
@@ -239,7 +241,9 @@ func (p *Pod) maybeRemoveServiceContainer() error {
239241
timeout := uint(0)
240242
logrus.Debugf("Removing service container %s", serviceCtr.ID())
241243
if err := p.runtime.RemoveContainer(context.Background(), serviceCtr, true, false, &timeout); err != nil {
242-
logrus.Errorf("Removing service container %s: %v", serviceCtr.ID(), err)
244+
if !errors.Is(err, define.ErrNoSuchCtr) {
245+
logrus.Errorf("Removing service container %s: %v", serviceCtr.ID(), err)
246+
}
243247
}
244248
})
245249
return nil

test/system/700-play.bats

+67
Original file line numberDiff line numberDiff line change
@@ -531,3 +531,70 @@ spec:
531531
run_podman pod rm -a -f
532532
run_podman rm -a -f
533533
}
534+
535+
@test "podman kube play - multi-pod YAML" {
536+
skip_if_remote "service containers only work locally"
537+
skip_if_journald_unavailable
538+
539+
# Create the YAMl file
540+
yaml_source="$PODMAN_TMPDIR/test.yaml"
541+
cat >$yaml_source <<EOF
542+
apiVersion: v1
543+
kind: Pod
544+
metadata:
545+
labels:
546+
app: pod1
547+
name: pod1
548+
spec:
549+
containers:
550+
- command:
551+
- top
552+
image: $IMAGE
553+
name: ctr1
554+
---
555+
apiVersion: v1
556+
kind: Pod
557+
metadata:
558+
labels:
559+
app: pod2
560+
name: pod2
561+
spec:
562+
containers:
563+
- command:
564+
- top
565+
image: $IMAGE
566+
name: ctr2
567+
EOF
568+
# Run `play kube` in the background as it will wait for the service
569+
# container to exit.
570+
timeout --foreground -v --kill=10 60 \
571+
$PODMAN play kube --service-container=true --log-driver journald $yaml_source &>/dev/null &
572+
573+
# The name of the service container is predictable: the first 12 characters
574+
# of the hash of the YAML file followed by the "-service" suffix
575+
yaml_sha=$(sha256sum $yaml_source)
576+
service_container="${yaml_sha:0:12}-service"
577+
# Wait for the containers to be running
578+
container_1=pod1-ctr1
579+
container_2=pod1-ctr2
580+
for i in $(seq 1 20); do
581+
run_podman "?" container wait $container_1 $container_2 $service_container --condition="running"
582+
if [[ $status == 0 ]]; then
583+
break
584+
fi
585+
sleep 0.5
586+
# Just for debugging
587+
run_podman ps -a
588+
done
589+
if [[ $status != 0 ]]; then
590+
die "container $container_1, $container_2 and/or $service_container did not start"
591+
fi
592+
593+
# Stop the pods, make sure that no ugly error logs show up and that the
594+
# service container will implicitly get stopped as well
595+
run_podman pod stop pod1 pod2
596+
assert "$output" !~ "Stopping"
597+
_ensure_container_running $service_container false
598+
599+
run_podman kube down $yaml_source
600+
}

0 commit comments

Comments
 (0)