Skip to content

Commit a2d55b5

Browse files
authored
Merge pull request #953 from ialidzhikov/fix/double-logging
📖 Prevent errors to be logged multiple times in builtins example
2 parents aac7ac5 + a4b50a4 commit a2d55b5

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

examples/builtins/controller.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ package main
1818

1919
import (
2020
"context"
21+
"fmt"
2122

2223
"github.com/go-logr/logr"
2324

@@ -50,8 +51,7 @@ func (r *reconcileReplicaSet) Reconcile(request reconcile.Request) (reconcile.Re
5051
}
5152

5253
if err != nil {
53-
log.Error(err, "Could not fetch ReplicaSet")
54-
return reconcile.Result{}, err
54+
return reconcile.Result{}, fmt.Errorf("could not fetch ReplicaSet: %+v", err)
5555
}
5656

5757
// Print the ReplicaSet
@@ -69,8 +69,7 @@ func (r *reconcileReplicaSet) Reconcile(request reconcile.Request) (reconcile.Re
6969
rs.Labels["hello"] = "world"
7070
err = r.client.Update(context.TODO(), rs)
7171
if err != nil {
72-
log.Error(err, "Could not write ReplicaSet")
73-
return reconcile.Result{}, err
72+
return reconcile.Result{}, fmt.Errorf("could not write ReplicaSet: %+v", err)
7473
}
7574

7675
return reconcile.Result{}, nil

0 commit comments

Comments
 (0)