mirror of
https://github.com/containers/podman.git
synced 2025-06-20 09:03:43 +08:00
Merge pull request #20898 from edsantiago/systemctl_debug
systests: debug systemd failures
This commit is contained in:
@ -46,8 +46,7 @@ function service_setup() {
|
|||||||
run systemctl enable "$SERVICE_NAME"
|
run systemctl enable "$SERVICE_NAME"
|
||||||
assert $status -eq 0 "Error enabling systemd unit $SERVICE_NAME: $output"
|
assert $status -eq 0 "Error enabling systemd unit $SERVICE_NAME: $output"
|
||||||
|
|
||||||
run systemctl start "$SERVICE_NAME"
|
systemctl_start "$SERVICE_NAME"
|
||||||
assert $status -eq 0 "Error starting systemd unit $SERVICE_NAME: $output"
|
|
||||||
|
|
||||||
run systemctl status "$SERVICE_NAME"
|
run systemctl status "$SERVICE_NAME"
|
||||||
assert $status -eq 0 "systemctl status $SERVICE_NAME: $output"
|
assert $status -eq 0 "systemctl status $SERVICE_NAME: $output"
|
||||||
@ -230,8 +229,7 @@ LISTEN_FDNAMES=listen_fdnames" | sort)
|
|||||||
systemctl daemon-reload
|
systemctl daemon-reload
|
||||||
|
|
||||||
INSTANCE="$SERVICE_NAME@1.service"
|
INSTANCE="$SERVICE_NAME@1.service"
|
||||||
run systemctl start "$INSTANCE"
|
systemctl_start "$INSTANCE"
|
||||||
assert $status -eq 0 "Error starting systemd unit $INSTANCE: $output"
|
|
||||||
|
|
||||||
run systemctl status "$INSTANCE"
|
run systemctl status "$INSTANCE"
|
||||||
assert $status -eq 0 "systemctl status $INSTANCE: $output"
|
assert $status -eq 0 "systemctl status $INSTANCE: $output"
|
||||||
@ -401,7 +399,7 @@ EOF
|
|||||||
|
|
||||||
# Dispatch the YAML file
|
# Dispatch the YAML file
|
||||||
service_name="podman-kube@$(systemd-escape $yaml_source).service"
|
service_name="podman-kube@$(systemd-escape $yaml_source).service"
|
||||||
systemctl start $service_name
|
systemctl_start $service_name
|
||||||
systemctl is-active $service_name
|
systemctl is-active $service_name
|
||||||
|
|
||||||
# Make sure that Podman is the service's MainPID
|
# Make sure that Podman is the service's MainPID
|
||||||
@ -456,7 +454,7 @@ $name stderr" "logs work with passthrough"
|
|||||||
|
|
||||||
# Now stop and start the service again.
|
# Now stop and start the service again.
|
||||||
systemctl stop $service_name
|
systemctl stop $service_name
|
||||||
systemctl start $service_name
|
systemctl_start $service_name
|
||||||
systemctl is-active $service_name
|
systemctl is-active $service_name
|
||||||
run_podman container inspect $service_container --format "{{.State.Running}}"
|
run_podman container inspect $service_container --format "{{.State.Running}}"
|
||||||
is "$output" "true"
|
is "$output" "true"
|
||||||
|
@ -91,10 +91,7 @@ function service_setup() {
|
|||||||
local activestate="inactive"
|
local activestate="inactive"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "$_LOG_PROMPT systemctl $startargs start $service"
|
systemctl_start $startargs "$service"
|
||||||
run systemctl $startargs start "$service"
|
|
||||||
echo "$output"
|
|
||||||
assert $status -eq 0 "Error starting systemd unit $service"
|
|
||||||
|
|
||||||
# FIXME FIXME FIXME: this is racy with short-lived containers!
|
# FIXME FIXME FIXME: this is racy with short-lived containers!
|
||||||
echo "$_LOG_PROMPT systemctl status $service"
|
echo "$_LOG_PROMPT systemctl status $service"
|
||||||
@ -798,7 +795,7 @@ ExecStart=/bin/bash -c "echo %T >$percent_t_file"
|
|||||||
Type=oneshot
|
Type=oneshot
|
||||||
EOF
|
EOF
|
||||||
systemctl daemon-reload
|
systemctl daemon-reload
|
||||||
systemctl --wait start $service
|
systemctl_start --wait $service
|
||||||
percent_t=$(< $percent_t_file)
|
percent_t=$(< $percent_t_file)
|
||||||
# Clean up. Don't bother to systemctl-reload, service_setup does that below.
|
# Clean up. Don't bother to systemctl-reload, service_setup does that below.
|
||||||
rm -f $unitfile
|
rm -f $unitfile
|
||||||
|
@ -92,7 +92,7 @@ function generate_service() {
|
|||||||
run_podman rm -t 0 -f $cname
|
run_podman rm -t 0 -f $cname
|
||||||
|
|
||||||
systemctl daemon-reload
|
systemctl daemon-reload
|
||||||
systemctl start container-$cname
|
systemctl_start container-$cname
|
||||||
systemctl status container-$cname
|
systemctl status container-$cname
|
||||||
|
|
||||||
# Original image ID.
|
# Original image ID.
|
||||||
@ -530,7 +530,7 @@ EOF
|
|||||||
|
|
||||||
# Dispatch the YAML file
|
# Dispatch the YAML file
|
||||||
service_name="podman-kube@$(systemd-escape $yaml_source).service"
|
service_name="podman-kube@$(systemd-escape $yaml_source).service"
|
||||||
systemctl start $service_name
|
systemctl_start $service_name
|
||||||
systemctl is-active $service_name
|
systemctl is-active $service_name
|
||||||
|
|
||||||
# Make sure the containers are properly configured
|
# Make sure the containers are properly configured
|
||||||
@ -588,8 +588,7 @@ EOF
|
|||||||
|
|
||||||
systemctl daemon-reload
|
systemctl daemon-reload
|
||||||
|
|
||||||
run systemctl start pod-$podname.service
|
systemctl_start pod-$podname.service
|
||||||
assert $status -eq 0 "Error starting pod systemd unit: $output"
|
|
||||||
_wait_service_ready container-$ctrname.service
|
_wait_service_ready container-$ctrname.service
|
||||||
|
|
||||||
run_podman pod inspect --format "{{.State}}" $podname
|
run_podman pod inspect --format "{{.State}}" $podname
|
||||||
|
@ -59,7 +59,7 @@ EOF
|
|||||||
rm -f $pause_pid_file
|
rm -f $pause_pid_file
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
systemctl start "$SERVICE_NAME.socket"
|
systemctl_start "$SERVICE_NAME.socket"
|
||||||
}
|
}
|
||||||
|
|
||||||
function teardown() {
|
function teardown() {
|
||||||
|
@ -33,6 +33,41 @@ systemd-run() {
|
|||||||
timeout --foreground -v --kill=10 $PODMAN_TIMEOUT systemd-run $_DASHUSER "$@";
|
timeout --foreground -v --kill=10 $PODMAN_TIMEOUT systemd-run $_DASHUSER "$@";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# "systemctl start" is special: when it fails, it doesn't give any useful info.
|
||||||
|
# This helper fixes that.
|
||||||
|
systemctl_start() {
|
||||||
|
# Arg processing. First arg might be "--wait"...
|
||||||
|
local wait=
|
||||||
|
if [[ "$1" = "--wait" ]]; then
|
||||||
|
wait="$1"
|
||||||
|
shift
|
||||||
|
fi
|
||||||
|
# ...but beyond that, only one arg is allowed
|
||||||
|
local unit="$1"
|
||||||
|
shift
|
||||||
|
assert "$*" = "" "systemctl_start invoked with spurious args"
|
||||||
|
|
||||||
|
echo "$_LOG_PROMPT systemctl $wait start $unit"
|
||||||
|
run systemctl $wait start "$unit"
|
||||||
|
echo "$output"
|
||||||
|
if [[ $status -eq 0 ]]; then
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Failed. This is our value added.
|
||||||
|
echo
|
||||||
|
echo "***** systemctl start $unit -- FAILED!"
|
||||||
|
echo
|
||||||
|
echo "$_LOG_PROMPT systemctl status $unit"
|
||||||
|
run systemctl status "$unit"
|
||||||
|
echo "$output"
|
||||||
|
echo
|
||||||
|
echo "$_LOG_PROMPT journalctl -xeu $unit"
|
||||||
|
run journalctl -xeu "$unit"
|
||||||
|
echo "$output"
|
||||||
|
false
|
||||||
|
}
|
||||||
|
|
||||||
install_kube_template() {
|
install_kube_template() {
|
||||||
# If running from a podman source directory, build and use the source
|
# If running from a podman source directory, build and use the source
|
||||||
# version of the play-kube-@ unit file
|
# version of the play-kube-@ unit file
|
||||||
|
Reference in New Issue
Block a user