Fix sysconfig render when set-name is missing#1327
Conversation
b04cd67 to
5a218bb
Compare
There was a problem hiding this comment.
Thanks for this fix. Overall LGTM.
The for loop is juuuust starting to get long enough that I'd consider putting the code you added into its own method/function, but I think it's ok as-is too. I'll leave it up to you if you want to change it.
Re: the circular import, I'm not a huge fan of the proposed solution as it adds more indirection and imports an underscore prefixed name.
Given that your current solution is already a workaround, I think a simpler (though maybe slightly hackier) workaround is to move the get_interfaces_by_mac import from the top of network_state.py to the top of the handle_ethernets method where you added it.
Long term, I think that most of the functions at the bottom of network_state.py (is_ipv6_addr through mask_and_ipv5_to_bcast_addr) probably make more sense in cloudinit/net/__init__.py. That's obviously a bigger refactor though, and not one we should do in this PR.
There are a number of test failures due to the moved function, but I think if we just move the import they should be fine.
Yeah, neither was I, but I also am not so actively involved with the project that I felt comfortable to refactor things too heavily.
I thought about that, but
Indeed. See my previous comment about refactoring.
I cannot figure out why as I added a shim to the original location. Why does moving the import fix things? Oh, because of the global symbol being changed? |
This patch refactors several network, helper functions out of the network_state.py file and into cloudinit.net. This is in relation to LP #1855945 and github.com/canonical/pull/1327. The aforementioned issue requires some refactoring to avoid circular imports, but it was not proper to do that refactoring in *that* pull request. Thus this PR is specific to the refactoring and can be evaluated on its own merits.
|
I pushed #1336 to handle the refactored network functions. Once approved, I can rebase this PR on that one. |
This patch refactors several network, helper functions out of the network_state.py file and into cloudinit.net. This is in relation to LP #1855945 and github.com/canonical/pull/1327. The aforementioned issue requires some refactoring to avoid circular imports, but it was not proper to do that refactoring in *that* pull request. Thus this PR is specific to the refactoring and can be evaluated on its own merits.
Yes, but since you did the refactor instead (thanks for that!), not needed. |
This patch refactors several network, helper functions out of the network_state.py file and into cloudinit.net. This is in relation to LP #1855945 and github.com/canonical/pull/1327. The aforementioned issue requires some refactoring to avoid circular imports, but it was not proper to do that refactoring in *that* pull request. Thus this PR is specific to the refactoring and can be evaluated on its own merits.
This patch refactors several network, helper functions out of the network_state.py file and into cloudinit.net. This is in relation to LP #1855945 and github.com//pull/1327. The aforementioned issue requires some refactoring to avoid circular imports, but it was not proper to do that refactoring in *that* pull request. Thus this PR is specific to the refactoring and can be evaluated on its own merits.
This patch addresses https://bugs.launchpad.net/cloud-init/+bug/1855945, where the absence of set-name in a network configuration potentially results in an unintended network configuration. Please note a function from cloudinit.net.networkstate was relocated under cloudinit.net due to a circular dependency introduced by the former calling get_interfaces_by_mac in the latter. A stub function has been created to preserve backward compatibility.
TheRealFalcon
left a comment
There was a problem hiding this comment.
Thanks @akutz . Assuming CI passes, I'll merge this soon.
Proposed Commit Message
Additional Context
NA
Test Steps
Checklist: