diff --git a/pkg/neg/syncers/transaction.go b/pkg/neg/syncers/transaction.go index f144874f00..0682b06ae8 100644 --- a/pkg/neg/syncers/transaction.go +++ b/pkg/neg/syncers/transaction.go @@ -843,6 +843,11 @@ func (s *transactionSyncer) isZoneChange() bool { existingZones := sets.NewString() for _, ref := range negCR.Status.NetworkEndpointGroups { + // For backward compatibility, an empty state is considered active. + if ref.State != "" && ref.State != negv1beta1.ActiveState { + continue + } + id, err := cloud.ParseResourceURL(ref.SelfLink) if err != nil { s.logger.Error(err, "unable to parse selflink", "selfLink", ref.SelfLink) diff --git a/pkg/neg/syncers/transaction_test.go b/pkg/neg/syncers/transaction_test.go index 9cd605eb35..3aa3f64f55 100644 --- a/pkg/neg/syncers/transaction_test.go +++ b/pkg/neg/syncers/transaction_test.go @@ -2728,6 +2728,7 @@ func TestIsZoneChange(t *testing.T) { zoneDeleted bool zoneAdded bool nodeWithNoProviderIDAdded bool + negCRStateInactive bool nodeWithInvalidProviderIDAdded bool expectedResult bool }{ @@ -2761,6 +2762,11 @@ func TestIsZoneChange(t *testing.T) { desc: "no zone change occurred", expectedResult: false, }, + { + desc: "neg cr state is inactive", + negCRStateInactive: true, + expectedResult: true, + }, } for _, tc := range testCases { @@ -2793,6 +2799,9 @@ func TestIsZoneChange(t *testing.T) { for _, neg := range negRefMap { refs = append(refs, neg) } + if tc.negCRStateInactive { + refs[0].State = negv1beta1.InactiveState + } negCR := createNegCR(syncer.NegName, metav1.Now(), true, true, refs) if err = syncer.svcNegLister.Add(negCR); err != nil { t.Errorf("failed to add neg to store:%s", err)