Skip to content

Commit

Permalink
Use Patch for status update
Browse files Browse the repository at this point in the history
  • Loading branch information
nolancon committed Dec 16, 2024
1 parent 7930848 commit 21cec7c
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion internal/controller/bucket/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import (
"github.com/linode/provider-ceph/internal/consts"
"github.com/linode/provider-ceph/internal/utils"
"go.opentelemetry.io/otel"
"sigs.k8s.io/controller-runtime/pkg/client"

kerrors "k8s.io/apimachinery/pkg/api/errors"
"k8s.io/apimachinery/pkg/types"
Expand Down Expand Up @@ -247,9 +248,10 @@ func (c *external) updateBucketCR(ctx context.Context, bucket *v1alpha1.Bucket,
if err := c.kubeClient.Get(ctx, nn, bucket); err != nil {
return err
}
bucketDeepCopy := bucket.DeepCopy()
switch cb(bucket) {
case NeedsStatusUpdate:
return c.kubeClient.Status().Update(ctx, bucket)
return c.kubeClient.Status().Patch(ctx, bucket, client.MergeFrom(bucketDeepCopy))
case NeedsObjectUpdate:
return c.kubeClient.Update(ctx, bucket)
default:
Expand Down

0 comments on commit 21cec7c

Please sign in to comment.