diff --git a/api/v1alpha1/storage_webhook.go b/api/v1alpha1/storage_webhook.go index d6be5085..816f4ba4 100644 --- a/api/v1alpha1/storage_webhook.go +++ b/api/v1alpha1/storage_webhook.go @@ -116,10 +116,6 @@ func (r *StorageDefaulter) Default(ctx context.Context, obj runtime.Object) erro storage := obj.(*Storage) storagelog.Info("default", "name", storage.Name) - if !storage.Spec.OperatorSync { - return nil - } - if storage.Spec.OperatorConnection != nil { if storage.Spec.OperatorConnection.Oauth2TokenExchange != nil { if storage.Spec.OperatorConnection.Oauth2TokenExchange.SignAlg == "" { @@ -311,9 +307,43 @@ func hasUpdatesBesidesFrozen(oldStorage, newStorage *Storage) (bool, string) { oldStorageCopy.Spec.OperatorSync = false newStorageCopy.Spec.OperatorSync = false - ignoreNonSpecFields := cmpopts.IgnoreFields(Storage{}, "Status", "ObjectMeta", "TypeMeta") + // We will allow configuration diffs if they are limited to + // formatting, order of keys in the map etc. If two maps are + // meaningfully different (not deep-equal), we still disallow + // the diff of course. + configurationCompareOpt := cmp.FilterPath( + func(path cmp.Path) bool { + if sf, ok := path.Last().(cmp.StructField); ok { + return sf.Name() == "Configuration" + } + return false + }, + cmp.Comparer(func(a, b string) bool { + var o1, o2 any + + if err := yaml.Unmarshal([]byte(a), &o1); err != nil { + return false + } + if err := yaml.Unmarshal([]byte(b), &o2); err != nil { + return false + } + + diff := cmp.Diff(o1, o2) + if diff != "" { + storagelog.Info(fmt.Sprintf("Configurations are different:\n%v\n%v", o1, o2)) + } + + return diff == "" + }), + ) - diff := cmp.Diff(oldStorageCopy, newStorageCopy, ignoreNonSpecFields) + ignoreNonSpecFields := cmpopts.IgnoreFields(Storage{}, "Status", "ObjectMeta", "TypeMeta") + diff := cmp.Diff( + oldStorageCopy, + newStorageCopy, + ignoreNonSpecFields, + configurationCompareOpt, + ) return diff != "", diff }