client-go: k8s.io/client-go/util/retry Index | Files

package retry

import "k8s.io/client-go/util/retry"

Index

Package Files

util.go

Variables

var DefaultBackoff = wait.Backoff{
    Steps:    4,
    Duration: 10 * time.Millisecond,
    Factor:   5.0,
    Jitter:   0.1,
}

DefaultBackoff is the recommended backoff for a conflict where a client may be attempting to make an unrelated modification to a resource under active management by one or more controllers.

var DefaultRetry = wait.Backoff{
    Steps:    5,
    Duration: 10 * time.Millisecond,
    Factor:   1.0,
    Jitter:   0.1,
}

DefaultRetry is the recommended retry for a conflict where multiple clients are making changes to the same resource.

func RetryOnConflict Uses

func RetryOnConflict(backoff wait.Backoff, fn func() error) error

RetryConflict executes the provided function repeatedly, retrying if the server returns a conflicting write. Callers should preserve previous executions if they wish to retry changes. It performs an exponential backoff.

var pod *api.Pod
err := RetryOnConflict(DefaultBackoff, func() (err error) {
  pod, err = c.Pods("mynamespace").UpdateStatus(podStatus)
  return
})
if err != nil {
  // may be conflict if max retries were hit
  return err
}
...

TODO: Make Backoff an interface?

Package retry imports 3 packages (graph) and is imported by 262 packages. Updated 2018-03-18. Refresh now. Tools for package owners.