Skip to content
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

fix: Render bridges correctly for v2 on sysconfig with set-name #5674

Merged
merged 2 commits into from
Oct 11, 2024

Conversation

TheRealFalcon
Copy link
Member

Proposed Commit Message

fix: Render bridges correctly for v2 on sysconfig with set-name

When listing interfaces in v2 format, we should expect to be able to
reference other interfaces using the name in the configuration, not
the name the interface will eventually take. This was broken when
using `set-name`.

To fix this, we now store the configuration id alongside the eventual
name, and reference that instead of the name.

Fixes GH-5574

Additional Context

Test Steps

Merge type

  • Squash merge using "Proposed Commit Message"
  • Rebase and merge unique commits. Requires commit messages per-commit each referencing the pull request number (#<PR_NUM>)

When listing interfaces in v2 format, we should expect to be able to
reference other interfaces using the name in the configuration, not
the name the interface will eventually take. This was broken when
using `set-name`.

To fix this, we now store the configuration id alongside the eventual
name, and reference that instead of the name.

Fixes canonicalGH-5574
@TheRealFalcon
Copy link
Member Author

@xiachen-rh , does this solve the issue that you raised in #5574 ?

@xiachen-rh
Copy link
Contributor

Sorry I just notice this, I will test it ASAP and let you know the result.

@xiachen-rh
Copy link
Contributor

@TheRealFalcon Hi James, the fix works for sysconfig renderer. However, we still have an issue for NM renderer, so I filed a new issue #5717 to track it.

@TheRealFalcon
Copy link
Member Author

@xiachen-rh , thanks for checking and filing that issue. We can follow up on that separately.

@holmanb , this is ready for review.

@TheRealFalcon TheRealFalcon mentioned this pull request Sep 24, 2024
2 tasks
@ani-sinha
Copy link
Contributor

@TheRealFalcon @holmanb waiting for this to get merged. Then #5740 .

Copy link
Member

@holmanb holmanb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@TheRealFalcon Thanks for this! I left a couple of nitpicks, take them or leave them. Either way it looks good to me.

iface = copy.deepcopy(iface)

# Remove irrelevant keys
with suppress(KeyError):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like using suppress, but in this case it doesn't appear to add value. Wouldn't something like this suffice?

if iface.get("config_id"):
    iface.pop("config_id")

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It doesn't remove value either than I think easier to ask forgiveness than permission is still slightly more idiomatic.

if "nameservers" in dev_cfg:
search = dev_cfg.get("nameservers").get("search", [])
dns = dev_cfg.get("nameservers").get("addresses", [])
name_cmd = {"type": "nameserver"}
if len(search) > 0:
name_cmd.update({"search": search})
name_cmd["search"] = search
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could similarly exploit the falsyness of search and dns (no need to check that len() > 0) and also remove the default values in .get("search", []) and .get("addresses", []), if you want.

@TheRealFalcon TheRealFalcon merged commit a8f6940 into canonical:main Oct 11, 2024
21 checks passed
@TheRealFalcon TheRealFalcon deleted the fix-sysconfig-bridges branch October 11, 2024 04:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants