Skip to content

Deleting FIP sets EIP to ready #5141

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

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions pkg/controller/ovn_eip.go
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ func (c *Controller) handleResetOvnEip(key string) error {
return nil
}
klog.Infof("handle reset ovn eip %s", cachedEip.Name)
if err := c.patchOvnEipStatus(key, true); err != nil {
if err := c.patchOvnEipStatus(key, false); err != nil {

Choose a reason for hiding this comment

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

medium

Should there be a comment here explaining why we are setting the status to false? It's not immediately obvious why this is the correct behavior during a reset. Consider adding a comment to clarify the intent, especially since the previous value was true.

Style Guide References

Suggested change
if err := c.patchOvnEipStatus(key, false); err != nil {
// Set the EIP status to 'not ready' during reset to ensure proper cleanup and reconfiguration.
if err := c.patchOvnEipStatus(key, false); err != nil {

klog.Errorf("failed to reset nat for eip %s, %v", key, err)
return err
}
Expand Down Expand Up @@ -364,17 +364,19 @@ func (c *Controller) createOrUpdateOvnEipCR(key, subnet, v4ip, v6ip, mac, usageT
return nil
}

func (c *Controller) patchOvnEipStatus(key string, ready bool) error {
func (c *Controller) patchOvnEipStatus(key string, markEIPAsReady bool) error {
cachedOvnEip, err := c.ovnEipsLister.Get(key)
if err != nil {
klog.Errorf("failed to get cached ovn eip '%s', %v", key, err)
return err
}
ovnEip := cachedOvnEip.DeepCopy()
changed := false
if ovnEip.Status.Ready != ready {
ovnEip.Status.Ready = ready
changed = true
if markEIPAsReady {
if !ovnEip.Status.Ready {
ovnEip.Status.Ready = true
changed = true
}
}
if ovnEip.Status.MacAddress == "" {
// not support change ip
Expand Down
Loading