Skip to content

Commit d5f8fb8

Browse files
leon-apeclaude
andauthored
feat(apis): enhance API for config manager migration to kbagent (#10016)
Co-authored-by: Claude <noreply@anthropic.com>
1 parent 6ad4438 commit d5f8fb8

22 files changed

Lines changed: 4967 additions & 164 deletions

apis/apps/v1/componentdefinition_types.go

Lines changed: 24 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1106,16 +1106,35 @@ type ComponentFileTemplate struct {
11061106
// +optional
11071107
DefaultMode *int32 `json:"defaultMode,omitempty"`
11081108

1109-
// ExternalManaged indicates whether the configuration is managed by an external system.
1110-
// When set to true, the controller will ignore the management of this configuration.
1109+
// Specifies whether to restart the workload when the file changes.
11111110
//
11121111
// +optional
1113-
ExternalManaged *bool `json:"externalManaged,omitempty"`
1112+
RestartOnFileChange *bool `json:"restartOnFileChange,omitempty"`
11141113

1115-
// Specifies whether to restart the pod when the file changes.
1114+
// Defines the procedure that reloads the file when it's content changes.
1115+
//
1116+
// If specified, this action overrides the global reconfigure action defined in lifecycle actions
1117+
// for this specific file template.
1118+
//
1119+
// When @restartOnFileChange is set to true, this action will be ignored.
1120+
//
1121+
// The container executing this action has access to following variables:
1122+
//
1123+
// - KB_CONFIG_FILES_CREATED: file1,file2...
1124+
// - KB_CONFIG_FILES_REMOVED: file1,file2...
1125+
// - KB_CONFIG_FILES_UPDATED: file1:checksum1,file2:checksum2...
1126+
//
1127+
// Note: This field is immutable once it has been set.
11161128
//
11171129
// +optional
1118-
RestartOnFileChange *bool `json:"restartOnFileChange,omitempty"`
1130+
Reconfigure *Action `json:"reconfigure,omitempty"`
1131+
1132+
// ExternalManaged specifies whether the file management is delegated to an external system or manual user control.
1133+
//
1134+
// When set to true, the controller will ignore the management of this file.
1135+
//
1136+
// +optional
1137+
ExternalManaged *bool `json:"externalManaged,omitempty"`
11191138
}
11201139

11211140
type LogConfig struct {
@@ -1693,8 +1712,6 @@ type ComponentLifecycleActions struct {
16931712
//
16941713
// Note: This field is immutable once it has been set.
16951714
//
1696-
// This Action is reserved for future versions.
1697-
//
16981715
// +optional
16991716
Reconfigure *Action `json:"reconfigure,omitempty"`
17001717

apis/apps/v1/deprecated.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,18 +50,18 @@ func (r *Cluster) GetComponentByName(componentName string) *ClusterComponentSpec
5050
}
5151

5252
func (r *ClusterSpec) GetComponentByName(componentName string) *ClusterComponentSpec {
53-
for _, v := range r.ComponentSpecs {
53+
for i, v := range r.ComponentSpecs {
5454
if v.Name == componentName {
55-
return &v
55+
return &r.ComponentSpecs[i]
5656
}
5757
}
5858
return nil
5959
}
6060

6161
func (r *ClusterSpec) GetShardingByName(shardingName string) *ClusterSharding {
62-
for _, v := range r.Shardings {
62+
for i, v := range r.Shardings {
6363
if v.Name == shardingName {
64-
return &v
64+
return &r.Shardings[i]
6565
}
6666
}
6767
return nil

apis/apps/v1/types.go

Lines changed: 26 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -529,25 +529,41 @@ type ClusterComponentConfig struct {
529529
// The external source for the configuration.
530530
ClusterComponentConfigSource `json:",inline"`
531531

532-
// The custom reconfigure action to reload the service configuration whenever changes to this config are detected.
532+
// ExternalManaged specifies whether the configuration management is delegated to an external system
533+
// or manual user control.
534+
//
535+
// When set to true, the controller will exclusively utilize the user-provided configuration source
536+
// and the 'reconfigure' action defined in this config, bypassing the default templates and
537+
// update behaviors specified in the ComponentDefinition.
538+
//
539+
// +optional
540+
ExternalManaged *bool `json:"externalManaged,omitempty"`
541+
542+
// Represents a checksum or hash of the configuration content.
543+
//
544+
// The controller uses this value to detect changes and determine if a reconfiguration or restart
545+
// is necessary to apply updates.
546+
//
547+
// +optional
548+
ConfigHash *string `json:"configHash,omitempty"`
549+
550+
// Specifies whether to restart the component to reload the updated configuration.
551+
//
552+
// +optional
553+
RestartOnConfigChange *bool `json:"restartOnConfigChange,omitempty"`
554+
555+
// The custom reconfigure action to reload the updated configuration.
556+
//
557+
// When @restartOnConfigChange is set to true, this action will be ignored.
533558
//
534559
// The container executing this action has access to following variables:
535560
//
536561
// - KB_CONFIG_FILES_CREATED: file1,file2...
537562
// - KB_CONFIG_FILES_REMOVED: file1,file2...
538563
// - KB_CONFIG_FILES_UPDATED: file1:checksum1,file2:checksum2...
539564
//
540-
// Note: This field is immutable once it has been set.
541-
//
542565
// +optional
543566
Reconfigure *Action `json:"reconfigure,omitempty"`
544-
545-
// ExternalManaged indicates whether the configuration is managed by an external system.
546-
// When set to true, the controller will use the user-provided template and reconfigure action,
547-
// ignoring the default template and update behavior.
548-
//
549-
// +optional
550-
ExternalManaged *bool `json:"externalManaged,omitempty"`
551567
}
552568

553569
// ClusterComponentConfigSource represents the source of a configuration for a component.

apis/apps/v1/zz_generated.deepcopy.go

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

apis/parameters/v1alpha1/types.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ type ParametersInFile struct {
167167

168168
// ReloadPolicy defines the policy of reconfiguring.
169169
// +enum
170-
// +kubebuilder:validation:Enum={none,restart,rolling,asyncReload,syncReload,dynamicReloadBeginRestart}
170+
// +kubebuilder:validation:Enum={none,restart,asyncReload,syncReload,dynamicReloadBeginRestart}
171171
type ReloadPolicy string
172172

173173
const (

apis/workloads/v1/instanceset_types.go

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -517,7 +517,7 @@ type LifecycleActions struct {
517517
// +optional
518518
Switchover *Action `json:"switchover,omitempty"`
519519

520-
// Defines the procedure that update a replica with new configuration.
520+
// Defines the procedure that update replicas with new configuration.
521521
//
522522
// +optional
523523
Reconfigure *Action `json:"reconfigure,omitempty"`
@@ -527,8 +527,15 @@ type ConfigTemplate struct {
527527
// The name of the config.
528528
Name string `json:"name"`
529529

530-
// The generation of the config.
531-
Generation int64 `json:"generation"`
530+
// The generation of the config content.
531+
//
532+
// +optional
533+
Generation int64 `json:"generation,omitempty"`
534+
535+
// Represents a checksum or hash of the config content.
536+
//
537+
// +optional
538+
ConfigHash *string `json:"configHash,omitempty"`
532539

533540
// The custom reconfigure action.
534541
//
@@ -579,8 +586,13 @@ type InstanceConfigStatus struct {
579586

580587
// The generation of the config.
581588
//
582-
// +kubebuilder:validation:Required
583-
Generation int64 `json:"generation"`
589+
// +optional
590+
Generation int64 `json:"generation,omitempty"`
591+
592+
// Represents a checksum or hash of the config content.
593+
//
594+
// +optional
595+
ConfigHash *string `json:"configHash,omitempty"`
584596
}
585597

586598
// 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: 46 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,14 @@ 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+
221+
222+
The controller uses this value to detect changes and determine if a reconfiguration or restart
223+
is necessary to apply updates.
224+
type: string
217225
configMap:
218226
description: ConfigMap source for the config.
219227
properties:
@@ -280,9 +288,13 @@ spec:
280288
x-kubernetes-map-type: atomic
281289
externalManaged:
282290
description: |-
283-
ExternalManaged indicates whether the configuration is managed by an external system.
284-
When set to true, the controller will use the user-provided template and reconfigure action,
285-
ignoring the default template and update behavior.
291+
ExternalManaged specifies whether the configuration management is delegated to an external system
292+
or manual user control.
293+
294+
295+
When set to true, the controller will exclusively utilize the user-provided configuration source
296+
and the 'reconfigure' action defined in this config, bypassing the default templates and
297+
update behaviors specified in the ComponentDefinition.
286298
type: boolean
287299
name:
288300
description: The name of the config.
@@ -291,7 +303,10 @@ spec:
291303
type: string
292304
reconfigure:
293305
description: |-
294-
The custom reconfigure action to reload the service configuration whenever changes to this config are detected.
306+
The custom reconfigure action to reload the updated configuration.
307+
308+
309+
When @restartOnConfigChange is set to true, this action will be ignored.
295310

296311

297312
The container executing this action has access to following variables:
@@ -300,9 +315,6 @@ spec:
300315
- KB_CONFIG_FILES_CREATED: file1,file2...
301316
- KB_CONFIG_FILES_REMOVED: file1,file2...
302317
- KB_CONFIG_FILES_UPDATED: file1:checksum1,file2:checksum2...
303-
304-
305-
Note: This field is immutable once it has been set.
306318
properties:
307319
exec:
308320
description: |-
@@ -739,6 +751,10 @@ spec:
739751
format: int32
740752
type: integer
741753
type: object
754+
restartOnConfigChange:
755+
description: Specifies whether to restart the component
756+
to reload the updated configuration.
757+
type: boolean
742758
variables:
743759
additionalProperties:
744760
type: string
@@ -11546,6 +11562,14 @@ spec:
1154611562
description: ClusterComponentConfig represents a configuration
1154711563
for a component.
1154811564
properties:
11565+
configHash:
11566+
description: |-
11567+
Represents a checksum or hash of the configuration content.
11568+
11569+
11570+
The controller uses this value to detect changes and determine if a reconfiguration or restart
11571+
is necessary to apply updates.
11572+
type: string
1154911573
configMap:
1155011574
description: ConfigMap source for the config.
1155111575
properties:
@@ -11612,9 +11636,13 @@ spec:
1161211636
x-kubernetes-map-type: atomic
1161311637
externalManaged:
1161411638
description: |-
11615-
ExternalManaged indicates whether the configuration is managed by an external system.
11616-
When set to true, the controller will use the user-provided template and reconfigure action,
11617-
ignoring the default template and update behavior.
11639+
ExternalManaged specifies whether the configuration management is delegated to an external system
11640+
or manual user control.
11641+
11642+
11643+
When set to true, the controller will exclusively utilize the user-provided configuration source
11644+
and the 'reconfigure' action defined in this config, bypassing the default templates and
11645+
update behaviors specified in the ComponentDefinition.
1161811646
type: boolean
1161911647
name:
1162011648
description: The name of the config.
@@ -11623,7 +11651,10 @@ spec:
1162311651
type: string
1162411652
reconfigure:
1162511653
description: |-
11626-
The custom reconfigure action to reload the service configuration whenever changes to this config are detected.
11654+
The custom reconfigure action to reload the updated configuration.
11655+
11656+
11657+
When @restartOnConfigChange is set to true, this action will be ignored.
1162711658

1162811659

1162911660
The container executing this action has access to following variables:
@@ -11632,9 +11663,6 @@ spec:
1163211663
- KB_CONFIG_FILES_CREATED: file1,file2...
1163311664
- KB_CONFIG_FILES_REMOVED: file1,file2...
1163411665
- KB_CONFIG_FILES_UPDATED: file1:checksum1,file2:checksum2...
11635-
11636-
11637-
Note: This field is immutable once it has been set.
1163811666
properties:
1163911667
exec:
1164011668
description: |-
@@ -12075,6 +12103,10 @@ spec:
1207512103
format: int32
1207612104
type: integer
1207712105
type: object
12106+
restartOnConfigChange:
12107+
description: Specifies whether to restart the component
12108+
to reload the updated configuration.
12109+
type: boolean
1207812110
variables:
1207912111
additionalProperties:
1208012112
type: string

0 commit comments

Comments
 (0)