Skip to content

Commit 3a2bd3a

Browse files
committed
rename config hash
1 parent e28690f commit 3a2bd3a

19 files changed

+124
-83
lines changed

apis/apps/v1/types.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -536,10 +536,12 @@ type ClusterComponentConfig struct {
536536
// +optional
537537
ExternalManaged *bool `json:"externalManaged,omitempty"`
538538

539-
// The versioned hash of the config content.
539+
// Represents a checksum or hash of the configuration content.
540+
// The controller uses this value to detect changes and determine if a reconfiguration or restart
541+
// is necessary to apply updates.
540542
//
541543
// +optional
542-
VersionHash string `json:"versionHash,omitempty"`
544+
ConfigHash *string `json:"configHash,omitempty"`
543545

544546
// The custom reconfigure action to reload the updated configuration.
545547
//

apis/apps/v1/zz_generated.deepcopy.go

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

apis/workloads/v1/instanceset_types.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -519,10 +519,10 @@ type ConfigTemplate struct {
519519
// +optional
520520
Generation int64 `json:"generation,omitempty"`
521521

522-
// The versioned hash of the config content.
522+
// Represents a checksum or hash of the config content.
523523
//
524524
// +optional
525-
VersionHash string `json:"versionHash,omitempty"`
525+
ConfigHash *string `json:"configHash,omitempty"`
526526

527527
// The custom reconfigure action.
528528
//
@@ -576,10 +576,10 @@ type InstanceConfigStatus struct {
576576
// +optional
577577
Generation int64 `json:"generation,omitempty"`
578578

579-
// The hash of the config content.
579+
// Represents a checksum or hash of the config content.
580580
//
581581
// +optional
582-
VersionHash string `json:"versionHash,omitempty"`
582+
ConfigHash *string `json:"configHash,omitempty"`
583583
}
584584

585585
// InstanceTemplateStatus aggregates the status of replicas for each InstanceTemplate

apis/workloads/v1/zz_generated.deepcopy.go

Lines changed: 13 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

config/crd/bases/apps.kubeblocks.io_clusters.yaml

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,12 @@ spec:
214214
description: ClusterComponentConfig represents a configuration
215215
for a component.
216216
properties:
217+
configHash:
218+
description: |-
219+
Represents a checksum or hash of the configuration content.
220+
The controller uses this value to detect changes and determine if a reconfiguration or restart
221+
is necessary to apply updates.
222+
type: string
217223
configMap:
218224
description: ConfigMap source for the config.
219225
properties:
@@ -746,9 +752,6 @@ spec:
746752
description: Variables are key-value pairs for dynamic
747753
configuration values that can be provided by the user.
748754
type: object
749-
versionHash:
750-
description: The versioned hash of the config content.
751-
type: string
752755
type: object
753756
type: array
754757
disableExporter:
@@ -11550,6 +11553,12 @@ spec:
1155011553
description: ClusterComponentConfig represents a configuration
1155111554
for a component.
1155211555
properties:
11556+
configHash:
11557+
description: |-
11558+
Represents a checksum or hash of the configuration content.
11559+
The controller uses this value to detect changes and determine if a reconfiguration or restart
11560+
is necessary to apply updates.
11561+
type: string
1155311562
configMap:
1155411563
description: ConfigMap source for the config.
1155511564
properties:
@@ -12087,9 +12096,6 @@ spec:
1208712096
configuration values that can be provided by the
1208812097
user.
1208912098
type: object
12090-
versionHash:
12091-
description: The versioned hash of the config content.
12092-
type: string
1209312099
type: object
1209412100
type: array
1209512101
disableExporter:

config/crd/bases/apps.kubeblocks.io_components.yaml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,12 @@ spec:
9090
description: ClusterComponentConfig represents a configuration for
9191
a component.
9292
properties:
93+
configHash:
94+
description: |-
95+
Represents a checksum or hash of the configuration content.
96+
The controller uses this value to detect changes and determine if a reconfiguration or restart
97+
is necessary to apply updates.
98+
type: string
9399
configMap:
94100
description: ConfigMap source for the config.
95101
properties:
@@ -617,9 +623,6 @@ spec:
617623
description: Variables are key-value pairs for dynamic configuration
618624
values that can be provided by the user.
619625
type: object
620-
versionHash:
621-
description: The versioned hash of the config content.
622-
type: string
623626
type: object
624627
type: array
625628
customActions:

config/crd/bases/workloads.kubeblocks.io_instancesets.yaml

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,9 @@ spec:
6969
description: Describe the configs to be reconfigured.
7070
items:
7171
properties:
72+
configHash:
73+
description: Represents a checksum or hash of the config content.
74+
type: string
7275
generation:
7376
description: The generation of the config content.
7477
format: int64
@@ -522,9 +525,6 @@ spec:
522525

523526
An empty name indicates that the reconfigure action is the default one defined by lifecycle actions.
524527
type: string
525-
versionHash:
526-
description: The versioned hash of the config content.
527-
type: string
528528
required:
529529
- name
530530
type: object
@@ -11720,16 +11720,17 @@ spec:
1172011720
description: The status of configs.
1172111721
items:
1172211722
properties:
11723+
configHash:
11724+
description: Represents a checksum or hash of the config
11725+
content.
11726+
type: string
1172311727
generation:
1172411728
description: The generation of the config.
1172511729
format: int64
1172611730
type: integer
1172711731
name:
1172811732
description: The name of the config.
1172911733
type: string
11730-
versionHash:
11731-
description: The hash of the config content.
11732-
type: string
1173311734
required:
1173411735
- name
1173511736
type: object

controllers/parameters/componentparameter_controller_test.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import (
2525
. "github.com/onsi/ginkgo/v2"
2626
. "github.com/onsi/gomega"
2727

28+
"k8s.io/utils/ptr"
2829
"sigs.k8s.io/controller-runtime/pkg/client"
2930

3031
parametersv1alpha1 "github.com/apecloud/kubeblocks/apis/parameters/v1alpha1"
@@ -79,8 +80,8 @@ var _ = Describe("ComponentParameter Controller", func() {
7980
PodName: fmt.Sprintf("%s-0", itsKey.Name),
8081
Configs: []workloads.InstanceConfigStatus{
8182
{
82-
Name: configSpecName,
83-
VersionHash: "8665bf6888",
83+
Name: configSpecName,
84+
ConfigHash: ptr.To("8665bf6888"),
8485
},
8586
},
8687
})

controllers/parameters/parameter_controller_test.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ import (
2828
. "github.com/onsi/gomega"
2929

3030
"k8s.io/apimachinery/pkg/types"
31-
"k8s.io/utils/pointer"
31+
"k8s.io/utils/ptr"
3232
"sigs.k8s.io/controller-runtime/pkg/client"
3333

3434
appsv1 "github.com/apecloud/kubeblocks/apis/apps/v1"
@@ -86,12 +86,12 @@ var _ = Describe("Parameter Controller", func() {
8686
if idx == -1 {
8787
its.Status.InstanceStatus[0].Configs = []workloads.InstanceConfigStatus{
8888
{
89-
Name: cfgName,
90-
VersionHash: versionHash,
89+
Name: cfgName,
90+
ConfigHash: ptr.To(versionHash),
9191
},
9292
}
9393
} else {
94-
its.Status.InstanceStatus[0].Configs[idx].VersionHash = versionHash
94+
its.Status.InstanceStatus[0].Configs[idx].ConfigHash = ptr.To(versionHash)
9595
}
9696
})()).Should(Succeed())
9797
}
@@ -126,8 +126,8 @@ var _ = Describe("Parameter Controller", func() {
126126
Eventually(testapps.CheckObj(&testCtx, compParamKey, func(g Gomega, compParameter *parametersv1alpha1.ComponentParameter) {
127127
item := parameters.GetConfigTemplateItem(&compParameter.Spec, configSpecName)
128128
Expect(item).ShouldNot(BeNil())
129-
Expect(item.ConfigFileParams[testparameters.MysqlConfigFile].Parameters).Should(HaveKeyWithValue("max_connections", pointer.String("100")))
130-
Expect(item.ConfigFileParams[testparameters.MysqlConfigFile].Parameters).Should(HaveKeyWithValue("innodb_buffer_pool_size", pointer.String("1024M")))
129+
Expect(item.ConfigFileParams[testparameters.MysqlConfigFile].Parameters).Should(HaveKeyWithValue("max_connections", ptr.To("100")))
130+
Expect(item.ConfigFileParams[testparameters.MysqlConfigFile].Parameters).Should(HaveKeyWithValue("innodb_buffer_pool_size", ptr.To("1024M")))
131131
})).Should(Succeed())
132132

133133
By("the second update parameters")
@@ -150,8 +150,8 @@ var _ = Describe("Parameter Controller", func() {
150150
Eventually(testapps.CheckObj(&testCtx, compParamKey, func(g Gomega, compParameter *parametersv1alpha1.ComponentParameter) {
151151
item := parameters.GetConfigTemplateItem(&compParameter.Spec, configSpecName)
152152
Expect(item).ShouldNot(BeNil())
153-
Expect(item.ConfigFileParams[testparameters.MysqlConfigFile].Parameters).Should(HaveKeyWithValue("max_connections", pointer.String("2000")))
154-
Expect(item.ConfigFileParams[testparameters.MysqlConfigFile].Parameters).Should(HaveKeyWithValue("gtid_mode", pointer.String("OFF")))
153+
Expect(item.ConfigFileParams[testparameters.MysqlConfigFile].Parameters).Should(HaveKeyWithValue("max_connections", ptr.To("2000")))
154+
Expect(item.ConfigFileParams[testparameters.MysqlConfigFile].Parameters).Should(HaveKeyWithValue("gtid_mode", ptr.To("OFF")))
155155
})).Should(Succeed())
156156
})
157157

controllers/parameters/reconfigure_controller.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -363,7 +363,7 @@ func (r *ReconfigureReconciler) buildReloadTask(policy parametersv1alpha1.Reload
363363
RequestCtx: rctx.RequestCtx,
364364
Client: rctx.Client,
365365
ConfigTemplate: *templateSpec,
366-
VersionHash: computeTargetVersionHash(rctx.RequestCtx, rctx.ConfigMap.Data),
366+
ConfigHash: computeTargetConfigHash(rctx.RequestCtx, rctx.ConfigMap.Data),
367367
ParametersDef: &pd.Spec,
368368
ConfigDescription: configDescription,
369369
Cluster: rctx.ClusterObj,
@@ -382,7 +382,7 @@ func (r *ReconfigureReconciler) buildRestartTask(configTemplate *appsv1.Componen
382382
RequestCtx: rctx.RequestCtx,
383383
Client: rctx.Client,
384384
ConfigTemplate: *configTemplate,
385-
VersionHash: computeTargetVersionHash(rctx.RequestCtx, rctx.ConfigMap.Data),
385+
ConfigHash: computeTargetConfigHash(rctx.RequestCtx, rctx.ConfigMap.Data),
386386
ClusterComponent: rctx.ClusterComObj,
387387
Cluster: rctx.ClusterObj,
388388
SynthesizedComponent: rctx.BuiltinComponent,

0 commit comments

Comments
 (0)