Kubernetes operators best practices: understanding conflict errors

  • user submitted new spec of the resource between you last pulled it from the server
  • some other controller updated the status or some other field on your resource
err := retry.RetryOnConflict(retry.DefaultRetry, func() error {    var res apiv1.MyResource    err := r.Get(ctx, types.NamespacedName{        Name:      resourceName,        Namespace: resourceNamespace,    }, &res)    if err != nil {        return err    }    res.Status.Replias = readyReplicas        return r.Status().Update(ctx, &res)})if err != nil {    return fmt.Errorf("failed to update resource status: %w", err)}

--

--

--

Passionate about traveling, food and programming. Tennis player that works on container orchestration at Mesosphere. Always trying to improve.

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

AMA RECAP : CRYPTOSTALKERS x DECHART .

Clean Code: Meaningful Names

How to avoid N+1 Query

How to setup cloud call center for under $200 in 10 minutes?

Self-Care For Developers

What’s Next: Continuous Optimization

Authorize and Restore Azure Artifacts NuGet packages within GitHub Actions workflow

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Alena Varkockova

Alena Varkockova

Passionate about traveling, food and programming. Tennis player that works on container orchestration at Mesosphere. Always trying to improve.

More from Medium

Kickstarting CI Best Practices in Autonomous Teams

GitOps Part 2.1: A GitOps Example “Conceptual Expression of Module Based Git Flow”

RazorOps Speeding up the deployment of microservices with Kubernetes!

Everything about Monolithic Architecture