GoogleCloudPlatform / guest-agent

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

GCP vm runs start up script before google_guest_agent creates sudoers file

meytalzuta opened this issue · comments

Hi,

We have a test running a startup script on GCP VM (Debian GNU/Linux 10). As part of the startup script we call 'su ubuntu'. The start up script sometimes fails on 'user ubuntu doesn't exist.

google_guest_agent version: GCE Agent Started (version 20231115.00)

When looking at the VM startup logs we see that on successful runs, the google_guest_agent is creating the sudoers file and is creating the ubuntu user before running our startup script:

Jan  4 13:02:09 vm-1 google_guest_agent[479]: Created google sudoers file

Jan  4 13:02:09 vm-1 google_guest_agent[479]: Creating user ubuntu.

Jan  4 13:02:10 vm-1 google_guest_agent[479]: Updating keys for user ubuntu.

On failed runs, the last entries of google_guest_agent in the log are:

Jan  4 13:02:09 vm-1 google_guest_agent[479]: Starting the scheduler to run jobs

[  OK  ] Started OpenBSD Secure Shell server.

Jan  4 13:02:09 vm-1 systemd[1]: Started OpenBSD Secure Shell server.

Jan  4 13:02:09 vm-1 google_guest_agent[479]: Scheduling job: telemetryJobID

Jan  4 13:02:09 vm-11 google_guest_agent[479]: Scheduling job "telemetryJobID" to run at 24.000000 hr interval

Jan  4 13:02:09 vm-1 google_guest_agent[479]: Successfully scheduled job telemetryJobID

Jan  4 13:02:09 vm-1 google_guest_agent[479]: Invoking job "telemetryJobID"

Jan  4 13:02:09 vm-1 dhclient[841]: Internet Systems Consortium DHCP Client 4.4.1

Jan  4 13:02:09 vm-1 dhclient[841]: Copyright 2004-2018 Internet Systems Consortium.

Jan  4 13:02:09 vm-1 dhclient[841]: All rights reserved.

Jan  4 13:02:09 vm-1 dhclient[841]: For info, please visit [https://www.isc.org/software/dhcp/](https://www.google.com/url?q=https://www.isc.org/software/dhcp/&sa=D)

Jan  4 13:02:09 vm-1 dhclient[841]: 

Jan  4 13:02:09 vm-1 google_guest_agent[479]: Scheduler - added: [now 2024-01-04 13:02:09.592349485 +0000 UTC entry 1 next 2024-01-05 13:02:09 +0000 UTC]

Is there a way to make sure the google_guest_agent run has completed before starting our scripts?

Hi @meytalzuta,

This looks like a timing issue.

Metadata script runner is already configured to run after Guest Agent has started. Agent executes minimum required setup steps before notifying systemd (systemd-notify --ready) its ready, and this startup process does not involve creating users/sudoers file.