-
Notifications
You must be signed in to change notification settings - Fork 883
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
handle TypeError when get_mount_info function get None #4322
Conversation
cloudinit/util.py
Outdated
*_, mnt_opts = get_mount_info(path, get_mnt_opts=True) | ||
except TypeError: | ||
LOG.warning( | ||
"Get Nothing mount info from %s", |
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.
this message reads really confusing
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.
I think this should say: "Found no mount info for %s",
@@ -2782,7 +2782,14 @@ def get_mount_info(path, log=LOG, get_mnt_opts=False): | |||
|
|||
|
|||
def has_mount_opt(path, opt: str) -> bool: | |||
*_, mnt_opts = get_mount_info(path, get_mnt_opts=True) | |||
try: | |||
*_, mnt_opts = get_mount_info(path, get_mnt_opts=True) |
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.
why would this function return None
to begin with?
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.
why would this function return
None
to begin with?
The reason still needs to be further identified. However, when we look at the implementation code of this function, there is some cases of returning None.
https://github.com/canonical/cloud-init/blob/main/cloudinit/util.py#L2530
https://github.com/canonical/cloud-init/blob/main/cloudinit/util.py#L2560
https://github.com/canonical/cloud-init/blob/main/cloudinit/util.py#L2570
https://github.com/canonical/cloud-init/blob/main/cloudinit/util.py#L2583
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.
of all of those, only the first and the last would leave no trace in the log
the first one would mean your mountinfo file is in the wrong, or a new unknown, different, format. Hopefully, that's an easy fix.
the last one would mean no match was found, including no match for /
! I'm not sure there are scenarios where that makes sense (at least as a system to run cloud-init on)
Per @blackboxsw's comment, I don't think that the current approach is desired to resolve the issue. |
Yes, we may need to fundamentally address why function get_mount_info() returns None. |
Proposed Commit Message
handle TypeError when get_mount_info function get None
Fixes GH-4321