Skip validation checks if an ingress is marked as deleted (#7216)

Signed-off-by: Aditya Sharma <git@adi.run>
This commit is contained in:
Aditya Sharma 2021-06-08 09:27:34 -07:00 committed by GitHub
parent 16402050dc
commit 475bcde64c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 15 additions and 0 deletions

View file

@ -214,6 +214,11 @@ func (n *NGINXController) CheckIngress(ing *networking.Ingress) error {
return nil
}
// Skip checks if the ingress is marked as deleted
if !ing.DeletionTimestamp.IsZero() {
return nil
}
if !class.IsValid(ing) {
klog.Warningf("ignoring ingress %v in %v based on annotation %v", ing.Name, ing.ObjectMeta.Namespace, class.IngressKey)
return nil

View file

@ -294,6 +294,16 @@ func TestCheckIngress(t *testing.T) {
}
})
})
t.Run("When the ingress is marked as deleted", func(t *testing.T) {
ing.DeletionTimestamp = &metav1.Time{
Time: time.Now(),
}
if nginx.CheckIngress(ing) != nil {
t.Errorf("when the ingress is marked as deleted, no error should be returned")
}
})
}
func TestMergeAlternativeBackends(t *testing.T) {