Skip to content

Commit

Permalink
go back to update after simplify
Browse files Browse the repository at this point in the history
  • Loading branch information
nolancon committed Dec 17, 2024
1 parent 01818a4 commit 3737a03
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions internal/controller/bucket/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ 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 @@ -241,13 +240,12 @@ func (c *external) updateBucketCR(ctx context.Context, bucket *v1alpha1.Bucket,
ctx, span := otel.Tracer("").Start(ctx, "bucket.external.updateBucketCR")
defer span.End()

bucketDeepCopy := &v1alpha1.Bucket{}
nn := types.NamespacedName{Name: bucket.GetName()}
err := retry.OnError(retry.DefaultRetry, resource.IsAPIError, func() error {
if err := c.kubeClient.Get(ctx, nn, bucket); err != nil {
return err
}
bucketDeepCopy = bucket.DeepCopy()

return nil
})
if err != nil {
Expand All @@ -262,9 +260,9 @@ func (c *external) updateBucketCR(ctx context.Context, bucket *v1alpha1.Bucket,
if err := retry.OnError(retry.DefaultRetry, resource.IsAPIError, func() error {
switch cb(bucket) {
case NeedsStatusUpdate:
return c.kubeClient.Status().Patch(ctx, bucket, client.MergeFrom(bucketDeepCopy))
return c.kubeClient.Status().Update(ctx, bucket)
case NeedsObjectUpdate:
return c.kubeClient.Patch(ctx, bucket, client.MergeFrom(bucketDeepCopy))
return c.kubeClient.Update(ctx, bucket)
default:
return nil
}
Expand Down

0 comments on commit 3737a03

Please sign in to comment.