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

digitalocean: do not Refresh() on startup #4144

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 @@ -27,7 +27,7 @@ import (
"k8s.io/autoscaler/cluster-autoscaler/cloudprovider"
"k8s.io/autoscaler/cluster-autoscaler/config"
"k8s.io/autoscaler/cluster-autoscaler/utils/errors"
klog "k8s.io/klog/v2"
"k8s.io/klog/v2"
)

var _ cloudprovider.CloudProvider = (*digitaloceanCloudProvider)(nil)
Expand All @@ -45,15 +45,11 @@ type digitaloceanCloudProvider struct {
resourceLimiter *cloudprovider.ResourceLimiter
}

func newDigitalOceanCloudProvider(manager *Manager, rl *cloudprovider.ResourceLimiter) (*digitaloceanCloudProvider, error) {
if err := manager.Refresh(); err != nil {
return nil, err
}

func newDigitalOceanCloudProvider(manager *Manager, rl *cloudprovider.ResourceLimiter) *digitaloceanCloudProvider {
return &digitaloceanCloudProvider{
manager: manager,
resourceLimiter: rl,
}, nil
}
}

// Name returns name of the cloud provider.
Expand Down Expand Up @@ -185,12 +181,7 @@ func BuildDigitalOcean(
// the cloud provider automatically uses all node pools in DigitalOcean.
// This means we don't use the cloudprovider.NodeGroupDiscoveryOptions
// flags (which can be set via '--node-group-auto-discovery' or '-nodes')
provider, err := newDigitalOceanCloudProvider(manager, rl)
if err != nil {
klog.Fatalf("Failed to create DigitalOcean cloud provider: %v", err)
}

return provider
return newDigitalOceanCloudProvider(manager, rl)
}

// toProviderID returns a provider ID from the given node ID.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,10 +83,7 @@ func testCloudProvider(t *testing.T, client *doClientMock) *digitaloceanCloudPro

manager.client = client

provider, err := newDigitalOceanCloudProvider(manager, rl)
assert.NoError(t, err)
return provider

return newDigitalOceanCloudProvider(manager, rl)
}

func TestNewDigitalOceanCloudProvider(t *testing.T) {
Expand All @@ -106,6 +103,8 @@ func TestDigitalOceanCloudProvider_Name(t *testing.T) {

func TestDigitalOceanCloudProvider_NodeGroups(t *testing.T) {
provider := testCloudProvider(t, nil)
err := provider.manager.Refresh()
assert.NoError(t, err)

t.Run("success", func(t *testing.T) {
nodes := provider.NodeGroups()
Expand Down Expand Up @@ -150,6 +149,8 @@ func TestDigitalOceanCloudProvider_NodeGroupForNode(t *testing.T) {
).Once()

provider := testCloudProvider(t, client)
err := provider.manager.Refresh()
assert.NoError(t, err)

// let's get the nodeGroup for the node with ID 4
node := &apiv1.Node{
Expand Down Expand Up @@ -190,6 +191,8 @@ func TestDigitalOceanCloudProvider_NodeGroupForNode(t *testing.T) {
).Once()

provider := testCloudProvider(t, client)
err := provider.manager.Refresh()
assert.NoError(t, err)

node := &apiv1.Node{
Spec: apiv1.NodeSpec{
Expand Down