Skip to content

Commit

Permalink
Merge pull request #212 from gibizer/remove-double-update
Browse files Browse the repository at this point in the history
Remove explicit instance Update calls
  • Loading branch information
openshift-merge-bot[bot] authored Apr 25, 2024
2 parents db67ae2 + af17c5b commit c58164c
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 33 deletions.
6 changes: 0 additions & 6 deletions controllers/swiftproxy_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -172,12 +172,6 @@ func (r *SwiftProxyReconciler) Reconcile(ctx context.Context, req ctrl.Request)
return ctrl.Result{}, nil
}

if isNewInstance {
if err := r.Status().Update(ctx, instance); err != nil {
return ctrl.Result{}, err
}
}

if instance.Status.NetworkAttachments == nil {
instance.Status.NetworkAttachments = map[string][]string{}
}
Expand Down
18 changes: 0 additions & 18 deletions controllers/swiftring_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -145,12 +145,6 @@ func (r *SwiftRingReconciler) Reconcile(ctx context.Context, req ctrl.Request) (
return ctrl.Result{}, nil
}

if isNewInstance {
if err := r.Status().Update(ctx, instance); err != nil {
return ctrl.Result{}, err
}
}

if !instance.DeletionTimestamp.IsZero() {
return r.reconcileDelete(ctx, instance, helper)
}
Expand Down Expand Up @@ -210,9 +204,6 @@ func (r *SwiftRingReconciler) reconcileNormal(ctx context.Context, instance *swi

instance.Status.Hash[swiftv1beta1.RingCreateHash] = ""
instance.Status.Hash[swiftv1beta1.DeviceListHash] = deviceListHash
if err := r.Status().Update(ctx, instance); err != nil {
return ctrl.Result{}, err
}
}

ringCreateJob := job.NewJob(swiftring.GetRingJob(instance, serviceLabels), "rebalance", true, 5*time.Second, instance.Status.Hash[swiftv1beta1.RingCreateHash])
Expand All @@ -231,24 +222,15 @@ func (r *SwiftRingReconciler) reconcileNormal(ctx context.Context, instance *swi
condition.ErrorReason,
condition.SeverityWarning,
err.Error()))
if err := r.Status().Update(ctx, instance); err != nil {
return ctrl.Result{}, err
}
return ctrl.Result{}, err
}

if ringCreateJob.HasChanged() {
instance.Status.Hash[swiftv1beta1.RingCreateHash] = ringCreateJob.GetHash()
if err := r.Status().Update(ctx, instance); err != nil {
return ctrl.Result{}, err
}
}

instance.Status.Conditions.MarkTrue(condition.ReadyCondition, condition.ReadyMessage)
instance.Status.Conditions.MarkTrue(swiftv1beta1.SwiftRingReadyCondition, condition.ReadyMessage)
if err := r.Status().Update(ctx, instance); err != nil {
return ctrl.Result{}, err
}
// Swift ring init job - end

// We reached the end of the Reconcile, update the Ready condition based on
Expand Down
9 changes: 0 additions & 9 deletions controllers/swiftstorage_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -173,12 +173,6 @@ func (r *SwiftStorageReconciler) Reconcile(ctx context.Context, req ctrl.Request
return ctrl.Result{}, nil
}

if isNewInstance {
if err := r.Status().Update(ctx, instance); err != nil {
return ctrl.Result{}, err
}
}

if instance.Status.NetworkAttachments == nil {
instance.Status.NetworkAttachments = map[string][]string{}
}
Expand Down Expand Up @@ -384,9 +378,6 @@ func (r *SwiftStorageReconciler) Reconcile(ctx context.Context, req ctrl.Request

instance.Status.Conditions.MarkTrue(condition.ReadyCondition, condition.ReadyMessage)
instance.Status.Conditions.MarkTrue(swiftv1beta1.SwiftStorageReadyCondition, condition.ReadyMessage)
if err := r.Status().Update(ctx, instance); err != nil {
return ctrl.Result{}, err
}
} else {
instance.Status.Conditions.Set(condition.FalseCondition(
swiftv1beta1.SwiftStorageReadyCondition,
Expand Down

0 comments on commit c58164c

Please sign in to comment.