Fix stacktrace in DataSourceRbxCloud if no metadata disk is found.#632
Conversation
Largely speaking, ds-identify protects from this scenario being hit, but if DataSourceRbxCloud ran and there was no metadata disks found (LABEL=CLOUDMD), then it would stacktrace. The fix is just to clean up the get_md function a little bit, and the explicitly check for False as a return value in _get_data.
767b912 to
28376d1
Compare
|
|
||
| def get_md(): | ||
| rbx_data = None | ||
| """Returns False (not found or error) or a dictionary with metadata.""" |
There was a problem hiding this comment.
instead of (or in addition to) this long-winded doc-string, we could add a type annotation
There was a problem hiding this comment.
instead of (or in addition to) this long-winded doc-string, we could add a type annotation
The return type is Union[dict, bool] which we can't express in our still-supporting-3.4 codebase.
TheRealFalcon
left a comment
There was a problem hiding this comment.
Do you think it makes sense to have get_md return an empty dictionary rather than false if nothing is found and then in generate_network_config check if rbx_data is truthy? Either way, I think this looks good.
|
|
||
| def get_md(): | ||
| rbx_data = None | ||
| """Returns False (not found or error) or a dictionary with metadata.""" |
There was a problem hiding this comment.
instead of (or in addition to) this long-winded doc-string, we could add a type annotation
The return type is Union[dict, bool] which we can't express in our still-supporting-3.4 codebase.
|
@smoser we're looking at SRU verification for this, do you have access to test this or was this a side fix that is not easily verifiable? Thanks |
|
Recreating the failure can be done like: |
Verify that if cloud-init is using DataSourceRbxCloud, there is no traceback if the metadata disk cannot be found.
Proposed Commit Message
Fix stacktrace in DataSourceRbxCloud if no metadata disk is found.
Largely speaking, ds-identify protects from this scenario being
hit, but if DataSourceRbxCloud ran and there was no metadata
disks found (LABEL=CLOUDMD), then it would stacktrace.
The fix is just to clean up the get_md function a little
bit, and the explicitly check for False as a return value in _get_data.
Additional Context
This was seen in a log attached to LP: #1901831.
Checklist: