Skip to content

Commit 7f27003

Browse files
committed
Remove unused function aggregateGoroutinesWithDelay
1 parent 0f4cfe5 commit 7f27003

File tree

6 files changed

+5
-97
lines changed

6 files changed

+5
-97
lines changed

staging/src/k8s.io/legacy-cloud-providers/azure/azure_utils.go

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,6 @@ package azure
2121
import (
2222
"context"
2323
"sync"
24-
"time"
25-
26-
utilerrors "k8s.io/apimachinery/pkg/util/errors"
2724
)
2825

2926
// lockMap used to lock on entries
@@ -77,21 +74,3 @@ func (lm *lockMap) unlockEntry(entry string) {
7774
func getContextWithCancel() (context.Context, context.CancelFunc) {
7875
return context.WithCancel(context.Background())
7976
}
80-
81-
// aggregateGoroutinesWithDelay aggregates goroutines and runs them
82-
// in parallel with delay before starting each goroutine
83-
func aggregateGoroutinesWithDelay(delay time.Duration, funcs ...func() error) utilerrors.Aggregate {
84-
errChan := make(chan error, len(funcs))
85-
86-
for _, f := range funcs {
87-
go func(f func() error) { errChan <- f() }(f)
88-
time.Sleep(delay)
89-
}
90-
errs := make([]error, 0)
91-
for i := 0; i < cap(errChan); i++ {
92-
if err := <-errChan; err != nil {
93-
errs = append(errs, err)
94-
}
95-
}
96-
return utilerrors.NewAggregate(errs)
97-
}

staging/src/k8s.io/legacy-cloud-providers/azure/azure_utils_test.go

Lines changed: 0 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ limitations under the License.
1919
package azure
2020

2121
import (
22-
"fmt"
2322
"testing"
2423
"time"
2524
)
@@ -84,67 +83,3 @@ func ensureNoCallback(t *testing.T, callbackChan <-chan interface{}) bool {
8483
return true
8584
}
8685
}
87-
88-
// running same unit tests as https://github.com/kubernetes/apimachinery/blob/master/pkg/util/errors/errors_test.go#L371
89-
func TestAggregateGoroutinesWithDelay(t *testing.T) {
90-
testCases := []struct {
91-
errs []error
92-
expected map[string]bool
93-
}{
94-
{
95-
[]error{},
96-
nil,
97-
},
98-
{
99-
[]error{nil},
100-
nil,
101-
},
102-
{
103-
[]error{nil, nil},
104-
nil,
105-
},
106-
{
107-
[]error{fmt.Errorf("1")},
108-
map[string]bool{"1": true},
109-
},
110-
{
111-
[]error{fmt.Errorf("1"), nil},
112-
map[string]bool{"1": true},
113-
},
114-
{
115-
[]error{fmt.Errorf("1"), fmt.Errorf("267")},
116-
map[string]bool{"1": true, "267": true},
117-
},
118-
{
119-
[]error{fmt.Errorf("1"), nil, fmt.Errorf("1234")},
120-
map[string]bool{"1": true, "1234": true},
121-
},
122-
{
123-
[]error{nil, fmt.Errorf("1"), nil, fmt.Errorf("1234"), fmt.Errorf("22")},
124-
map[string]bool{"1": true, "1234": true, "22": true},
125-
},
126-
}
127-
for i, testCase := range testCases {
128-
funcs := make([]func() error, len(testCase.errs))
129-
for i := range testCase.errs {
130-
err := testCase.errs[i]
131-
funcs[i] = func() error { return err }
132-
}
133-
agg := aggregateGoroutinesWithDelay(100*time.Millisecond, funcs...)
134-
if agg == nil {
135-
if len(testCase.expected) > 0 {
136-
t.Errorf("%d: expected %v, got nil", i, testCase.expected)
137-
}
138-
continue
139-
}
140-
if len(agg.Errors()) != len(testCase.expected) {
141-
t.Errorf("%d: expected %d errors in aggregate, got %v", i, len(testCase.expected), agg)
142-
continue
143-
}
144-
for _, err := range agg.Errors() {
145-
if !testCase.expected[err.Error()] {
146-
t.Errorf("%d: expected %v, got aggregate containing %v", i, testCase.expected, err)
147-
}
148-
}
149-
}
150-
}

staging/src/k8s.io/legacy-cloud-providers/azure/azure_vmss.go

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ import (
2626
"strconv"
2727
"strings"
2828
"sync"
29-
"time"
3029

3130
"github.com/Azure/azure-sdk-for-go/services/compute/mgmt/2019-07-01/compute"
3231
"github.com/Azure/azure-sdk-for-go/services/network/mgmt/2019-06-01/network"
@@ -56,13 +55,6 @@ var (
5655
vmssVMProviderIDRE = regexp.MustCompile(`azure:///subscriptions/(?:.*)/resourceGroups/(.+)/providers/Microsoft.Compute/virtualMachineScaleSets/(.+)/virtualMachines/(?:\d+)`)
5756
)
5857

59-
const (
60-
// vmssVMInstanceUpdateDelay is used when updating multiple vm instances in parallel
61-
// the optimum value is 3s to prevent any conflicts that result in concurrent vmss vm
62-
// instances update
63-
vmssVMInstanceUpdateDelay = 3 * time.Second
64-
)
65-
6658
// vmssMetaInfo contains the metadata for a VMSS.
6759
type vmssMetaInfo struct {
6860
vmssName string

staging/src/k8s.io/legacy-cloud-providers/azure/clients/armclient/mockarmclient/BUILD

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ go_library(
1010
importpath = "k8s.io/legacy-cloud-providers/azure/clients/armclient/mockarmclient",
1111
visibility = ["//visibility:public"],
1212
deps = [
13+
"//staging/src/k8s.io/legacy-cloud-providers/azure/clients/armclient:go_default_library",
1314
"//staging/src/k8s.io/legacy-cloud-providers/azure/retry:go_default_library",
1415
"//vendor/github.com/Azure/go-autorest/autorest:go_default_library",
1516
"//vendor/github.com/Azure/go-autorest/autorest/azure:go_default_library",

staging/src/k8s.io/legacy-cloud-providers/azure/clients/vmssvmclient/BUILD

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ go_library(
1111
importpath = "k8s.io/legacy-cloud-providers/azure/clients/vmssvmclient",
1212
visibility = ["//visibility:public"],
1313
deps = [
14+
"//staging/src/k8s.io/apimachinery/pkg/util/errors:go_default_library",
1415
"//staging/src/k8s.io/client-go/util/flowcontrol:go_default_library",
1516
"//staging/src/k8s.io/legacy-cloud-providers/azure/clients:go_default_library",
1617
"//staging/src/k8s.io/legacy-cloud-providers/azure/clients/armclient:go_default_library",

staging/src/k8s.io/legacy-cloud-providers/azure/mockvmsets/azure_mock_vmsets.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ import (
2626
gomock "github.com/golang/mock/gomock"
2727
v1 "k8s.io/api/core/v1"
2828
types "k8s.io/apimachinery/pkg/types"
29-
cloud_provider "k8s.io/cloud-provider"
29+
cloudprovider "k8s.io/cloud-provider"
3030
cache "k8s.io/legacy-cloud-providers/azure/cache"
3131
)
3232

@@ -130,10 +130,10 @@ func (mr *MockVMSetMockRecorder) GetNodeNameByProviderID(providerID interface{})
130130
}
131131

132132
// GetZoneByNodeName mocks base method
133-
func (m *MockVMSet) GetZoneByNodeName(name string) (cloud_provider.Zone, error) {
133+
func (m *MockVMSet) GetZoneByNodeName(name string) (cloudprovider.Zone, error) {
134134
m.ctrl.T.Helper()
135135
ret := m.ctrl.Call(m, "GetZoneByNodeName", name)
136-
ret0, _ := ret[0].(cloud_provider.Zone)
136+
ret0, _ := ret[0].(cloudprovider.Zone)
137137
ret1, _ := ret[1].(error)
138138
return ret0, ret1
139139
}

0 commit comments

Comments
 (0)