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 · 2 comments
Open

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

EmilienM opened this issue Oct 21, 2024 · 2 comments
Labels
lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale.

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.

@k8s-triage-robot
Copy link

The Kubernetes project currently lacks enough contributors to adequately respond to all issues.

This bot triages un-triaged issues according to the following rules:

  • After 90d of inactivity, lifecycle/stale is applied
  • After 30d of inactivity since lifecycle/stale was applied, lifecycle/rotten is applied
  • After 30d of inactivity since lifecycle/rotten was applied, the issue is closed

You can:

  • Mark this issue as fresh with /remove-lifecycle stale
  • Close this issue with /close
  • Offer to help out with Issue Triage

Please send feedback to sig-contributor-experience at kubernetes/community.

/lifecycle stale

@k8s-ci-robot k8s-ci-robot added the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Jan 19, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants