Skip to content
This repository has been archived by the owner on May 30, 2023. It is now read-only.

coreos-base/oem-gce: bring back shutdown scripts #1912

Merged
merged 2 commits into from
May 24, 2022
Merged

Conversation

tormath1
Copy link
Contributor

@tormath1 tormath1 commented May 23, 2022

In the init.sh of the OEM GCE container, we have the following
section:

wait -n "${daemon_pids[@]}" || :
kill "${daemon_pids[@]}" || :

test -n "$stopping" || exit 1

exec /usr/bin/google_metadata_script_runner --script-type shutdown

shutdown script was not executed because container was receiving a
SIGKILL, the started processes was not properly terminated.

According to the systemd-nspawn manual:

If --boot is not used and this option is not specified
the container's processes are terminated abruptly via SIGKILL

Signed-off-by: Mathieu Tortuyaux mtortuyaux@microsoft.com


Testing done

Added a shutdown-script to the GCP metadata server, edited the oem-gce to add the --kill-signal=SIGTERM, manually stopped the service and see the shutdown-script being executed in the logs:

Trying to halt container. Send SIGTERM again to trigger immediate termination.
++ stopping=1
++ kill 30 31 32
+ :
+ kill 30 31 32
+ test -n 1
+ exec /usr/bin/google_metadata_script_runner --script-type shutdown
Stopping GCE Linux Agent...
INFO Starting shutdown scripts.
INFO Found shutdown-script in metadata.
INFO shutdown-script: Return code 0.
INFO Finished running shutdown scripts.
Container oem-gce exited successfully.
oem-gce.service: Deactivated successfully.
Stopped GCE Linux Agent.
oem-gce.service: Consumed 4.964s CPU time.
  • Changelog entries added in the respective changelog/ directory (user-facing change, bug fix, security fix, update)

Closes: flatcar/Flatcar#743

In the `init.sh` of the OEM GCE container, we have the following
section:

```bash
wait -n "${daemon_pids[@]}" || :
kill "${daemon_pids[@]}" || :

test -n "$stopping" || exit 1

exec /usr/bin/google_metadata_script_runner --script-type shutdown
```

`shutdown` script was not executed because container was receiving a
`SIGKILL`, the started processes was not properly terminated.

According to the `systemd-nspawn` manual:
```bash
If --boot is not used and this option is not specified
the container's processes are terminated abruptly via SIGKILL
```

Signed-off-by: Mathieu Tortuyaux <mtortuyaux@microsoft.com>
@tormath1 tormath1 self-assigned this May 23, 2022
Signed-off-by: Mathieu Tortuyaux <mtortuyaux@microsoft.com>
@tormath1 tormath1 added the main label May 23, 2022
@tormath1 tormath1 marked this pull request as ready for review May 23, 2022 16:08
@tormath1 tormath1 requested a review from a team May 23, 2022 16:08
@tormath1 tormath1 merged commit d75df5a into main May 24, 2022
@tormath1 tormath1 deleted the tormath1/gcp branch May 24, 2022 07:27
@tormath1
Copy link
Contributor Author

tormath1 commented May 24, 2022

cherry-picked to:

  • flatcar-3227
  • flatcar-3139
  • flatcar-3248

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

shutdown-script metadata in GCP not working. Was working in old coreos.
2 participants