diff --git a/controllers/apps/operations/reconfigure_pipeline.go b/controllers/apps/operations/reconfigure_pipeline.go index 759e320e203..a83fb733e0a 100644 --- a/controllers/apps/operations/reconfigure_pipeline.go +++ b/controllers/apps/operations/reconfigure_pipeline.go @@ -134,6 +134,7 @@ func (p *pipeline) doMergeImpl(parameters appsv1alpha1.ConfigurationItem) error } filter := validate.WithKeySelector(configSpec.Keys) for _, key := range parameters.Keys { + // patch parameters if configSpec.ConfigConstraintRef != "" && filter(key.Key) { if key.FileContent != "" { return cfgcore.MakeError("not allowed to update file content: %s", key.Key) @@ -145,10 +146,12 @@ func (p *pipeline) doMergeImpl(parameters appsv1alpha1.ConfigurationItem) error }) continue } + // update file content if len(key.Parameters) != 0 { return cfgcore.MakeError("not allowed to patch parameters: %s", key.Key) } updateFileContent(item, key.Key, key.FileContent) + p.isFileUpdated = true } p.updatedObject = newConfigObj return p.createUpdatePatch(item, configSpec) diff --git a/controllers/apps/operations/reconfigure_pipeline_test.go b/controllers/apps/operations/reconfigure_pipeline_test.go index 5640602cdd3..96a1010275c 100644 --- a/controllers/apps/operations/reconfigure_pipeline_test.go +++ b/controllers/apps/operations/reconfigure_pipeline_test.go @@ -218,6 +218,8 @@ mysqld.innodb_autoinc_lock_mode: conflicting values 2 and 100: // r := updateConfigConfigmapResource(updatedCfg, tpl, client.ObjectKeyFromObject(cmObj), ctx, k8sMockClient.Client(), "test", mockUpdate) r := testUpdateConfigConfigmapResource(reqCtx, k8sMockClient.Client(), opsRes, updatedCfg, clusterName, componentName) Expect(r.err).Should(Succeed()) + Expect(r.noFormatFilesUpdated).Should(BeFalse()) + Expect(r.configPatch).ShouldNot(BeNil()) diff := r.configPatch Expect(diff.IsModify).Should(BeTrue()) Expect(diff.UpdateConfig["my.cnf"]).Should(BeEquivalentTo(diffCfg)) @@ -265,6 +267,8 @@ z2=y2 // r := updateConfigConfigmapResource(updatedFiles, tpl, client.ObjectKeyFromObject(cmObj), ctx, k8sMockClient.Client(), "test", mockUpdate) r := testUpdateConfigConfigmapResource(reqCtx, k8sMockClient.Client(), opsRes, updatedFiles, clusterName, componentName) Expect(r.err).Should(Succeed()) + Expect(r.configPatch).Should(BeNil()) + Expect(r.noFormatFilesUpdated).Should(BeTrue()) } By("normal file update without configSpec keys") diff --git a/controllers/apps/operations/reconfigure_util.go b/controllers/apps/operations/reconfigure_util.go index 6647b70714f..dafdc876b70 100644 --- a/controllers/apps/operations/reconfigure_util.go +++ b/controllers/apps/operations/reconfigure_util.go @@ -245,7 +245,7 @@ func makeReconfiguringResult(err error, ops ...func(*reconfiguringResult)) recon } func constructReconfiguringConditions(result reconfiguringResult, resource *OpsResource, configSpec *appsv1alpha1.ComponentConfigSpec) *metav1.Condition { - if result.noFormatFilesUpdated || result.configPatch.IsModify { + if result.noFormatFilesUpdated || (result.configPatch != nil && result.configPatch.IsModify) { return appsv1alpha1.NewReconfigureRunningCondition( resource.OpsRequest, appsv1alpha1.ReasonReconfigurePersisted, diff --git a/pkg/controllerutil/util.go b/pkg/controllerutil/util.go index 83931704470..839eab01425 100644 --- a/pkg/controllerutil/util.go +++ b/pkg/controllerutil/util.go @@ -57,6 +57,7 @@ func GetUncachedObjects() []client.Object { &corev1.ConfigMap{}, &corev1.Secret{}, &appsv1alpha1.Cluster{}, + &appsv1alpha1.Configuration{}, } }