Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions pkg/neg/syncers/transaction.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
9 changes: 9 additions & 0 deletions pkg/neg/syncers/transaction_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2728,6 +2728,7 @@ func TestIsZoneChange(t *testing.T) {
zoneDeleted bool
zoneAdded bool
nodeWithNoProviderIDAdded bool
negCRStateInactive bool
nodeWithInvalidProviderIDAdded bool
expectedResult bool
}{
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we make all of the NEGs inactive instead of just 1?

This makes the what the flag does consistent. Otherwise, it is a little non-obvious that we are only affecting the first one to be inactive.

Or I would change negCRStateInactive to be instead be a list of zones where inactive negs exist. And we can make the refs considering that.

}
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)
Expand Down