Skip to content

Commit 8b8e205

Browse files
committed
Make CloudControllerManagerState immutable in spec
and mirror CloudControllerManagerState into the PlatformStatus
1 parent 269ad52 commit 8b8e205

4 files changed

Lines changed: 82 additions & 1 deletion

config/v1/0000_10_config-operator_01_infrastructure-Default.crd.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,12 +83,16 @@ spec:
8383
description: CloudControllerManager contains settings specific to the external Cloud Controller Manager (a.k.a. CCM or CPI)
8484
properties:
8585
state:
86+
default: ""
8687
description: "state determines whether or not an external Cloud Controller Manager is expected to be installed within the cluster. https://kubernetes.io/docs/tasks/administer-cluster/running-cloud-controller/#running-cloud-controller-manager \n When set to \"External\", new nodes will be tainted as uninitialized when created, preventing them from running workloads until they are initialized by the cloud controller manager. When omitted or set to \"None\", new nodes will be not tainted and no extra initialization from the cloud controller manager is expected."
8788
enum:
8889
- ""
8990
- External
9091
- None
9192
type: string
93+
x-kubernetes-validations:
94+
- message: cloud controller state cannot be changed once set
95+
rule: (oldSelf == '' && self == 'None') || self == oldSelf
9296
type: object
9397
platformName:
9498
default: Unknown

config/v1/0000_10_config-operator_01_infrastructure-TechPreviewNoUpgrade.crd.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,12 +83,16 @@ spec:
8383
description: CloudControllerManager contains settings specific to the external Cloud Controller Manager (a.k.a. CCM or CPI)
8484
properties:
8585
state:
86+
default: ""
8687
description: "state determines whether or not an external Cloud Controller Manager is expected to be installed within the cluster. https://kubernetes.io/docs/tasks/administer-cluster/running-cloud-controller/#running-cloud-controller-manager \n When set to \"External\", new nodes will be tainted as uninitialized when created, preventing them from running workloads until they are initialized by the cloud controller manager. When omitted or set to \"None\", new nodes will be not tainted and no extra initialization from the cloud controller manager is expected."
8788
enum:
8889
- ""
8990
- External
9091
- None
9192
type: string
93+
x-kubernetes-validations:
94+
- message: cloud controller state cannot be changed once set
95+
rule: (oldSelf == '' && self == 'None') || self == oldSelf
9296
type: object
9397
platformName:
9498
default: Unknown

config/v1/stable.infrastructure.testsuite.yaml

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,55 @@ tests:
5656
external:
5757
platformName: SomeOtherCoolplatformName
5858
expectedError: " spec.platformSpec.external.platformName: Invalid value: \"string\": platform name cannot be changed once set"
59+
- name: Should not be able to change External cloudControllerManager state once it was set
60+
initial: |
61+
apiVersion: config.openshift.io/v1
62+
kind: Infrastructure
63+
spec:
64+
platformSpec:
65+
type: External
66+
external:
67+
cloudControllerManager:
68+
state: ""
69+
updated: |
70+
apiVersion: config.openshift.io/v1
71+
kind: Infrastructure
72+
spec:
73+
platformSpec:
74+
type: External
75+
external:
76+
cloudControllerManager:
77+
state: External
78+
expectedError: " spec.platformSpec.external.cloudControllerManager.state: Invalid value: \"string\": cloud controller state cannot be changed once set"
79+
- name: Should be able to change External cloudControllerManager state from "" to "None"
80+
initial: |
81+
apiVersion: config.openshift.io/v1
82+
kind: Infrastructure
83+
spec:
84+
platformSpec:
85+
type: External
86+
external:
87+
cloudControllerManager:
88+
state: ""
89+
updated: |
90+
apiVersion: config.openshift.io/v1
91+
kind: Infrastructure
92+
spec:
93+
platformSpec:
94+
type: External
95+
external:
96+
cloudControllerManager:
97+
state: None
98+
expected: |
99+
apiVersion: config.openshift.io/v1
100+
kind: Infrastructure
101+
spec:
102+
platformSpec:
103+
type: External
104+
external:
105+
cloudControllerManager:
106+
state: None
107+
platformName: Unknown
59108
- name: Should not be able to modify an existing Azure ResourceTags Tag
60109
initial: |
61110
apiVersion: config.openshift.io/v1

config/v1/types_infrastructure.go

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,10 @@ type CloudControllerManagerSpec struct {
255255
// preventing them from running workloads until they are initialized by the cloud controller manager.
256256
// When omitted or set to "None", new nodes will be not tainted
257257
// and no extra initialization from the cloud controller manager is expected.
258+
// +kubebuilder:default:=""
259+
// +default=""
258260
// +kubebuilder:validation:Enum="";External;None
261+
// +kubebuilder:validation:XValidation:rule="(oldSelf == '' && self == 'None') || self == oldSelf",message="cloud controller state cannot be changed once set"
259262
// +optional
260263
State CloudControllerManagerState `json:"state"`
261264
}
@@ -348,8 +351,29 @@ type PlatformSpec struct {
348351
External *ExternalPlatformSpec `json:"external,omitempty"`
349352
}
350353

354+
// CloudControllerManagerStatus holds the state of Cloud Controller Manager (a.k.a. CCM or CPI) related settings
355+
type CloudControllerManagerStatus struct {
356+
// state determines whether or not an external Cloud Controller Manager is expected to
357+
// be installed within the cluster.
358+
// https://kubernetes.io/docs/tasks/administer-cluster/running-cloud-controller/#running-cloud-controller-manager
359+
//
360+
// When set to "External", new nodes will be tainted as uninitialized when created,
361+
// preventing them from running workloads until they are initialized by the cloud controller manager.
362+
// When omitted or set to "None", new nodes will be not tainted
363+
// and no extra initialization from the cloud controller manager is expected.
364+
// +kubebuilder:default:=""
365+
// +default=""
366+
// +kubebuilder:validation:Enum="";External;None
367+
// +optional
368+
State CloudControllerManagerState `json:"state"`
369+
}
370+
351371
// ExternalPlatformStatus holds the current status of the generic External infrastructure provider.
352-
type ExternalPlatformStatus struct{}
372+
type ExternalPlatformStatus struct {
373+
// CloudControllerManager contains settings specific to the external Cloud Controller Manager (a.k.a. CCM or CPI)
374+
// +optional
375+
CloudControllerManager CloudControllerManagerStatus `json:"cloudControllerManager"`
376+
}
353377

354378
// PlatformStatus holds the current status specific to the underlying infrastructure provider
355379
// of the current cluster. Since these are used at status-level for the underlying cluster, it

0 commit comments

Comments
 (0)