Skip to content

Commit

Permalink
Log diff on resource update
Browse files Browse the repository at this point in the history
  • Loading branch information
samuelattwood committed Jan 31, 2025
1 parent 6ddcced commit 577ce79
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 4 deletions.
4 changes: 0 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -79,14 +79,10 @@ github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9G
github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk=
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 h1:C3w9PqII01/Oq1c1nUAm88MOHcQC9l5mIlSMApZMrHA=
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822/go.mod h1:+n7T8mK8HuQTcFwEeznm/DIxMOiR9yIdICNftLE1DvQ=
github.com/nats-io/jsm.go v0.1.1-0.20250120135113-0db99fd62ad9 h1:2DfL+nZjlB8kQh5GN5IEBdVroHbRaRod3BAi07Ag89Q=
github.com/nats-io/jsm.go v0.1.1-0.20250120135113-0db99fd62ad9/go.mod h1:w/SA3/rNK5xl6ZsCqKLVgQzVLfxbYNScle8LcQ5gSBM=
github.com/nats-io/jsm.go v0.1.1-0.20250127160126-62a6bf0def83 h1:0NXdeCr1J2bytMkdGgCLW//ymhAM716HFnnSU8OxnVc=
github.com/nats-io/jsm.go v0.1.1-0.20250127160126-62a6bf0def83/go.mod h1:+wiVkC1oBBVXnJaWdbsLwXN/vH5rZgjkkfsu5a76q3s=
github.com/nats-io/jwt/v2 v2.7.3 h1:6bNPK+FXgBeAqdj4cYQ0F8ViHRbi7woQLq4W29nUAzE=
github.com/nats-io/jwt/v2 v2.7.3/go.mod h1:GvkcbHhKquj3pkioy5put1wvPxs78UlZ7D/pY+BgZk4=
github.com/nats-io/nats-server/v2 v2.11.0-dev.0.20250109022000-c0ae95d0be26 h1:mN0eraizaHih90T32ItWe58+l31eVjoD6JOu99WqdNc=
github.com/nats-io/nats-server/v2 v2.11.0-dev.0.20250109022000-c0ae95d0be26/go.mod h1:nXRZ6eQo2lmNpZLVNIMDNwKM7FgbHgPJ1pIRcPOpVuk=
github.com/nats-io/nats-server/v2 v2.11.0-dev.0.20250126014539-f2eb5650d200 h1:JTZQwrehqUHpEO+DRjm0734B4a0porO1Cb5ACT0nSJY=
github.com/nats-io/nats-server/v2 v2.11.0-dev.0.20250126014539-f2eb5650d200/go.mod h1:NLseHFkD5ZPPkHVYn4JEG8LguxveaOXJPiIfswZugHg=
github.com/nats-io/nats.go v1.38.0 h1:A7P+g7Wjp4/NWqDOOP/K6hfhr54DvdDQUznt5JFg9XA=
Expand Down
3 changes: 3 additions & 0 deletions internal/controller/consumer_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,9 @@ func (r *ConsumerReconciler) createOrUpdate(ctx context.Context, log klog.Logger
if err != nil {
return err
}

diff := compareConfigState(updatedConsumer.Configuration(), *serverState)
log.Info("Updated Consumer.", "diff", diff)
} else {
log.Info("Skipping Consumer update.",
"preventUpdate", consumer.Spec.PreventUpdate,
Expand Down
8 changes: 8 additions & 0 deletions internal/controller/keyvalue_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,14 @@ func (r *KeyValueReconciler) createOrUpdate(ctx context.Context, log logr.Logger
if err != nil {
return err
}

updatedKeyValue, err := getServerKeyValueState(ctx, js, keyValue)
if err != nil {
log.Error(err, "Failed to fetch updated KeyValue state")
} else {
diff := compareConfigState(updatedKeyValue, serverState)
log.Info("Updated KeyValue.", "diff", diff)
}
} else {
log.Info("Skipping KeyValue update.",
"preventUpdate", keyValue.Spec.PreventUpdate,
Expand Down
8 changes: 8 additions & 0 deletions internal/controller/objectstore_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,14 @@ func (r *ObjectStoreReconciler) createOrUpdate(ctx context.Context, log logr.Log
if err != nil {
return err
}

updatedObjectStore, err := getServerObjectStoreState(ctx, js, objectStore)
if err != nil {
log.Error(err, "Failed to fetch updated objectstore state")
} else {
diff := compareConfigState(updatedObjectStore, serverState)
log.Info("Updated ObjectStore.", "diff", diff)
}
} else {
log.Info("Skipping ObjectStore update.",
"preventUpdate", objectStore.Spec.PreventUpdate,
Expand Down
3 changes: 3 additions & 0 deletions internal/controller/stream_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,9 @@ func (r *StreamReconciler) createOrUpdate(ctx context.Context, log logr.Logger,
if err != nil {
return err
}

diff := compareConfigState(updatedStream.Configuration(), *serverState)
log.Info("Updated Stream.", "diff", diff)
} else {
log.Info("Skipping Stream update.",
"preventUpdate", stream.Spec.PreventUpdate,
Expand Down

0 comments on commit 577ce79

Please sign in to comment.