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

fix: do not log ppid when ppid is undefined #5781

Closed
wants to merge 1 commit into from

Conversation

hcartiaux
Copy link
Contributor

This fixes a bug introduced in the function log_ppid by the commit 75add5c which renders cloud-init unusable on all non-linux systems.

With this commit, cloud-init tried to log the ppid even if it was undefined, because ppid is only collected on linux distros. Here is the output of cloud-init 24.3 on OpenBSD:

Cloud-init v. 24.3 running 'init-local' at Thu, 03 Oct 2024 20:24:37 +0000. Up 39.569653034210205 seconds.
2024-10-03 20:24:38,050 - main.py[ERROR]: failed stage init-local
Traceback (most recent call last):
  File "/usr/local/lib/python3.10/site-packages/cloud_init-24.3-py3.10.egg/cloudinit/cmd/main.py", line 831, in status_wrapper
    ret = functor(name, args)
  File "/usr/local/lib/python3.10/site-packages/cloud_init-24.3-py3.10.egg/cloudinit/cmd/main.py", line 395, in main_init
    log_ppid(init.distro, bootstage_name)
  File "/usr/local/lib/python3.10/site-packages/cloud_init-24.3-py3.10.egg/cloudinit/cmd/main.py", line 112, in log_ppid
    LOG.info("PID [%s] started cloud-init '%s'.", ppid, bootstage_name)
UnboundLocalError: local variable 'ppid' referenced before assignment
failed run of stage init-local

This PR is an attempt to fix this issue by restoring the previous behavior of log_ppid from the commits dc7c48b and 4abdd5a

Proposed Commit Message

fix: do not log ppid when ppid is undefined

This fixes a bug introduced in 75add5c72aa575d373825deddcb685f725e290d8
which renders cloud-init unusable on all non-linux systems.

Merge type

  • Squash merge using "Proposed Commit Message"
  • Rebase and merge unique commits. Requires commit messages per-commit each referencing the pull request number (#<PR_NUM>)

This fixes a bug introduced in 75add5c
which renders cloud-init unusable on all non-linux systems.
@hcartiaux
Copy link
Contributor Author

Note: this PR may be obsoleted by #5770

@blackboxsw
Copy link
Collaborator

@hcartiaux thank you much for your contribution to cloud-init here. I was surprised to discover this same bug while I was improving unittest coverage in my initial pass at limiting deprecated logs inside the log_ppid function. Given that the log_ppid function is removed per #5770. This is no longer an issue. Again, thank you for noticing and proposing a fix.

@blackboxsw blackboxsw closed this Oct 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants