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

Remove SGs from non-existent nodes ports on Update #2695

Open
EmilienM opened this issue Oct 21, 2024 · 1 comment
Open

Remove SGs from non-existent nodes ports on Update #2695

EmilienM opened this issue Oct 21, 2024 · 1 comment

Comments

@EmilienM
Copy link
Contributor

Current code assumes that if a Node has been removed from the list on UpdateLoadBalancer(), we don't care about it's security group.
We could update applyNodeSecurityGroupIDForLB() to also lookup ports that have the SG tag and detach the SG from the ports that aren't belonging to the ports of the current list of Nodes.

for _, port := range allPorts {
// You can't assign an SG to a port with port_security_enabled=false, skip them.
if !port.PortSecurityEnabled {
continue
}
// If the Security Group is already present on the port, skip it.
if slices.Contains(port.SecurityGroups, sg) {
continue
}
// Only add SGs to the port actually attached to the LB
if !isPortMember(port, addr, svcConf.lbMemberSubnetID) {
continue
}
// Add the SG to the port
// TODO(dulek): This isn't an atomic operation. In order to protect from lost update issues we should use
// `revision_number` handling to make sure our update to `security_groups` field wasn't preceded
// by a different one. Same applies to a removal of the SG.
newSGs := append(port.SecurityGroups, sg)
updateOpts := neutronports.UpdateOpts{SecurityGroups: &newSGs}
mc := metrics.NewMetricContext("port", "update")
res := neutronports.Update(context.TODO(), network, port.ID, updateOpts)
if mc.ObserveRequest(res.Err) != nil {
return fmt.Errorf("failed to update security group for port %s: %v", port.ID, res.Err)
}
}

@EmilienM
Copy link
Contributor Author

/cc dulek mdbooth

@dulek hey there, you filed a bug some time ago about this issue and I'm taking over it. If time permits, let me know what you think about the proposed fix.

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 a pull request may close this issue.

1 participant