Skip to content

Commit 95acd68

Browse files
authored
Log resourceVersion on Create and Update (elastic#8503)
1 parent 4aeccb6 commit 95acd68

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

pkg/controller/common/reconciler/reconciler.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,8 @@ type Params struct {
4949
PostUpdate func()
5050
}
5151

52+
const resourceVersion = "resourceVersion"
53+
5254
func (p Params) CheckNilValues() error {
5355
if p.Reconciled == nil {
5456
return errors.New("Reconciled must not be nil")
@@ -88,7 +90,6 @@ func ReconcileResource(params Params) error {
8890
namespace := params.Expected.GetNamespace()
8991
name := params.Expected.GetName()
9092
log := ulog.FromContext(params.Context).WithValues("kind", kind, "namespace", namespace, "name", name)
91-
9293
create := func() error {
9394
log.Info("Creating resource")
9495
if params.PreCreate != nil {
@@ -108,7 +109,7 @@ func ReconcileResource(params Params) error {
108109
if err != nil {
109110
return err
110111
}
111-
log.Info("Created resource successfully")
112+
log.Info("Created resource successfully", resourceVersion, params.Reconciled.GetResourceVersion())
112113
return nil
113114
}
114115

@@ -182,7 +183,7 @@ func ReconcileResource(params Params) error {
182183
if params.PostUpdate != nil {
183184
params.PostUpdate()
184185
}
185-
log.Info("Updated resource successfully")
186+
log.Info("Updated resource successfully", resourceVersion, params.Reconciled.GetResourceVersion())
186187
}
187188
return nil
188189
}

0 commit comments

Comments
 (0)