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

Show gateway leases when features.networks is disabled (for default project networks) #14305

Draft
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

hamistao
Copy link
Contributor

If project foo has features.networks disabled on a project, it does not have networks of its own and the networks from the default project are visible from that project. However, the gateway leases for networks on the default project don't show on lxc network list-leases lxdbr0 --project foo.
This PR proposes changing this behavior and showing those leases, being more consistent with how we handle features.networks.

@github-actions github-actions bot added Documentation Documentation needs updating API Changes to the REST API labels Oct 20, 2024
@github-actions github-actions bot removed Documentation Documentation needs updating API Changes to the REST API labels Oct 20, 2024

// Only query for project when we need to check for "features.networks". That is, when the network project is
// the default project and projectName refers to any one other project.
if projectName != api.ProjectDefaultName && projectName != "" && n.project == api.ProjectDefaultName {
Copy link
Member

@tomponline tomponline Oct 21, 2024

Choose a reason for hiding this comment

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

Can we move this logic into NetworkProject() to avoid the duplication? Would that be correct?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't think this would be correct since we have to consider the networks from project default and the instances from the requested project (e.g. projectName)

Copy link
Member

@tomponline tomponline Oct 22, 2024

Choose a reason for hiding this comment

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

Lets move this to an exported function in network.Common


// Include gateway IPs when the network belongs to requested project, getting leases for all projects or
// requested project doesn't have features.networks and network is in default project.
if projectName == n.project || projectName == "" ||
Copy link
Member

Choose a reason for hiding this comment

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

please dont put if statements on multiple lines.
If its too long please break it up into multiple variables to make the if statement clearer.

We do want gateway Leases to show when listing them for a project if the network is visible from that project. However, when dealing with DNS zone configuration, we only want to consider these leases when dealing with the network's original project.

Signed-off-by: hamistao <[email protected]>
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.

2 participants