Skip to content
This repository has been archived by the owner on Apr 18, 2024. It is now read-only.

Commit

Permalink
fix: return if objects needs to be updated with finalizer
Browse files Browse the repository at this point in the history
  • Loading branch information
teodor-pripoae committed Aug 9, 2021
1 parent d690357 commit 1f81b86
Show file tree
Hide file tree
Showing 4 changed files with 3 additions and 19 deletions.
11 changes: 1 addition & 10 deletions controllers/rest_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -132,16 +132,7 @@ func (r *RESTReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.
return ctrl.Result{}, err
}

// refresh object to avoid getting error: the object has been modified; please apply your changes to the latest version and try again
if err := r.ControllerClient.Get(ctx, req.NamespacedName, rest); err != nil {
if kerrors.IsNotFound(err) {
log.Error(err, "rest not found")
return reconcile.Result{}, nil
}
log.Error(err, "failed to get rest")
incRESTFailed(name)
return reconcile.Result{}, err
}
return ctrl.Result{}, nil
}

err = tm.Update(ctx, rest)
Expand Down
2 changes: 1 addition & 1 deletion examples/rest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ spec:
"matchers": [
{
"name": "alertname",
"value": "ExcessivePodCPURatioS",
"value": "ExcessivePodCPURatio",
"isRegex": false,
"isEqual": true
}
Expand Down
8 changes: 0 additions & 8 deletions k8s/rest_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,6 @@ func (r *RESTManager) Update(ctx context.Context, rest *templatev1.REST) error {
return nil
}

if rest.Status == nil {
rest.Status = map[string]string{}
}

url := rest.Spec.Update.URL
method := rest.Spec.Update.Method
body := rest.Spec.Update.Body
Expand Down Expand Up @@ -82,10 +78,6 @@ func (r *RESTManager) Update(ctx context.Context, rest *templatev1.REST) error {
}

func (r *RESTManager) Delete(ctx context.Context, rest *templatev1.REST) error {
if rest.Status == nil {
rest.Status = map[string]string{}
}

url := rest.Spec.Remove.URL
method := rest.Spec.Remove.Method
body := rest.Spec.Remove.Body
Expand Down
1 change: 1 addition & 0 deletions test/e2e.go
Original file line number Diff line number Diff line change
Expand Up @@ -794,6 +794,7 @@ metadata:
spec:
backup:
bucket: e2e-postgres-backups
restic: false
cpu: "0.5"
memory: 6Gi
parameters:
Expand Down

0 comments on commit 1f81b86

Please sign in to comment.