Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: add missing call to fetch autodiscovered nodegroups #3972

Merged
Merged
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
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
Copy link
Member Author

Choose a reason for hiding this comment

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

this is needed because the manager setup logic skips createAzureManagerInternal and thus by the time fetchAutoNodegroups is called explicitlyConfigured will be empty and the nodegroup will be unregistered on L217 in azure_manager.

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