Skip to content

Commit 8407e83

Browse files
andrewlee1089Andrew Lee
andauthored
Add Finalizer to FIP before programming FIP into the VPC NT Gateway (#5142)
Signed-off-by: Andrew Lee <alee@evroc.com> Co-authored-by: Andrew Lee <alee@evroc.com>
1 parent 6b60170 commit 8407e83

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

pkg/controller/vpc_nat_gw_nat.go

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,16 @@ func (c *Controller) handleAddIptablesFip(key string) error {
170170
return err
171171
}
172172

173+
// we add the finalizer **before** we run "createFipInPod". This is because if we
174+
// added the finalizer after, then it is possible that the FIP is deleted after
175+
// we run createFipInPod but before the finalizer is created, and
176+
// then we can be left with IPtables rules in the VPC Nat
177+
// Gateway pod which are unmanaged.
178+
if err = c.handleAddIptablesFipFinalizer(key); err != nil {
179+
klog.Errorf("failed to handle add finalizer for fip, %v", err)
180+
return err
181+
}
182+
173183
// create fip nat
174184
if err = c.createFipInPod(eip.Spec.NatGwDp, eip.Status.IP, fip.Spec.InternalIP); err != nil {
175185
klog.Errorf("failed to create fip, %v", err)
@@ -184,10 +194,6 @@ func (c *Controller) handleAddIptablesFip(key string) error {
184194
klog.Errorf("failed to update label for fip %s, %v", key, err)
185195
return err
186196
}
187-
if err = c.handleAddIptablesFipFinalizer(key); err != nil {
188-
klog.Errorf("failed to handle add finalizer for fip, %v", err)
189-
return err
190-
}
191197
if err = c.patchEipStatus(eipName, "", "", "", true); err != nil {
192198
// refresh eip nats
193199
klog.Errorf("failed to patch fip use eip %s, %v", key, err)

0 commit comments

Comments
 (0)