Skip to content

Commit

Permalink
Merge pull request #3972 from marwanad/fix-autodiscovery-add-missing-…
Browse files Browse the repository at this point in the history
…call

fix: add missing call to fetch autodiscovered nodegroups
  • Loading branch information
k8s-ci-robot authored Mar 29, 2021
2 parents 7f6f6e1 + 8d365c2 commit 02e6fb5
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ func TestNodeGroupForNode(t *testing.T) {

registered := provider.azureManager.RegisterNodeGroup(
newTestScaleSet(provider.azureManager, "test-asg"))
provider.azureManager.explicitlyConfigured["test-asg"] = true
assert.True(t, registered)
assert.Equal(t, len(provider.NodeGroups()), 1)

Expand Down
3 changes: 3 additions & 0 deletions cluster-autoscaler/cloudprovider/azure/azure_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,9 @@ func (m *AzureManager) Refresh() error {
}

func (m *AzureManager) forceRefresh() error {
if err := m.fetchAutoNodeGroups(); err != nil {
klog.Errorf("Failed to fetch autodiscovered nodegroups: %v", err)
}
if err := m.azureCache.regenerate(); err != nil {
klog.Errorf("Failed to regenerate Azure cache: %v", err)
return err
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,7 @@ func TestIncreaseSizeOnVMSSUpdating(t *testing.T) {
mockVMSSVMClient := mockvmssvmclient.NewMockInterface(ctrl)
mockVMSSVMClient.EXPECT().List(gomock.Any(), manager.config.ResourceGroup, "vmss-updating", gomock.Any()).Return(expectedVMSSVMs, nil).AnyTimes()
manager.azClient.virtualMachineScaleSetVMsClient = mockVMSSVMClient
manager.explicitlyConfigured["vmss-updating"] = true
registered := manager.RegisterNodeGroup(newTestScaleSet(manager, vmssName))
assert.True(t, registered)
manager.Refresh()
Expand Down Expand Up @@ -229,6 +230,7 @@ func TestBelongs(t *testing.T) {

scaleSet, ok := provider.NodeGroups()[0].(*ScaleSet)
assert.True(t, ok)
provider.azureManager.explicitlyConfigured["test-asg"] = true
provider.azureManager.Refresh()

invalidNode := &apiv1.Node{
Expand Down Expand Up @@ -286,6 +288,7 @@ func TestDeleteNodes(t *testing.T) {

registered := manager.RegisterNodeGroup(
newTestScaleSet(manager, "test-asg"))
manager.explicitlyConfigured["test-asg"] = true
assert.True(t, registered)
err = manager.forceRefresh()
assert.NoError(t, err)
Expand Down Expand Up @@ -385,6 +388,7 @@ func TestDeleteNoConflictRequest(t *testing.T) {
assert.NoError(t, err)

registered := manager.RegisterNodeGroup(newTestScaleSet(manager, "test-asg"))
manager.explicitlyConfigured["test-asg"] = true
assert.True(t, registered)
manager.Refresh()

Expand Down Expand Up @@ -436,6 +440,7 @@ func TestScaleSetNodes(t *testing.T) {

registered := provider.azureManager.RegisterNodeGroup(
newTestScaleSet(provider.azureManager, "test-asg"))
provider.azureManager.explicitlyConfigured["test-asg"] = true
provider.azureManager.Refresh()
assert.True(t, registered)
assert.Equal(t, len(provider.NodeGroups()), 1)
Expand Down

0 comments on commit 02e6fb5

Please sign in to comment.