Repository navigation
fix: reconfig error Upgrade KubeBlocks dependency to v1.2 #688
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -29,7 +29,6 @@ import ( | |
| "github.com/apecloud/kubeblocks/pkg/client/clientset/versioned" | ||
| "github.com/apecloud/kubeblocks/pkg/generics" | ||
| configctrl "github.com/apecloud/kubeblocks/pkg/parameters" | ||
| cfgcm "github.com/apecloud/kubeblocks/pkg/parameters/configmanager" | ||
| "github.com/apecloud/kubeblocks/pkg/parameters/core" | ||
| "github.com/spf13/cobra" | ||
| "k8s.io/cli-runtime/pkg/genericiooptions" | ||
|
|
@@ -137,7 +136,7 @@ func (o *configOpsOptions) Validate() error { | |
| return err | ||
| } | ||
|
|
||
| classifyParams, err := configctrl.ClassifyComponentParameters(o.KeyValues, rctx.ParametersDefs, rctx.Cmpd.Spec.Configs, tplObjs, rctx.ConfigRender) | ||
| classifyParams, err := configctrl.ClassifyComponentParameters(o.KeyValues, rctx.ParametersDefs, rctx.Cmpd.Spec.Configs, tplObjs, configDescriptions(rctx)) | ||
| if err != nil { | ||
| return err | ||
| } | ||
|
|
@@ -161,7 +160,7 @@ func (o *configOpsOptions) validateConfigParams(rctx *ReconfigureContext, classi | |
| checkRestart := func(params map[string]*parametersv1alpha1.ParametersInFile) bool { | ||
| for file := range params { | ||
| match := func(pd *parametersv1alpha1.ParametersDefinition) bool { | ||
| return pd.Spec.FileName == file && cfgcm.IsSupportReload(pd.Spec.ReloadAction) | ||
| return pd.Spec.FileName == file && supportsDynamicReload(&pd.Spec) | ||
| } | ||
| if generics.FindFirstFunc(rctx.ParametersDefs, match) < 0 { | ||
| return true | ||
|
|
@@ -173,7 +172,7 @@ func (o *configOpsOptions) validateConfigParams(rctx *ReconfigureContext, classi | |
| transform := func(params map[string]*parametersv1alpha1.ParametersInFile) []core.ParamPairs { | ||
| var result []core.ParamPairs | ||
| for file, ps := range params { | ||
| configDescs := configctrl.GetComponentConfigDescriptions(&rctx.ConfigRender.Spec, file) | ||
| configDescs := configctrl.GetComponentConfigDescriptions(configDescriptions(rctx), file) | ||
| builder := configctrl.NewValueManager(rctx.ParametersDefs, configDescs) | ||
| updatedParams, _ := core.FromStringMap(ps.Parameters, builder.BuildValueTransformer(file)) | ||
| result = append(result, core.ParamPairs{ | ||
|
|
@@ -186,7 +185,7 @@ func (o *configOpsOptions) validateConfigParams(rctx *ReconfigureContext, classi | |
|
|
||
| restart := false | ||
| for _, parameters := range classifyParameters { | ||
| _, err := configctrl.MergeAndValidateConfigs(mockEmptyData(parameters), transform(parameters), rctx.ParametersDefs, rctx.ConfigRender.Spec.Configs) | ||
| _, err := configctrl.MergeAndValidateConfigs(mockEmptyData(parameters), transform(parameters), rctx.ParametersDefs, configDescriptions(rctx)) | ||
| if err != nil { | ||
| return err | ||
| } | ||
|
|
@@ -209,6 +208,16 @@ func mockEmptyData(m map[string]*parametersv1alpha1.ParametersInFile) map[string | |
| return r | ||
| } | ||
|
|
||
| func supportsDynamicReload(pd *parametersv1alpha1.ParametersDefinitionSpec) bool { | ||
| if pd == nil { | ||
| return false | ||
| } | ||
| if configctrl.NeedDynamicReloadAction(pd) { | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [P1] This treats mergeReloadAndRestart=false as evidence that the file can be dynamically reloaded, but the controller does not use that field as the reload capability gate. v1.2 reload is allowed when the matched ComponentFileTemplate.reconfigure exists, or for legacy definitions when spec.reloadAction is valid. With the current check, a ParametersDefinition that only sets mergeReloadAndRestart=false skips kbcli restart confirmation even though the controller falls back to restart; conversely a v1.2 addon using template reconfigure without deprecated reloadAction still gets a restart warning. Please derive the prompt from the matched config template plus legacy reloadAction, not from NeedDynamicReloadAction alone. |
||
| return true | ||
| } | ||
| return pd.ReloadAction != nil && (pd.ReloadAction.AutoTrigger != nil || pd.ReloadAction.ShellTrigger != nil) | ||
| } | ||
|
|
||
| func fromStringPointerMap(m map[string]string) map[string]*string { | ||
| r := make(map[string]*string, len(m)) | ||
| for key, value := range m { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[P2] GetComponentConfigDescriptions now filters by ComponentConfigDescription.TemplateName, but file here is the config file name from map[file]ParametersInFile. For normal PCR entries such as templateName=mysql-config and name=my.cnf, this returns an empty slice, so NewValueManager cannot apply the matched file format transformer before FromStringMap. JSON/YAML/TOML numeric or boolean parameters can then be validated or rendered as strings instead of their schema types. Keep the outer template name from classifyParameters and pass that to this helper.