Skip to content

Commit

Permalink
Log PPID for better debugging (#4398)
Browse files Browse the repository at this point in the history
It is unusual on Linux for cloud-init to be started
by any process besides PID 1. To ease debugging, log
parent process PID and executable.

Note: current implementation only supports Linux
  • Loading branch information
holmanb authored Sep 1, 2023
1 parent 8761fe8 commit dc7c48b
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions cloudinit/cmd/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,21 @@ def print_exc(msg=""):
sys.stderr.write("\n")


def log_ppid():
if util.is_Linux():
ppid = os.getppid()
LOG.info(
"PID [%s] started cloud-init using: %s",
ppid,
os.path.realpath(f"/proc/{ppid}/exe"),
)


def welcome(action, msg=None):
if not msg:
msg = welcome_format(action)
util.multi_log("%s\n" % (msg), console=False, stderr=True, log=LOG)
log_ppid()
return msg


Expand Down

0 comments on commit dc7c48b

Please sign in to comment.