Skip to content

Commit

Permalink
Merge pull request #4144 from timoreimann/digitalocean/do-not-refresh…
Browse files Browse the repository at this point in the history
…-on-startup

digitalocean: do not Refresh() on startup
  • Loading branch information
k8s-ci-robot authored Jun 16, 2021
2 parents 84f7628 + 7faca8b commit cdf62a1
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 17 deletions.
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

0 comments on commit cdf62a1

Please sign in to comment.