Skip to content

Commit

Permalink
Fix cloud-init service-startup dep. loop
Browse files Browse the repository at this point in the history
In GCP, there are google services that must start on boot but we also
rely on the more generic cloud-init services to setup the VM.
Specifically, this is necessary to attend to rootfs resizing properly
before testing.  However, there is a dependency loop created when both
are installed, that will result in messages like:

...network-online.target: Found ordering cycle on \
    cloud-init.service/start
...network-online.target: Found dependency on \
    google-network-daemon.service/start
...network-online.target: Found dependency on \
    google-instance-setup.service/start
...network-online.target: Found dependency on \
    network-online.target/start
...network-online.target: Job cloud-init.service/start \
    deleted to break ordering cycle starting with \
    network-online.target/start

Previously, this was addressed by depositing a customized
cloud-init.service file for Fedora VMs.  However, at some point in the
past this step was dropped.  Restore it.

Also, add a header-comment to this and another custom service file to
indicate where they came from.

Signed-off-by: Chris Evich <[email protected]>
  • Loading branch information
cevich committed Nov 12, 2021
1 parent 5c8cc8b commit a8c3311
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion base_images/fedora_base-setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,20 @@ install_automation_tooling
if ! ((CONTAINER)); then
custom_cloud_init

# Be kind to humans, indicate where generated files came from
sourcemsg="### File generated during VM Image build by $(basename $SCRIPT_FILEPATH)"

if ((OS_RELEASE_VER<35)); then
echo "Overriding cloud-init service file"
# The packaged cloud-init.service unit has a dependency loop
# vs google-network-daemon.service. Fix this with a custom
# cloud-init service file.
CLOUD_SERVICE_PATH="systemd/system/cloud-init.service"
echo "$sourcemsg" > /etc/$CLOUD_SERVICE_PATH
cat $SCRIPT_DIRPATH/fedora-cloud-init.service >> /etc/$CLOUD_SERVICE_PATH
fi

echo "Setting GCP startup service (for Cirrus-CI agent) SELinux unconfined"
# ref: https://cloud.google.com/compute/docs/startupscript
# The mechanism used by Cirrus-CI to execute tasks on the system is through an
# "agent" process launched as a GCP startup-script (from the metadata service).
Expand All @@ -50,9 +64,10 @@ if ! ((CONTAINER)); then
# run with the proper contexts.
METADATA_SERVICE_CTX=unconfined_u:unconfined_r:unconfined_t:s0
METADATA_SERVICE_PATH=systemd/system/google-startup-scripts.service
echo "$sourcemsg" > /etc/$METADATA_SERVICE_PATH
sed -r -e \
"s/^Type=oneshot/Type=oneshot\nSELinuxContext=$METADATA_SERVICE_CTX/" \
/lib/$METADATA_SERVICE_PATH > /etc/$METADATA_SERVICE_PATH
/lib/$METADATA_SERVICE_PATH >> /etc/$METADATA_SERVICE_PATH
fi

if [[ "$OS_RELEASE_ID" == "fedora" ]] && ((OS_RELEASE_VER>=33)); then
Expand Down

0 comments on commit a8c3311

Please sign in to comment.