Skip to content

Commit 55ae87c

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

8 files changed

Lines changed: 188 additions & 3 deletions

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

Lines changed: 17 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
@@ -603,6 +607,19 @@ spec:
603607
type: object
604608
external:
605609
description: External contains settings specific to the generic External infrastructure provider.
610+
properties:
611+
cloudControllerManager:
612+
description: CloudControllerManager contains settings specific to the external Cloud Controller Manager (a.k.a. CCM or CPI)
613+
properties:
614+
state:
615+
default: ""
616+
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."
617+
enum:
618+
- ""
619+
- External
620+
- None
621+
type: string
622+
type: object
606623
type: object
607624
gcp:
608625
description: GCP contains settings specific to the Google Cloud Platform infrastructure provider.

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

Lines changed: 17 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
@@ -626,6 +630,19 @@ spec:
626630
type: object
627631
external:
628632
description: External contains settings specific to the generic External infrastructure provider.
633+
properties:
634+
cloudControllerManager:
635+
description: CloudControllerManager contains settings specific to the external Cloud Controller Manager (a.k.a. CCM or CPI)
636+
properties:
637+
state:
638+
default: ""
639+
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."
640+
enum:
641+
- ""
642+
- External
643+
- None
644+
type: string
645+
type: object
629646
type: object
630647
gcp:
631648
description: GCP contains settings specific to the Google Cloud Platform infrastructure provider.

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

config/v1/zz_generated.deepcopy.go

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

config/v1/zz_generated.swagger_doc_generated.go

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

openapi/generated_openapi/zz_generated.openapi.go

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

openapi/openapi.json

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4902,6 +4902,17 @@
49024902
}
49034903
}
49044904
},
4905+
"com.github.openshift.api.config.v1.CloudControllerManagerStatus": {
4906+
"description": "CloudControllerManagerStatus holds the state of Cloud Controller Manager (a.k.a. CCM or CPI) related settings",
4907+
"type": "object",
4908+
"properties": {
4909+
"state": {
4910+
"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\nWhen 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.",
4911+
"type": "string",
4912+
"default": ""
4913+
}
4914+
}
4915+
},
49054916
"com.github.openshift.api.config.v1.ClusterCondition": {
49064917
"description": "ClusterCondition is a union of typed cluster conditions. The 'type' property determines which of the type-specific properties are relevant. When evaluated on a cluster, the condition may match, not match, or fail to evaluate.",
49074918
"type": "object",
@@ -5956,7 +5967,14 @@
59565967
},
59575968
"com.github.openshift.api.config.v1.ExternalPlatformStatus": {
59585969
"description": "ExternalPlatformStatus holds the current status of the generic External infrastructure provider.",
5959-
"type": "object"
5970+
"type": "object",
5971+
"properties": {
5972+
"cloudControllerManager": {
5973+
"description": "CloudControllerManager contains settings specific to the external Cloud Controller Manager (a.k.a. CCM or CPI)",
5974+
"default": {},
5975+
"$ref": "#/definitions/com.github.openshift.api.config.v1.CloudControllerManagerStatus"
5976+
}
5977+
}
59605978
},
59615979
"com.github.openshift.api.config.v1.FeatureGate": {
59625980
"description": "Feature holds cluster-wide information about feature gates. The canonical name is `cluster`\n\nCompatibility level 1: Stable within a major release for a minimum of 12 months or 3 minor releases (whichever is longer).",

0 commit comments

Comments
 (0)