@@ -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