Skip to content

Commit

Permalink
Use non-deprecated functions after K8s lib bump
Browse files Browse the repository at this point in the history
Go linter errors [1] suggested to use different functions, so use them to
appease the robots. But also mostly because the K8s developers have
decided to deprecate the existing functions

[1]:

```
Error: SA1019: wait.PollWithContext is deprecated: This method does not return errors from context, use PollWithContextTimeout. Note that the new method will no longer return ErrWaitTimeout and instead return errors defined by the context package. Will be removed in a future release.  (staticcheck)
```

Signed-off-by: Chris Tarazi <[email protected]>
  • Loading branch information
christarazi committed Apr 26, 2023
1 parent f8b16b6 commit e84da68
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions sysdump/k8sutils.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ func (c *Collector) ensureExecTarget(ctx context.Context, pod *corev1.Pod, conta
c.logDebug("Created EphemeralContainer %q on pod %q in namespace %q", ec.Name, pod.Name, pod.Namespace)

// Ephemeral container created, wait for it to enter Running status.
err = wait.PollWithContext(ctx, 10*time.Second, 30*time.Second, func(ctx context.Context) (bool, error) {
err = wait.PollUntilContextTimeout(ctx, 10*time.Second, 30*time.Second, false, func(ctx context.Context) (bool, error) {
var err error
targetPod, err = c.Client.GetPod(ctx, targetPod.Namespace, targetPod.Name, metav1.GetOptions{})
if err != nil {
Expand Down Expand Up @@ -141,7 +141,7 @@ func (c *Collector) ensureExecTarget(ctx context.Context, pod *corev1.Pod, conta
}

// Wait up to 2 minutes for pod to be available
err = wait.PollWithContext(ctx, 10*time.Second, 2*time.Minute, func(ctx context.Context) (bool, error) {
err = wait.PollUntilContextTimeout(ctx, 10*time.Second, 2*time.Minute, false, func(ctx context.Context) (bool, error) {
var err error
targetPod, err = c.Client.GetPod(ctx, targetPod.Namespace, targetPod.Name, metav1.GetOptions{})
if err != nil {
Expand Down

0 comments on commit e84da68

Please sign in to comment.