-
Notifications
You must be signed in to change notification settings - Fork 822
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
feat: Warn user of unexpected run mode #5209
base: main
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -72,17 +72,21 @@ def print_exc(msg=""): | |
sys.stderr.write("\n") | ||
|
||
|
||
def log_ppid(): | ||
if util.is_Linux(): | ||
def log_ppid(distro): | ||
if distro.is_linux: | ||
ppid = os.getppid() | ||
LOG.info("PID [%s] started cloud-init.", ppid) | ||
log = LOG.info | ||
extra_message = "" | ||
if 1 != ppid and distro.uses_systemd(): | ||
log = LOG.warning | ||
extra_message = ("Not a supported configuration.",) | ||
log("PID [%s] started cloud-init. %s", ppid, extra_message) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Are we intentionally not logging the PID when There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That's what the code did before, but I suppose we should be able to log PPID on non-linux too. I'm curious whether the PPID=1 should hold true on any of the BSDs, and it wouldn't hurt to log it. |
||
|
||
|
||
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 | ||
|
||
|
||
|
@@ -324,6 +328,7 @@ def main_init(name, args): | |
init = stages.Init(ds_deps=deps, reporter=args.reporter) | ||
# Stage 1 | ||
init.read_cfg(extract_fns(args)) | ||
log_ppid(init.distro) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This cannot happen until after |
||
# Stage 2 | ||
outfmt = None | ||
errfmt = None | ||
|
@@ -580,6 +585,7 @@ def main_modules(action_name, args): | |
init = stages.Init(ds_deps=[], reporter=args.reporter) | ||
# Stage 1 | ||
init.read_cfg(extract_fns(args)) | ||
log_ppid(init.distro) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Need to move this down a bit too after |
||
# Stage 2 | ||
try: | ||
init.fetch(existing="trust") | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -490,6 +490,12 @@ def multi_log( | |
|
||
@lru_cache() | ||
def is_Linux(): | ||
"""deprecated: prefer Distro object's `is_linux` property | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We could just drop this function altogether if we can figure a better approach to sort There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yep! |
||
|
||
Multiple sources of truth is bad, and already know whether we are | ||
working with Linux from the Distro class. Using Distro offers greater code | ||
reusablity, cleaner code, and easier maintenance. | ||
""" | ||
return "Linux" in platform.system() | ||
|
||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's add details in the extra message to tell use what's unsupported about it.
Unsupported configuration: boot stage called outside of systemd