WALinuxAgent: [BUG] WALinuxAgent service should start after the cloud-config service

Currently (On Canonical UbuntuServer 18.04-LTS) the WALinuxAgent service and cloud-init run in parallel on start-up causing issues with contention of the package repository.

I believe that WALinuxAgent should start after the cloud-config service to ensure that:

Distro and WALinuxAgent details:

  • Distro and Version: [e.g. Ubuntu 18.04 latest image]
  • WALinuxAgent version
WALinuxAgent-2.2.45 running on ubuntu 18.04
Python: 3.6.9
Goal state agent: 2.2.48.1

Additional context My current situation when starting an Ubuntu 18.04 VM, with the Log Analytics extension is that:

  1. WALinuxAgent starts, installs the Log Analytics agent (through extension) then;
  2. Shortly after (~2 seconds or so) cloud-init starts with the following configuration:
package_upgrade: true
package_reboot_if_required: true
  1. WALinuxAgent or Log Analytics agent has the package repository lock, and causes cloud-init to fail

My current solution is to modify the service behaviour by adding this override to /etc/systemd/system/walinuxagent.service.d/override.conf from within bootcmd using cloud-init:

[Unit]
After=cloud-config.service

About this issue

  • Original URL
  • State: open
  • Created 6 years ago
  • Reactions: 13
  • Comments: 17 (1 by maintainers)

Most upvoted comments

+1

It seems utterly bizarre to leave this broken for two and a half years: cloud-init has been around for over a decade and is absolutely industry standard. To have an external agent that wades in without any reference to cloud-init renders it unusable. There is a provided mechanism to check if cloud-init is still running https://cloudinit.readthedocs.io/en/latest/reference/faq.html

Update on this; my proposed solution doesn’t appear to work reliably.

I believe that the walinuxagent service needs to start after cloud-final to be more robust. I’m achieving that with the following in cloud-init:

bootcmd:
  - mkdir -p /etc/systemd/system/walinuxagent.service.d
  - echo "[Unit]\nAfter=cloud-final.service" > /etc/systemd/system/walinuxagent.service.d/override.conf
  - sed "s/After=multi-user.target//g" /lib/systemd/system/cloud-final.service > /etc/systemd/system/cloud-final.service
  - systemctl daemon-reload

We implemented the solution some time ago and everything worked well.

Update on this; my proposed solution doesn’t appear to work reliably.

I believe that the walinuxagent service needs to start after cloud-final to be more robust. I’m achieving that with the following in cloud-init:

bootcmd:

  • mkdir -p /etc/systemd/system/walinuxagent.service.d
  • echo “[Unit]\nAfter=cloud-final.service” > /etc/systemd/system/walinuxagent.service.d/override.conf
  • sed “s/After=multi-user.target//g” /lib/systemd/system/cloud-final.service > /etc/systemd/system/cloud-final.service
  • systemctl daemon-reload

Recently, our cloud-init process failed due to connection issues. We use these workers to run the Azure DevOps extension, which is installed by the WALinuxAgent. Normally, the provided solution ensures that the extension is installed only after cloud-init completes. However, because cloud-init failed, it was marked as finished, so WALinuxAgent proceeded to install the Azure DevOps agent extension even though the initialization was incomplete.

So we extended the workaround by testing the status of cloud-init.

# walinuxagent installs extansion (eg. azure devops pipeline agent)
# to have all the tools ready, we need to wait for cloud init
# unfortunately this is a open issue https://github.com/Azure/WALinuxAgent/issues/1938
bootcmd:
  - mkdir -p /etc/systemd/system/walinuxagent.service.d
  - echo "[Service]\nExecStartPre=cloud-init status --wait" > /etc/systemd/system/walinuxagent.service.d/cloudinittest.conf # only start when cloud init was successful (2 is recoverable error, we should allow that when we notice many problems)
  - echo "[Unit]\nAfter=cloud-final.service" > /etc/systemd/system/walinuxagent.service.d/cloudinitwait.conf # Start after cloud init service to reduce time waiting
  - sed "s/After=multi-user.target//g" /lib/systemd/system/cloud-final.service > /etc/systemd/system/cloud-final.service # fix dependency cycle
  - systemctl daemon-reload

Good workaround but this should be fix, or allow extension sequencing for customScript extension.