Skip to content

Commit 259298b

Browse files
committed
filter out inactive negs in isZoneChange
1 parent b7a97eb commit 259298b

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

pkg/neg/syncers/transaction.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -843,6 +843,11 @@ func (s *transactionSyncer) isZoneChange() bool {
843843

844844
existingZones := sets.NewString()
845845
for _, ref := range negCR.Status.NetworkEndpointGroups {
846+
// For backward compatibility, an empty state is considered active.
847+
if ref.State != "" && ref.State != negv1beta1.ActiveState {
848+
continue
849+
}
850+
846851
id, err := cloud.ParseResourceURL(ref.SelfLink)
847852
if err != nil {
848853
s.logger.Error(err, "unable to parse selflink", "selfLink", ref.SelfLink)

pkg/neg/syncers/transaction_test.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2728,6 +2728,7 @@ func TestIsZoneChange(t *testing.T) {
27282728
zoneDeleted bool
27292729
zoneAdded bool
27302730
nodeWithNoProviderIDAdded bool
2731+
negCRStateInactive bool
27312732
nodeWithInvalidProviderIDAdded bool
27322733
expectedResult bool
27332734
}{
@@ -2761,6 +2762,11 @@ func TestIsZoneChange(t *testing.T) {
27612762
desc: "no zone change occurred",
27622763
expectedResult: false,
27632764
},
2765+
{
2766+
desc: "neg cr state is inactive",
2767+
negCRStateInactive: true,
2768+
expectedResult: true,
2769+
},
27642770
}
27652771

27662772
for _, tc := range testCases {
@@ -2793,6 +2799,9 @@ func TestIsZoneChange(t *testing.T) {
27932799
for _, neg := range negRefMap {
27942800
refs = append(refs, neg)
27952801
}
2802+
if tc.negCRStateInactive {
2803+
refs[0].State = negv1beta1.InactiveState
2804+
}
27962805
negCR := createNegCR(syncer.NegName, metav1.Now(), true, true, refs)
27972806
if err = syncer.svcNegLister.Add(negCR); err != nil {
27982807
t.Errorf("failed to add neg to store:%s", err)

0 commit comments

Comments
 (0)