Skip to content

Commit

Permalink
fix: validate the topology as immutable (#8894)
Browse files Browse the repository at this point in the history
(cherry picked from commit da8c324)
  • Loading branch information
leon-inf committed Feb 7, 2025
1 parent f8de547 commit d0d97c6
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 0 deletions.
2 changes: 2 additions & 0 deletions apis/apps/v1/cluster_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ func init() {
}

// ClusterSpec defines the desired state of Cluster.
// +kubebuilder:validation:XValidation:rule="!has(oldSelf.topology) || has(self.topology)", message="topology is required once set"
type ClusterSpec struct {
// Specifies the name of the ClusterDefinition to use when creating a Cluster.
//
Expand Down Expand Up @@ -122,6 +123,7 @@ type ClusterSpec struct {
// It establishes the initial composition and structure of the Cluster and is intended for one-time configuration.
//
// +kubebuilder:validation:MaxLength=32
// +kubebuilder:validation:XValidation:rule="self == oldSelf",message="topology is immutable"
// +optional
Topology string `json:"topology,omitempty"`

Expand Down
6 changes: 6 additions & 0 deletions config/crd/bases/apps.kubeblocks.io_clusters.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16059,9 +16059,15 @@ spec:
It establishes the initial composition and structure of the Cluster and is intended for one-time configuration.
maxLength: 32
type: string
x-kubernetes-validations:
- message: topology is immutable
rule: self == oldSelf
required:
- terminationPolicy
type: object
x-kubernetes-validations:
- message: topology is required once set
rule: '!has(oldSelf.topology) || has(self.topology)'
status:
description: ClusterStatus defines the observed state of the Cluster.
properties:
Expand Down
6 changes: 6 additions & 0 deletions deploy/helm/crds/apps.kubeblocks.io_clusters.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16059,9 +16059,15 @@ spec:
It establishes the initial composition and structure of the Cluster and is intended for one-time configuration.
maxLength: 32
type: string
x-kubernetes-validations:
- message: topology is immutable
rule: self == oldSelf
required:
- terminationPolicy
type: object
x-kubernetes-validations:
- message: topology is required once set
rule: '!has(oldSelf.topology) || has(self.topology)'
status:
description: ClusterStatus defines the observed state of the Cluster.
properties:
Expand Down

0 comments on commit d0d97c6

Please sign in to comment.