Skip to content

Commit 39e5a94

Browse files
committed
Address review comments
1 parent dd870dc commit 39e5a94

File tree

7 files changed

+16
-16
lines changed

7 files changed

+16
-16
lines changed

cmd/machine-controller-manager/app/controllermanager.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -313,7 +313,7 @@ func getAvailableResources(clientBuilder corecontroller.ClientBuilder) (map[sche
313313
var healthzContent string
314314
// If apiserver is not running we should wait for some time and fail only then. This is particularly
315315
// important when we start apiserver and controller manager at the same time.
316-
err := wait.PollImmediate(time.Second, 10*time.Second, func() (bool, error) {
316+
err := wait.PollUntilContextTimeout(context.Background(), 1*time.Second, 10*time.Second, true, func(ctx context.Context) (bool, error) {
317317
client, err := clientBuilder.Client("controller-discovery")
318318
if err != nil {
319319
klog.Errorf("Failed to get api versions from server: %v", err)

pkg/controller/controller.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ func NewController(
7070
),
7171
machineSetQueue: workqueue.NewTypedRateLimitingQueueWithConfig(
7272
workqueue.DefaultTypedControllerRateLimiter[string](),
73-
workqueue.TypedRateLimitingQueueConfig[string]{Name: "machinetermination"},
73+
workqueue.TypedRateLimitingQueueConfig[string]{Name: "machineset"},
7474
),
7575
machineDeploymentQueue: workqueue.NewTypedRateLimitingQueueWithConfig(
7676
workqueue.DefaultTypedControllerRateLimiter[string](),

pkg/controller/controller_suite_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -455,7 +455,7 @@ func createController(
455455
),
456456
machineSetQueue: workqueue.NewTypedRateLimitingQueueWithConfig(
457457
workqueue.DefaultTypedControllerRateLimiter[string](),
458-
workqueue.TypedRateLimitingQueueConfig[string]{Name: "machinetermination"},
458+
workqueue.TypedRateLimitingQueueConfig[string]{Name: "machineset"},
459459
),
460460
machineDeploymentQueue: workqueue.NewTypedRateLimitingQueueWithConfig(
461461
workqueue.DefaultTypedControllerRateLimiter[string](),

pkg/controller/deployment_sync.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ func (dc *controller) addHashKeyToISAndMachines(ctx context.Context, is *v1alpha
184184
if updatedIS.Generation > updatedIS.Status.ObservedGeneration {
185185
// TODO: Revisit if we really need to wait here as opposed to returning and
186186
// potentially unblocking this worker (can wait up to 1min before timing out).
187-
if err = WaitForMachineSetUpdated(dc.machineSetLister, updatedIS.Generation, updatedIS.Namespace, updatedIS.Name); err != nil {
187+
if err = WaitForMachineSetUpdated(ctx, dc.machineSetLister, updatedIS.Generation, updatedIS.Namespace, updatedIS.Name); err != nil {
188188
return nil, fmt.Errorf("error waiting for machine set %s to be observed by controller: %v", updatedIS.Name, err)
189189
}
190190
klog.V(4).Infof("Observed the update of machine set %s's machine template with hash %s.", is.Name, hash)
@@ -202,7 +202,7 @@ func (dc *controller) addHashKeyToISAndMachines(ctx context.Context, is *v1alpha
202202
// back to the number of replicas in the spec.
203203
// TODO: Revisit if we really need to wait here as opposed to returning and
204204
// potentially unblocking this worker (can wait up to 1min before timing out).
205-
if err := WaitForMachinesHashPopulated(dc.machineSetLister, updatedIS.Generation, updatedIS.Namespace, updatedIS.Name); err != nil {
205+
if err := WaitForMachinesHashPopulated(ctx, dc.machineSetLister, updatedIS.Generation, updatedIS.Namespace, updatedIS.Name); err != nil {
206206
return nil, fmt.Errorf("Machine set %s: error waiting for machineset controller to observe machines being labeled with template hash: %v", updatedIS.Name, err)
207207
}
208208

pkg/controller/deployment_util.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -937,8 +937,8 @@ func FindOldMachineSets(deployment *v1alpha1.MachineDeployment, isList []*v1alph
937937
}
938938

939939
// WaitForMachineSetUpdated polls the machine set until it is updated.
940-
func WaitForMachineSetUpdated(c v1alpha1listers.MachineSetLister, desiredGeneration int64, namespace, name string) error {
941-
return wait.PollImmediate(1*time.Second, 1*time.Minute, func() (bool, error) {
940+
func WaitForMachineSetUpdated(ctx context.Context, c v1alpha1listers.MachineSetLister, desiredGeneration int64, namespace, name string) error {
941+
return wait.PollUntilContextTimeout(ctx, 1*time.Second, 1*time.Minute, true, func(ctx context.Context) (bool, error) {
942942
is, err := c.MachineSets(namespace).Get(name)
943943
if err != nil {
944944
return false, err
@@ -948,8 +948,8 @@ func WaitForMachineSetUpdated(c v1alpha1listers.MachineSetLister, desiredGenerat
948948
}
949949

950950
// WaitForMachinesHashPopulated polls the machine set until updated and fully labeled.
951-
func WaitForMachinesHashPopulated(c v1alpha1listers.MachineSetLister, desiredGeneration int64, namespace, name string) error {
952-
return wait.PollImmediate(1*time.Second, 1*time.Minute, func() (bool, error) {
951+
func WaitForMachinesHashPopulated(ctx context.Context, c v1alpha1listers.MachineSetLister, desiredGeneration int64, namespace, name string) error {
952+
return wait.PollUntilContextTimeout(ctx, 1*time.Second, 1*time.Minute, true, func(ctx context.Context) (bool, error) {
953953
is, err := c.MachineSets(namespace).Get(name)
954954
if err != nil {
955955
return false, err
@@ -1206,7 +1206,7 @@ func IsSaturated(deployment *v1alpha1.MachineDeployment, is *v1alpha1.MachineSet
12061206
// Returns error if polling timesout.
12071207
func WaitForObservedMachineDeployment(getDeploymentFunc func() (*v1alpha1.MachineDeployment, error), desiredGeneration int64, interval, timeout time.Duration) error {
12081208
// TODO: This should take clientset.Interface when all code is updated to use clientset. Keeping it this way allows the function to be used by callers who have client.Interface.
1209-
return wait.PollImmediate(interval, timeout, func() (bool, error) {
1209+
return wait.PollUntilContextTimeout(context.Background(), interval, timeout, true, func(ctx context.Context) (bool, error) {
12101210
deployment, err := getDeploymentFunc()
12111211
if err != nil {
12121212
return false, err
@@ -1219,7 +1219,7 @@ func WaitForObservedMachineDeployment(getDeploymentFunc func() (*v1alpha1.Machin
12191219
// Returns error if polling timesout.
12201220
// TODO: remove the duplicate
12211221
func WaitForObservedDeploymentInternal(getDeploymentFunc func() (*v1alpha1.MachineDeployment, error), desiredGeneration int64, interval, timeout time.Duration) error {
1222-
return wait.Poll(interval, timeout, func() (bool, error) {
1222+
return wait.PollUntilContextTimeout(context.Background(), interval, timeout, false, func(ctx context.Context) (bool, error) {
12231223
deployment, err := getDeploymentFunc()
12241224
if err != nil {
12251225
return false, err

pkg/test/integration/common/helpers/handling_files.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ func (c *Cluster) applyFile(filePath string, namespace string) error {
172172

173173
// checkEstablished uses the specified name to check if it is established
174174
func (c *Cluster) checkEstablished(crdName string) error {
175-
err := wait.Poll(500*time.Millisecond, 60*time.Second, func() (bool, error) {
175+
err := wait.PollUntilContextTimeout(context.Background(), 500*time.Millisecond, 60*time.Second, false, func(ctx context.Context) (bool, error) {
176176
crd, err := c.apiextensionsClient.
177177
ApiextensionsV1().
178178
CustomResourceDefinitions().

pkg/util/configz/configz_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ Modifications Copyright SAP SE or an SAP affiliate company and Gardener contribu
2222
package configz
2323

2424
import (
25-
"io/ioutil"
25+
"io"
2626
"net/http"
2727
"net/http/httptest"
2828
"testing"
@@ -44,7 +44,7 @@ func TestConfigz(t *testing.T) {
4444
t.Fatalf("err: %v", err)
4545
}
4646

47-
body, err := ioutil.ReadAll(resp.Body)
47+
body, err := io.ReadAll(resp.Body)
4848
if err != nil {
4949
t.Fatalf("err: %v", err)
5050
}
@@ -58,7 +58,7 @@ func TestConfigz(t *testing.T) {
5858
t.Fatalf("err: %v", err)
5959
}
6060

61-
body, err = ioutil.ReadAll(resp.Body)
61+
body, err = io.ReadAll(resp.Body)
6262
if err != nil {
6363
t.Fatalf("err: %v", err)
6464
}
@@ -72,7 +72,7 @@ func TestConfigz(t *testing.T) {
7272
t.Fatalf("err: %v", err)
7373
}
7474

75-
body, err = ioutil.ReadAll(resp.Body)
75+
body, err = io.ReadAll(resp.Body)
7676
if err != nil {
7777
t.Fatalf("err: %v", err)
7878
}

0 commit comments

Comments
 (0)