Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bash option 'set -e' is ignored #5808

Open
pschirch opened this issue Oct 10, 2024 · 1 comment
Open

Bash option 'set -e' is ignored #5808

pschirch opened this issue Oct 10, 2024 · 1 comment
Labels
bug Something isn't working correctly incomplete Action required by submitter

Comments

@pschirch
Copy link

pschirch commented Oct 10, 2024

Bug report

You usually use set -e to exit a script on error. cloud-init status should be error now. But cloud-init continues and ends up with status done.

cloud-init status --long

status: done
extended_status: done
boot_status_code: enabled-by-generator
last_update: Thu, 01 Jan 1970 00:01:48 +0000
detail: DataSourceHetzner
errors: []
recoverable_errors: {}

Steps to reproduce the problem

#cloud-config
write_files:
  - owner: root:root
    path: /root/.cloud-init/some-script.sh
    content: |
      #!/bin/bash

      set -e

      a command that will fail

runcmd:
  - /bin/bash /root/.cloud-init/some-script.sh

Environment details

  • Cloud-init version: 24.3.1-0ubuntu0~24.04.2
  • Operating System Distribution: Ubuntu 24.04.1 LTS
  • Cloud provider, platform or installer type: hcloud

cloud-init logs

 /root/.cloud-init/some-script.sh: line 5: a: command not found
@pschirch pschirch added bug Something isn't working correctly new An issue that still needs triage labels Oct 10, 2024
@TheRealFalcon
Copy link
Member

@pschirch , I cannot reproduce this. Using the same version of Ubuntu, cloud-init, and your user data, I get:

# cloud-init status --wait --long
......status: error
extended_status: error - done
boot_status_code: enabled-by-generator
last_update: Thu, 01 Jan 1970 00:00:06 +0000
detail: DataSourceLXD
errors:
	- ('scripts_user', RuntimeError('Runparts: 1 failures (runcmd) in 1 attempted commands'))
recoverable_errors:
WARNING:
	- Failed to run module scripts_user (scripts in /var/lib/cloud/instance/scripts)
	- Running module scripts_user (<module 'cloudinit.config.cc_scripts_user' from '/usr/lib/python3/dist-packages/cloudinit/config/cc_scripts_user.py'>) failed

Can you run cloud-init collect-logs on an affected instance and upload them?

@TheRealFalcon TheRealFalcon added incomplete Action required by submitter and removed new An issue that still needs triage labels Oct 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working correctly incomplete Action required by submitter
Projects
None yet
Development

No branches or pull requests

2 participants