CSE executed before cloud-init

Open
#161 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
28/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Stale
Tech stack
azure, linux

Research direction

Start with the custom-script extension's enable handler and the ARM template dependency described in the issue. Compare the custom-script handler.log timestamps with cloud-init's journal entries, then trace how startup ordering is determined. Done means the CSE does not run its command until cloud-init has completed and the installed az command is available.

Written by the indexing model from the issue text.

Description

Hello,

I have an ARM template with VM + CSE script to be executed.
I've provided a cloud-init config through customData parameter.

My cloud-init looks as follows:

#cloud-config
package_upgrade: true
package_update: true
packages:
  - libssl-dev
  - libffi-dev
  - python-dev
runcmd:
  - curl -sL https://aka.ms/InstallAzureCLIDeb | sudo bash
  - az aks install-cli

Within the CSE script, I'm trying to run az login command, but I keep getting an error az: command not found.

When I ssh into VM, I can see az working just fine.

Actual behavior

I've looked through logs, and this is what I saw:

$ journalctl -b | grep cloud-init
Feb 10 16:25:14 kch-test-cluster-setupvm cloud-init[1613]: The following NEW packages will be installed:
Feb 10 16:25:14 kch-test-cluster-setupvm cloud-init[1613]:   azure-cli
Feb 10 16:25:14 kch-test-cluster-setupvm cloud-init[1613]: 0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
Feb 10 16:25:14 kch-test-cluster-setupvm cloud-init[1613]: Need to get 46.4 MB of archives.
Feb 10 16:25:14 kch-test-cluster-setupvm cloud-init[1613]: After this operation, 490 MB of additional disk space will be used.
Feb 10 16:25:14 kch-test-cluster-setupvm cloud-init[1613]: Get:1 https://packages.microsoft.com/repos/azure-cli bionic/main amd64 azure-cli all 2.0.81-1~bionic [46.4 MB]
Feb 10 16:25:15 kch-test-cluster-setupvm cloud-init[1613]: Fetched 46.4 MB in 1s (48.9 MB/s)
Feb 10 16:25:24 kch-test-cluster-setupvm cloud-init[1613]: Selecting previously unselected package azure-cli.
Feb 10 16:25:24 kch-test-cluster-setupvm cloud-init[1613]: [614B blob data]
Feb 10 16:25:24 kch-test-cluster-setupvm cloud-init[1613]: Preparing to unpack .../azure-cli_2.0.81-1~bionic_all.deb ...
Feb 10 16:25:24 kch-test-cluster-setupvm cloud-init[1613]: Unpacking azure-cli (2.0.81-1~bionic) ...
Feb 10 16:26:47 kch-test-cluster-setupvm cloud-init[1613]: Setting up azure-cli (2.0.81-1~bionic) ...
...

Please, note the time.

Then I've looked through custom script logs

$ cat /var/log/azure/custom-script/handler.log
...
time=2020-02-10T16:24:35Z version=v2.1.3/git@4cd2b9f-clean operation=enable seq=0 event="executing command" output=/var/lib/waagent/custom-script/download/0
time=2020-02-10T16:24:35Z version=v2.1.3/git@4cd2b9f-clean operation=enable seq=0 event="executing protected commandToExecute" output=/var/lib/waagent/custom-script/download/0
time=2020-02-10T16:24:36Z version=v2.1.3/git@4cd2b9f-clean operation=enable seq=0 event="failed to execute command" error="command terminated with exit status=1" output=/var/lib/waagent/custom-script/download/0
time=2020-02-10T16:24:36Z version=v2.1.3/git@4cd2b9f-clean operation=enable seq=0 event="enable failed"
time=2020-02-10T16:24:36Z version=v2.1.3/git@4cd2b9f-clean operation=enable seq=0 event="failed to handle" error="failed to execute command: command terminated with exit status=1"
...

Again, notice the time.

It turns out, CSE executed before cloud-init.

Expected behavior

I would expect CSE to be executed after cloud-init, especially since in my ARM template I have defined a dependency for CSE on VM deployment.

Best,
Karol

Dominant language
Go
Stars
113
Forks
46
Avg merge
4d 15h
Merged PRs (30d)
3

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from Azure/custom-script-extension-linux

All issues in Azure/custom-script-extension-linux

Similar issues

More Go issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.