Skip to content

Commit

Permalink
Merge pull request #2812 from swetharepakula/update-cr-after-gc
Browse files Browse the repository at this point in the history
Enable CR updates after NEG GC always
  • Loading branch information
k8s-ci-robot authored Feb 27, 2025
2 parents f683eee + 53235ac commit 7262fed
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
13 changes: 5 additions & 8 deletions pkg/neg/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ import (
"k8s.io/client-go/tools/cache"
"k8s.io/client-go/tools/record"
negv1beta1 "k8s.io/ingress-gce/pkg/apis/svcneg/v1beta1"
"k8s.io/ingress-gce/pkg/flags"
"k8s.io/ingress-gce/pkg/neg/metrics"
"k8s.io/ingress-gce/pkg/neg/metrics/metricscollector"
"k8s.io/ingress-gce/pkg/neg/readiness"
Expand Down Expand Up @@ -658,10 +657,11 @@ func (manager *syncerManager) processNEGDeletionCandidate(svcNegCR *negv1beta1.S
shouldDeleteNegCR = shouldDeleteNegCR && negDeleted
}
}
// Since no more NEG deletion will be happening at this point, and NEG
// CR will not be deleted, clear the reference for deleted NEGs in the
// NEG CR.
if flags.F.EnableMultiSubnetClusterPhase1 {

if !shouldDeleteNegCR {
// Since no more NEG deletion will be happening at this point, and NEG
// CR will not be deleted, clear the reference for deleted NEGs in the
// NEG CR.
if len(deletedNegs) != 0 {
updatedCR := svcNegCR.DeepCopy()

Expand All @@ -672,9 +672,6 @@ func (manager *syncerManager) processNEGDeletionCandidate(svcNegCR *negv1beta1.S
errList = append(errList, err)
}
}
}

if !shouldDeleteNegCR {
return errList
}

Expand Down
6 changes: 6 additions & 0 deletions pkg/neg/manager_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1520,6 +1520,12 @@ func TestGarbageCollectionNegCrdEnabled(t *testing.T) {
if !tc.expectCrGC && crDeleted && !tc.markedForDeletion {
t.Errorf("expected neg %s to not be deleted", negName)
}

if !tc.expectCrGC && !crDeleted && tc.negCrGCError == nil {
if len(crs[0].Status.NetworkEndpointGroups) != tc.expectedNegCount {
t.Errorf("SvcNeg CR contains %d Negs, expected %d", len(crs[0].Status.NetworkEndpointGroups), tc.expectedNegCount)
}
}
}
}
})
Expand Down

0 comments on commit 7262fed

Please sign in to comment.