Skip to content

Commit

Permalink
Fix linter warnings (#569)
Browse files Browse the repository at this point in the history
Signed-off-by: Tamal Saha <[email protected]>
  • Loading branch information
tamalsaha authored Dec 16, 2023
1 parent 1995b2c commit 0753a8e
Show file tree
Hide file tree
Showing 48 changed files with 88 additions and 84 deletions.
2 changes: 1 addition & 1 deletion admissionregistration/v1/mutatingwebhookconfiguration.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ func PatchMutatingWebhookConfigurationObject(ctx context.Context, c kubernetes.I

func TryUpdateMutatingWebhookConfiguration(ctx context.Context, c kubernetes.Interface, name string, transform func(*reg.MutatingWebhookConfiguration) *reg.MutatingWebhookConfiguration, opts metav1.UpdateOptions) (result *reg.MutatingWebhookConfiguration, err error) {
attempt := 0
err = wait.PollImmediate(kutil.RetryInterval, kutil.RetryTimeout, func() (bool, error) {
err = wait.PollUntilContextTimeout(ctx, kutil.RetryInterval, kutil.RetryTimeout, true, func(ctx context.Context) (bool, error) {
attempt++
cur, e2 := c.AdmissionregistrationV1().MutatingWebhookConfigurations().Get(ctx, name, metav1.GetOptions{})
if kerr.IsNotFound(e2) {
Expand Down
2 changes: 1 addition & 1 deletion admissionregistration/v1/validatingwebhookconfiguration.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ func PatchValidatingWebhookConfigurationObject(ctx context.Context, c kubernetes

func TryUpdateValidatingWebhookConfiguration(ctx context.Context, c kubernetes.Interface, name string, transform func(*reg.ValidatingWebhookConfiguration) *reg.ValidatingWebhookConfiguration, opts metav1.UpdateOptions) (result *reg.ValidatingWebhookConfiguration, err error) {
attempt := 0
err = wait.PollImmediate(kutil.RetryInterval, kutil.RetryTimeout, func() (bool, error) {
err = wait.PollUntilContextTimeout(ctx, kutil.RetryInterval, kutil.RetryTimeout, true, func(ctx context.Context) (bool, error) {
attempt++
cur, e2 := c.AdmissionregistrationV1().ValidatingWebhookConfigurations().Get(ctx, name, metav1.GetOptions{})
if kerr.IsNotFound(e2) {
Expand Down
4 changes: 2 additions & 2 deletions admissionregistration/v1/xray.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ func (d ValidatingWebhookXray) IsActive(ctx context.Context) error {

attempt := 0
var failures []string
return wait.PollImmediateUntil(kutil.RetryInterval, func() (bool, error) {
return wait.PollUntilContextCancel(wait.ContextForChannel(d.stopCh), kutil.RetryInterval, true, func(ctx context.Context) (bool, error) {
apisvc, err := apireg.ApiregistrationV1().APIServices().Get(ctx, d.apisvc, metav1.GetOptions{})
if err != nil {
return false, retry(err)
Expand Down Expand Up @@ -166,7 +166,7 @@ func (d ValidatingWebhookXray) IsActive(ctx context.Context) error {
}
}
return false, nil
}, d.stopCh)
})
}

func (d ValidatingWebhookXray) updateAPIService(ctx context.Context, apireg apireg_cs.Interface, apisvc *apiregistration.APIService, err error) error {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ func PatchMutatingWebhookConfigurationObject(ctx context.Context, c kubernetes.I

func TryUpdateMutatingWebhookConfiguration(ctx context.Context, c kubernetes.Interface, name string, transform func(*reg.MutatingWebhookConfiguration) *reg.MutatingWebhookConfiguration, opts metav1.UpdateOptions) (result *reg.MutatingWebhookConfiguration, err error) {
attempt := 0
err = wait.PollImmediate(kutil.RetryInterval, kutil.RetryTimeout, func() (bool, error) {
err = wait.PollUntilContextTimeout(ctx, kutil.RetryInterval, kutil.RetryTimeout, true, func(ctx context.Context) (bool, error) {
attempt++
cur, e2 := c.AdmissionregistrationV1beta1().MutatingWebhookConfigurations().Get(ctx, name, metav1.GetOptions{})
if kerr.IsNotFound(e2) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ func PatchValidatingWebhookConfigurationObject(ctx context.Context, c kubernetes

func TryUpdateValidatingWebhookConfiguration(ctx context.Context, c kubernetes.Interface, name string, transform func(*reg.ValidatingWebhookConfiguration) *reg.ValidatingWebhookConfiguration, opts metav1.UpdateOptions) (result *reg.ValidatingWebhookConfiguration, err error) {
attempt := 0
err = wait.PollImmediate(kutil.RetryInterval, kutil.RetryTimeout, func() (bool, error) {
err = wait.PollUntilContextTimeout(ctx, kutil.RetryInterval, kutil.RetryTimeout, true, func(ctx context.Context) (bool, error) {
attempt++
cur, e2 := c.AdmissionregistrationV1beta1().ValidatingWebhookConfigurations().Get(ctx, name, metav1.GetOptions{})
if kerr.IsNotFound(e2) {
Expand Down
4 changes: 2 additions & 2 deletions admissionregistration/v1beta1/xray.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ func (d ValidatingWebhookXray) IsActive(ctx context.Context) error {

attempt := 0
var failures []string
return wait.PollImmediateUntil(kutil.RetryInterval, func() (bool, error) {
return wait.PollUntilContextCancel(wait.ContextForChannel(d.stopCh), kutil.RetryInterval, true, func(ctx context.Context) (bool, error) {
apisvc, err := apireg.ApiregistrationV1beta1().APIServices().Get(ctx, d.apisvc, metav1.GetOptions{})
if err != nil {
return false, retry(err)
Expand Down Expand Up @@ -166,7 +166,7 @@ func (d ValidatingWebhookXray) IsActive(ctx context.Context) error {
}
}
return false, nil
}, d.stopCh)
})
}

func (d ValidatingWebhookXray) updateAPIService(ctx context.Context, apireg apireg_cs.Interface, apisvc *apiregistration.APIService, err error) error {
Expand Down
2 changes: 1 addition & 1 deletion apiextensions/kubernetes.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ func RegisterCRDs(client crd_cs.Interface, crds []*CustomResourceDefinition) err
}

func WaitForCRDReady(client crd_cs.Interface, crds []*CustomResourceDefinition) error {
err := wait.Poll(3*time.Second, 5*time.Minute, func() (bool, error) {
err := wait.PollUntilContextTimeout(context.Background(), 3*time.Second, 5*time.Minute, false, func(ctx context.Context) (bool, error) {
for _, crd := range crds {
var gvr schema.GroupVersionResource
if crd.V1 != nil {
Expand Down
2 changes: 1 addition & 1 deletion apiextensions/v1/crd.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ func TryUpdateCustomResourceDefinition(
opts metav1.UpdateOptions,
) (result *api.CustomResourceDefinition, err error) {
attempt := 0
err = wait.PollImmediate(kutil.RetryInterval, kutil.RetryTimeout, func() (bool, error) {
err = wait.PollUntilContextTimeout(ctx, kutil.RetryInterval, kutil.RetryTimeout, true, func(ctx context.Context) (bool, error) {
attempt++
cur, e2 := c.ApiextensionsV1().CustomResourceDefinitions().Get(ctx, name, metav1.GetOptions{})
if kerr.IsNotFound(e2) {
Expand Down
2 changes: 1 addition & 1 deletion apiextensions/v1beta1/crd.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ func TryUpdateCustomResourceDefinition(
opts metav1.UpdateOptions,
) (result *api.CustomResourceDefinition, err error) {
attempt := 0
err = wait.PollImmediate(kutil.RetryInterval, kutil.RetryTimeout, func() (bool, error) {
err = wait.PollUntilContextTimeout(ctx, kutil.RetryInterval, kutil.RetryTimeout, true, func(ctx context.Context) (bool, error) {
attempt++
cur, e2 := c.ApiextensionsV1beta1().CustomResourceDefinitions().Get(ctx, name, metav1.GetOptions{})
if kerr.IsNotFound(e2) {
Expand Down
2 changes: 1 addition & 1 deletion apiregistration/v1/apiservice.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ func PatchAPIServiceObject(ctx context.Context, c apireg_cs.Interface, cur, mod

func TryUpdateAPIService(ctx context.Context, c apireg_cs.Interface, name string, transform func(*reg.APIService) *reg.APIService, opts metav1.UpdateOptions) (result *reg.APIService, err error) {
attempt := 0
err = wait.PollImmediate(kutil.RetryInterval, kutil.RetryTimeout, func() (bool, error) {
err = wait.PollUntilContextTimeout(ctx, kutil.RetryInterval, kutil.RetryTimeout, true, func(ctx context.Context) (bool, error) {
attempt++
cur, e2 := c.ApiregistrationV1().APIServices().Get(ctx, name, metav1.GetOptions{})
if kerr.IsNotFound(e2) {
Expand Down
2 changes: 1 addition & 1 deletion apiregistration/v1beta1/apiservice.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ func PatchAPIServiceObject(ctx context.Context, c apireg_cs.Interface, cur, mod

func TryUpdateAPIService(ctx context.Context, c apireg_cs.Interface, name string, transform func(*reg.APIService) *reg.APIService, opts metav1.UpdateOptions) (result *reg.APIService, err error) {
attempt := 0
err = wait.PollImmediate(kutil.RetryInterval, kutil.RetryTimeout, func() (bool, error) {
err = wait.PollUntilContextTimeout(ctx, kutil.RetryInterval, kutil.RetryTimeout, true, func(ctx context.Context) (bool, error) {
attempt++
cur, e2 := c.ApiregistrationV1beta1().APIServices().Get(ctx, name, metav1.GetOptions{})
if kerr.IsNotFound(e2) {
Expand Down
4 changes: 2 additions & 2 deletions apps/v1/daemonset.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ func PatchDaemonSetObject(ctx context.Context, c kubernetes.Interface, cur, mod

func TryUpdateDaemonSet(ctx context.Context, c kubernetes.Interface, meta metav1.ObjectMeta, transform func(*apps.DaemonSet) *apps.DaemonSet, opts metav1.UpdateOptions) (result *apps.DaemonSet, err error) {
attempt := 0
err = wait.PollImmediate(kutil.RetryInterval, kutil.RetryTimeout, func() (bool, error) {
err = wait.PollUntilContextTimeout(ctx, kutil.RetryInterval, kutil.RetryTimeout, true, func(ctx context.Context) (bool, error) {
attempt++
cur, e2 := c.AppsV1().DaemonSets(meta.Namespace).Get(ctx, meta.Name, metav1.GetOptions{})
if kerr.IsNotFound(e2) {
Expand All @@ -101,7 +101,7 @@ func TryUpdateDaemonSet(ctx context.Context, c kubernetes.Interface, meta metav1
}

func WaitUntilDaemonSetReady(ctx context.Context, c kubernetes.Interface, meta metav1.ObjectMeta) error {
return wait.PollImmediate(kutil.RetryInterval, kutil.ReadinessTimeout, func() (bool, error) {
return wait.PollUntilContextTimeout(ctx, kutil.RetryInterval, kutil.ReadinessTimeout, true, func(ctx context.Context) (bool, error) {
// It takes some time to populate .status field of the DaemonSet after it is being created.
// If this function is called just after creating a DaemonSet, the Get methond returns an obj with .status field is defaulted to their default values.
// At this time, "obj.Status.DesiredNumberScheduled" and "obj.Status.NumberReady" both are defaulted to 0 and "obj.Status.DesiredNumberScheduled == obj.Status.NumberReady"
Expand Down
4 changes: 2 additions & 2 deletions apps/v1/deployment.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ func PatchDeploymentObject(ctx context.Context, c kubernetes.Interface, cur, mod

func TryUpdateDeployment(ctx context.Context, c kubernetes.Interface, meta metav1.ObjectMeta, transform func(*apps.Deployment) *apps.Deployment, opts metav1.UpdateOptions) (result *apps.Deployment, err error) {
attempt := 0
err = wait.PollImmediate(kutil.RetryInterval, kutil.RetryTimeout, func() (bool, error) {
err = wait.PollUntilContextTimeout(ctx, kutil.RetryInterval, kutil.RetryTimeout, true, func(ctx context.Context) (bool, error) {
attempt++
cur, e2 := c.AppsV1().Deployments(meta.Namespace).Get(ctx, meta.Name, metav1.GetOptions{})
if kerr.IsNotFound(e2) {
Expand Down Expand Up @@ -122,7 +122,7 @@ func DeploymentsAreReady(items []*apps.Deployment) (bool, string) {
}

func WaitUntilDeploymentReady(ctx context.Context, c kubernetes.Interface, meta metav1.ObjectMeta) error {
return wait.PollImmediate(kutil.RetryInterval, kutil.ReadinessTimeout, func() (bool, error) {
return wait.PollUntilContextTimeout(ctx, kutil.RetryInterval, kutil.ReadinessTimeout, true, func(ctx context.Context) (bool, error) {
if obj, err := c.AppsV1().Deployments(meta.Namespace).Get(ctx, meta.Name, metav1.GetOptions{}); err == nil {
return IsDeploymentReady(obj), nil
}
Expand Down
4 changes: 2 additions & 2 deletions apps/v1/replicaset.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ func PatchReplicaSetObject(ctx context.Context, c kubernetes.Interface, cur, mod

func TryUpdateReplicaSet(ctx context.Context, c kubernetes.Interface, meta metav1.ObjectMeta, transform func(*apps.ReplicaSet) *apps.ReplicaSet, opts metav1.UpdateOptions) (result *apps.ReplicaSet, err error) {
attempt := 0
err = wait.PollImmediate(kutil.RetryInterval, kutil.RetryTimeout, func() (bool, error) {
err = wait.PollUntilContextTimeout(ctx, kutil.RetryInterval, kutil.RetryTimeout, true, func(ctx context.Context) (bool, error) {
attempt++
cur, e2 := c.AppsV1().ReplicaSets(meta.Namespace).Get(ctx, meta.Name, metav1.GetOptions{})
if kerr.IsNotFound(e2) {
Expand All @@ -102,7 +102,7 @@ func TryUpdateReplicaSet(ctx context.Context, c kubernetes.Interface, meta metav
}

func WaitUntilReplicaSetReady(ctx context.Context, c kubernetes.Interface, meta metav1.ObjectMeta) error {
return wait.PollImmediate(kutil.RetryInterval, kutil.ReadinessTimeout, func() (bool, error) {
return wait.PollUntilContextTimeout(ctx, kutil.RetryInterval, kutil.ReadinessTimeout, true, func(ctx context.Context) (bool, error) {
if obj, err := c.AppsV1().ReplicaSets(meta.Namespace).Get(ctx, meta.Name, metav1.GetOptions{}); err == nil {
return pointer.Int32(obj.Spec.Replicas) == obj.Status.ReadyReplicas, nil
}
Expand Down
4 changes: 2 additions & 2 deletions apps/v1/statefulset.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ func PatchStatefulSetObject(ctx context.Context, c kubernetes.Interface, cur, mo

func TryUpdateStatefulSet(ctx context.Context, c kubernetes.Interface, meta metav1.ObjectMeta, transform func(*apps.StatefulSet) *apps.StatefulSet, opts metav1.UpdateOptions) (result *apps.StatefulSet, err error) {
attempt := 0
err = wait.PollImmediate(kutil.RetryInterval, kutil.RetryTimeout, func() (bool, error) {
err = wait.PollUntilContextTimeout(ctx, kutil.RetryInterval, kutil.RetryTimeout, true, func(ctx context.Context) (bool, error) {
attempt++
cur, e2 := c.AppsV1().StatefulSets(meta.Namespace).Get(ctx, meta.Name, metav1.GetOptions{})
if kerr.IsNotFound(e2) {
Expand Down Expand Up @@ -122,7 +122,7 @@ func StatefulSetsAreReady(items []*apps.StatefulSet) (bool, string) {
}

func WaitUntilStatefulSetReady(ctx context.Context, c kubernetes.Interface, meta metav1.ObjectMeta) error {
return wait.PollImmediate(kutil.RetryInterval, kutil.ReadinessTimeout, func() (bool, error) {
return wait.PollUntilContextTimeout(ctx, kutil.RetryInterval, kutil.ReadinessTimeout, true, func(ctx context.Context) (bool, error) {
if obj, err := c.AppsV1().StatefulSets(meta.Namespace).Get(ctx, meta.Name, metav1.GetOptions{}); err == nil {
return IsStatefulSetReady(obj), nil
}
Expand Down
2 changes: 1 addition & 1 deletion batch/v1/cronjob.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ func PatchCronJobObject(ctx context.Context, c kubernetes.Interface, cur, mod *b

func TryUpdateCronJob(ctx context.Context, c kubernetes.Interface, meta metav1.ObjectMeta, transform func(*batch.CronJob) *batch.CronJob, opts metav1.UpdateOptions) (result *batch.CronJob, err error) {
attempt := 0
err = wait.PollImmediate(kutil.RetryInterval, kutil.RetryTimeout, func() (bool, error) {
err = wait.PollUntilContextTimeout(ctx, kutil.RetryInterval, kutil.RetryTimeout, true, func(ctx context.Context) (bool, error) {
attempt++
cur, e2 := c.BatchV1().CronJobs(meta.Namespace).Get(ctx, meta.Name, metav1.GetOptions{})
if kerr.IsNotFound(e2) {
Expand Down
4 changes: 2 additions & 2 deletions batch/v1/job.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ func PatchJobObject(ctx context.Context, c kubernetes.Interface, cur, mod *batch

func TryUpdateJob(ctx context.Context, c kubernetes.Interface, meta metav1.ObjectMeta, transform func(*batch.Job) *batch.Job, opts metav1.UpdateOptions) (result *batch.Job, err error) {
attempt := 0
err = wait.PollImmediate(kutil.RetryInterval, kutil.RetryTimeout, func() (bool, error) {
err = wait.PollUntilContextTimeout(ctx, kutil.RetryInterval, kutil.RetryTimeout, true, func(ctx context.Context) (bool, error) {
attempt++
cur, e2 := c.BatchV1().Jobs(meta.Namespace).Get(ctx, meta.Name, metav1.GetOptions{})
if kerr.IsNotFound(e2) {
Expand All @@ -102,7 +102,7 @@ func TryUpdateJob(ctx context.Context, c kubernetes.Interface, meta metav1.Objec
}

func WaitUntilJobCompletion(ctx context.Context, c kubernetes.Interface, meta metav1.ObjectMeta) error {
return wait.PollInfinite(kutil.RetryInterval, func() (bool, error) {
return wait.PollUntilContextCancel(ctx, kutil.RetryInterval, true, func(ctx context.Context) (bool, error) {
job, err := c.BatchV1().Jobs(meta.Namespace).Get(ctx, meta.Name, metav1.GetOptions{})
if err != nil {
if kerr.IsNotFound(err) {
Expand Down
2 changes: 1 addition & 1 deletion batch/v1beta1/cronjob.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ func PatchCronJobObject(ctx context.Context, c kubernetes.Interface, cur, mod *b

func TryUpdateCronJob(ctx context.Context, c kubernetes.Interface, meta metav1.ObjectMeta, transform func(*batch.CronJob) *batch.CronJob, opts metav1.UpdateOptions) (result *batch.CronJob, err error) {
attempt := 0
err = wait.PollImmediate(kutil.RetryInterval, kutil.RetryTimeout, func() (bool, error) {
err = wait.PollUntilContextTimeout(ctx, kutil.RetryInterval, kutil.RetryTimeout, true, func(ctx context.Context) (bool, error) {
attempt++
cur, e2 := c.BatchV1beta1().CronJobs(meta.Namespace).Get(ctx, meta.Name, metav1.GetOptions{})
if kerr.IsNotFound(e2) {
Expand Down
2 changes: 1 addition & 1 deletion certificates/v1beta1/csr.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ func PatchCSRObject(ctx context.Context, c kubernetes.Interface, cur, mod *certi

func TryUpdateCSR(ctx context.Context, c kubernetes.Interface, meta metav1.ObjectMeta, transform func(*certificates.CertificateSigningRequest) *certificates.CertificateSigningRequest, opts metav1.UpdateOptions) (result *certificates.CertificateSigningRequest, err error) {
attempt := 0
err = wait.PollImmediate(kutil.RetryInterval, kutil.RetryTimeout, func() (bool, error) {
err = wait.PollUntilContextTimeout(ctx, kutil.RetryInterval, kutil.RetryTimeout, true, func(ctx context.Context) (bool, error) {
attempt++
cur, e2 := c.CertificatesV1beta1().CertificateSigningRequests().Get(ctx, meta.Name, metav1.GetOptions{})
if kerr.IsNotFound(e2) {
Expand Down
2 changes: 1 addition & 1 deletion client/sa-token.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ const (
)

func tryGetServiceAccountTokenSecret(kc client.Client, sa client.ObjectKey) (secret *core.Secret, err error) {
err = wait.PollImmediate(kutil.RetryInterval, RetryTimeout, func() (bool, error) {
err = wait.PollUntilContextTimeout(context.Background(), kutil.RetryInterval, RetryTimeout, true, func(ctx context.Context) (bool, error) {
var e2 error
secret, e2 = getServiceAccountTokenSecret(kc, sa)
if e2 == nil {
Expand Down
2 changes: 1 addition & 1 deletion core/v1/configmap.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ func PatchConfigMapObject(ctx context.Context, c kubernetes.Interface, cur, mod

func TryUpdateConfigMap(ctx context.Context, c kubernetes.Interface, meta metav1.ObjectMeta, transform func(*core.ConfigMap) *core.ConfigMap, opts metav1.UpdateOptions) (result *core.ConfigMap, err error) {
attempt := 0
err = wait.PollImmediate(kutil.RetryInterval, kutil.RetryTimeout, func() (bool, error) {
err = wait.PollUntilContextTimeout(ctx, kutil.RetryInterval, kutil.RetryTimeout, true, func(ctx context.Context) (bool, error) {
attempt++
cur, e2 := c.CoreV1().ConfigMaps(meta.Namespace).Get(ctx, meta.Name, metav1.GetOptions{})
if kerr.IsNotFound(e2) {
Expand Down
2 changes: 1 addition & 1 deletion core/v1/events.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ func PatchEventObject(ctx context.Context, c kubernetes.Interface, cur, mod *cor

func TryUpdateEvent(ctx context.Context, c kubernetes.Interface, meta metav1.ObjectMeta, transform func(*core.Event) *core.Event, opts metav1.UpdateOptions) (result *core.Event, err error) {
attempt := 0
err = wait.PollImmediate(kutil.RetryInterval, kutil.RetryTimeout, func() (bool, error) {
err = wait.PollUntilContextTimeout(ctx, kutil.RetryInterval, kutil.RetryTimeout, true, func(ctx context.Context) (bool, error) {
attempt++
cur, e2 := c.CoreV1().Events(meta.Namespace).Get(ctx, meta.Name, metav1.GetOptions{})
if kerr.IsNotFound(e2) {
Expand Down
8 changes: 4 additions & 4 deletions core/v1/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ func PatchNodeObject(ctx context.Context, c kubernetes.Interface, cur, mod *core

func TryUpdateNode(ctx context.Context, c kubernetes.Interface, meta metav1.ObjectMeta, transform func(*core.Node) *core.Node, opts metav1.UpdateOptions) (result *core.Node, err error) {
attempt := 0
err = wait.PollImmediate(kutil.RetryInterval, kutil.RetryTimeout, func() (bool, error) {
err = wait.PollUntilContextTimeout(ctx, kutil.RetryInterval, kutil.RetryTimeout, true, func(ctx context.Context) (bool, error) {
attempt++
cur, e2 := c.CoreV1().Nodes().Get(ctx, meta.Name, metav1.GetOptions{})
if kerr.IsNotFound(e2) {
Expand Down Expand Up @@ -204,7 +204,7 @@ func DetectTopology(ctx context.Context, mc metadata.Interface) (*Topology, erro
var topology Topology
topology.TotalNodes = 0

mapRegion := make(map[string]sets.String)
mapRegion := make(map[string]sets.Set[string])
instances := make(map[string]int)
first := true

Expand Down Expand Up @@ -259,7 +259,7 @@ func DetectTopology(ctx context.Context, mc metadata.Interface) (*Topology, erro
region, _ := meta_util.GetStringValueForKeys(labels, topology.LabelRegion)
zone, _ := meta_util.GetStringValueForKeys(labels, topology.LabelZone)
if _, ok := mapRegion[region]; !ok {
mapRegion[region] = sets.NewString()
mapRegion[region] = sets.Set[string]{}
}
mapRegion[region].Insert(zone)

Expand All @@ -278,7 +278,7 @@ func DetectTopology(ctx context.Context, mc metadata.Interface) (*Topology, erro

regions := make(map[string][]string)
for k, v := range mapRegion {
regions[k] = v.List()
regions[k] = sets.List(v)
}
topology.Regions = regions
topology.InstanceTypes = instances
Expand Down
Loading

0 comments on commit 0753a8e

Please sign in to comment.