Skip to content

Commit

Permalink
Record event when EgressIP remains unassigned
Browse files Browse the repository at this point in the history
Modified the code to record an event for case, when an egressIP is
unassigned from a node and is not assigned to any other node.

Signed-off-by: Pulkit Jain <[email protected]>
  • Loading branch information
Pulkit Jain committed Mar 5, 2024
1 parent f85fe55 commit cf475e7
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions pkg/agent/controller/egress/egress_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -1002,7 +1002,7 @@ func (c *EgressController) syncEgress(egressName string) error {
if !exist {
return nil
}
if err := c.uninstallEgress(egressName, eState); err != nil {
if err := c.uninstallEgress(egressName, eState, egress); err != nil {
return err
}
return nil
Expand Down Expand Up @@ -1030,7 +1030,7 @@ func (c *EgressController) syncEgress(egressName string) error {
eState, exist := c.getEgressState(egressName)
// If the EgressIP changes, uninstalls this Egress first.
if exist && eState.egressIP != desiredEgressIP {
if err := c.uninstallEgress(egressName, eState); err != nil {
if err := c.uninstallEgress(egressName, eState, egress); err != nil {
return err
}
exist = false
Expand Down Expand Up @@ -1153,7 +1153,7 @@ func (c *EgressController) syncEgress(egressName string) error {
return nil
}

func (c *EgressController) uninstallEgress(egressName string, eState *egressState) error {
func (c *EgressController) uninstallEgress(egressName string, eState *egressState, egress *crdv1b1.Egress) error {
// Uninstall all of its Pod flows.
if err := c.uninstallPodFlows(egressName, eState, eState.ofPorts, eState.pods); err != nil {
return err
Expand All @@ -1169,9 +1169,13 @@ func (c *EgressController) uninstallEgress(egressName string, eState *egressStat
}
}
// Unassign the Egress IP from the local Node if it was assigned by the agent.
if _, err := c.ipAssigner.UnassignIP(eState.egressIP); err != nil {
unassigned, err := c.ipAssigner.UnassignIP(eState.egressIP)
if err != nil {
return err
}
if unassigned && egress != nil {
c.record.Eventf(egress, corev1.EventTypeNormal, "IPUnassigned", "Unassigned Egress %s with IP %s from Node %s", egressName, eState.egressIP, c.nodeName)
}
// Remove the Egress's state.
c.deleteEgressState(egressName)
return nil
Expand Down

0 comments on commit cf475e7

Please sign in to comment.