Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

Large diffs are not rendered by default.

15 changes: 9 additions & 6 deletions config/v1/types_infrastructure.go
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,9 @@ type ExternalPlatformSpec struct {
// PlatformSpec holds the desired state specific to the underlying infrastructure provider
// of the current cluster. Since these are used at spec-level for the underlying cluster, it
// is supposed that only one of the spec structs is set.
// +kubebuilder:validation:XValidation:rule="!has(oldSelf.vsphere) && has(self.vsphere) ? size(self.vsphere.vcenters) < 2 : true",message="vcenters can have at most 1 item when configured post-install"
// +openshift:validation:FeatureGateAwareXValidation:featureGate="",rule="!has(oldSelf.vsphere) && has(self.vsphere) ? (has(self.vsphere.vcenters) && size(self.vsphere.vcenters) < 2) : true",message="vcenters can have at most 1 item when configured post-install"
// +openshift:validation:FeatureGateAwareXValidation:featureGate=VSphereMultiVCenterDay2,rule="has(oldSelf.vsphere) && has(oldSelf.vsphere.vcenters) ? (has(self.vsphere) && has(self.vsphere.vcenters)) : true",message="vcenters is required once set and cannot be removed"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Functionally equivalent but more succinct

Suggested change
// +openshift:validation:FeatureGateAwareXValidation:featureGate=VSphereMultiVCenterDay2,rule="has(oldSelf.vsphere) && has(oldSelf.vsphere.vcenters) ? (has(self.vsphere) && has(self.vsphere.vcenters)) : true",message="vcenters is required once set and cannot be removed"
// +openshift:validation:FeatureGateAwareXValidation:featureGate=VSphereMultiVCenterDay2,rule="oldSelf.?vsphere.vcenters.hasValue() ? self.?vsphere.vcenters.hasValue() : true",message="vcenters is required once set and cannot be removed"

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll update that.

// +openshift:validation:FeatureGateAwareXValidation:featureGate=VSphereMultiVCenterDay2,rule="!has(oldSelf.vsphere) && has(self.vsphere) && has(self.vsphere.vcenters) ? size(self.vsphere.vcenters) > 0 : true",message="vcenters must have at least 1 item when initially configured"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it be a breaking change to set the vcenters MinItems directly to 1? Rather than having this validation here, I suspect we can make that change, add a test to show that it ratchets, and avoid the CEL

Anyone who has somehow persisted vcenters: [] today has seen no configuration/behavioural difference to their cluster, so I think this will be acceptable. vcenters: [] has no semantic meaning right?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In theory it isn't a breaking change. I think the issue I hit was more of a unit test. I'll make sure that we still catch someone trying to create an empty list.

type PlatformSpec struct {
// type is the underlying infrastructure provider for the cluster. This
// value controls whether infrastructure automation such as service load
Expand Down Expand Up @@ -1641,21 +1643,22 @@ type VSpherePlatformNodeNetworking struct {
// use these fields for configuration.
// +kubebuilder:validation:XValidation:rule="!has(oldSelf.apiServerInternalIPs) || has(self.apiServerInternalIPs)",message="apiServerInternalIPs list is required once set"
// +kubebuilder:validation:XValidation:rule="!has(oldSelf.ingressIPs) || has(self.ingressIPs)",message="ingressIPs list is required once set"
// +kubebuilder:validation:XValidation:rule="!has(oldSelf.vcenters) && has(self.vcenters) ? size(self.vcenters) < 2 : true",message="vcenters can have at most 1 item when configured post-install"
type VSpherePlatformSpec struct {
// vcenters holds the connection details for services to communicate with vCenter.
// Currently, only a single vCenter is supported, but in tech preview 3 vCenters are supported.
// Currently, up to 3 vCenters are supported.
// Once the cluster has been installed, you are unable to change the current number of defined
// vCenters except in the case where the cluster has been upgraded from a version of OpenShift
// where the vsphere platform spec was not present. You may make modifications to the existing
// vCenters except when 1.) the cluster has been upgraded from a version of OpenShift
// where the vsphere platform spec was not present or 2.) in TechPreview you are able to add and
// remove vCenters but may not remove all vCenters. You may make modifications to the existing
// vCenters that are defined in the vcenters list in order to match with any added or modified
// failure domains.
// ---
// + If VCenters is not defined use the existing cloud-config configmap defined
// + in openshift-config.
// +kubebuilder:validation:MinItems=0
// +kubebuilder:validation:MaxItems=3
// +kubebuilder:validation:XValidation:rule="size(self) != size(oldSelf) ? size(oldSelf) == 0 && size(self) < 2 : true",message="vcenters cannot be added or removed once set"
// +openshift:validation:FeatureGateAwareXValidation:featureGate="",rule="size(self) != size(oldSelf) ? size(oldSelf) == 0 && size(self) < 2 : true",message="vcenters cannot be added or removed once set"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I completely change the configuration of the vcenter, but keep the number the same, is that ok? Effectively like adding an item to the list, then removing the old item, but in one transaction?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interesting. that would be be ok now going forward since we'll be cleaning up older configs from the cloud config via the other PRs; however, the older releases this would not be allowed. Its the configuration of vcenters in the ini / yaml file that we are protecting. Older cluster installs (before multi vcenter was introduced) had ini files and that only allowed 1 vcenter. Newer installs now leverage YAML cloud config and we can configure more than 1. So even replacing the existing one w/ a new one will invalidate the INI file and cluster will be in bad shape.

// +openshift:validation:FeatureGateAwareXValidation:featureGate=VSphereMultiVCenterDay2,rule="size(self) != size(oldSelf) ? size(self) > 0 : true",message="vcenters must have at least 1 item"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can avoid this if we just make MinItems 1 right?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep. the response message will change due to using basic validation, but that shouldn't be an issue. I"ll update the unit tests.

// +listType=atomic
// +optional
VCenters []VSpherePlatformVCenterSpec `json:"vcenters,omitempty"`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1031,10 +1031,11 @@ spec:
vcenters:
description: |-
vcenters holds the connection details for services to communicate with vCenter.
Currently, only a single vCenter is supported, but in tech preview 3 vCenters are supported.
Currently, up to 3 vCenters are supported.
Once the cluster has been installed, you are unable to change the current number of defined
vCenters except in the case where the cluster has been upgraded from a version of OpenShift
where the vsphere platform spec was not present. You may make modifications to the existing
vCenters except when 1.) the cluster has been upgraded from a version of OpenShift
where the vsphere platform spec was not present or 2.) in TechPreview you are able to add and
remove vCenters but may not remove all vCenters. You may make modifications to the existing
vCenters that are defined in the vcenters list in order to match with any added or modified
failure domains.
items:
Expand Down Expand Up @@ -1083,23 +1084,22 @@ spec:
type: array
x-kubernetes-list-type: atomic
x-kubernetes-validations:
- message: vcenters cannot be added or removed once set
rule: 'size(self) != size(oldSelf) ? size(oldSelf) == 0
&& size(self) < 2 : true'
- message: vcenters must have at least 1 item
rule: 'size(self) != size(oldSelf) ? size(self) > 0 : true'
type: object
x-kubernetes-validations:
- message: apiServerInternalIPs list is required once set
rule: '!has(oldSelf.apiServerInternalIPs) || has(self.apiServerInternalIPs)'
- message: ingressIPs list is required once set
rule: '!has(oldSelf.ingressIPs) || has(self.ingressIPs)'
- message: vcenters can have at most 1 item when configured post-install
rule: '!has(oldSelf.vcenters) && has(self.vcenters) ? size(self.vcenters)
< 2 : true'
type: object
x-kubernetes-validations:
- message: vcenters can have at most 1 item when configured post-install
rule: '!has(oldSelf.vsphere) && has(self.vsphere) ? size(self.vsphere.vcenters)
< 2 : true'
- message: vcenters is required once set and cannot be removed
rule: 'has(oldSelf.vsphere) && has(oldSelf.vsphere.vcenters) ? (has(self.vsphere)
&& has(self.vsphere.vcenters)) : true'
- message: vcenters must have at least 1 item when initially configured
rule: '!has(oldSelf.vsphere) && has(self.vsphere) && has(self.vsphere.vcenters)
? size(self.vsphere.vcenters) > 0 : true'
type: object
status:
description: status holds observed values from the cluster. They may not
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -965,10 +965,11 @@ spec:
vcenters:
description: |-
vcenters holds the connection details for services to communicate with vCenter.
Currently, only a single vCenter is supported, but in tech preview 3 vCenters are supported.
Currently, up to 3 vCenters are supported.
Once the cluster has been installed, you are unable to change the current number of defined
vCenters except in the case where the cluster has been upgraded from a version of OpenShift
where the vsphere platform spec was not present. You may make modifications to the existing
vCenters except when 1.) the cluster has been upgraded from a version of OpenShift
where the vsphere platform spec was not present or 2.) in TechPreview you are able to add and
remove vCenters but may not remove all vCenters. You may make modifications to the existing
vCenters that are defined in the vcenters list in order to match with any added or modified
failure domains.
items:
Expand Down Expand Up @@ -1026,14 +1027,11 @@ spec:
rule: '!has(oldSelf.apiServerInternalIPs) || has(self.apiServerInternalIPs)'
- message: ingressIPs list is required once set
rule: '!has(oldSelf.ingressIPs) || has(self.ingressIPs)'
- message: vcenters can have at most 1 item when configured post-install
rule: '!has(oldSelf.vcenters) && has(self.vcenters) ? size(self.vcenters)
< 2 : true'
type: object
x-kubernetes-validations:
- message: vcenters can have at most 1 item when configured post-install
rule: '!has(oldSelf.vsphere) && has(self.vsphere) ? size(self.vsphere.vcenters)
< 2 : true'
rule: '!has(oldSelf.vsphere) && has(self.vsphere) ? (has(self.vsphere.vcenters)
&& size(self.vsphere.vcenters) < 2) : true'
type: object
status:
description: status holds observed values from the cluster. They may not
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1031,10 +1031,11 @@ spec:
vcenters:
description: |-
vcenters holds the connection details for services to communicate with vCenter.
Currently, only a single vCenter is supported, but in tech preview 3 vCenters are supported.
Currently, up to 3 vCenters are supported.
Once the cluster has been installed, you are unable to change the current number of defined
vCenters except in the case where the cluster has been upgraded from a version of OpenShift
where the vsphere platform spec was not present. You may make modifications to the existing
vCenters except when 1.) the cluster has been upgraded from a version of OpenShift
where the vsphere platform spec was not present or 2.) in TechPreview you are able to add and
remove vCenters but may not remove all vCenters. You may make modifications to the existing
vCenters that are defined in the vcenters list in order to match with any added or modified
failure domains.
items:
Expand Down Expand Up @@ -1083,23 +1084,22 @@ spec:
type: array
x-kubernetes-list-type: atomic
x-kubernetes-validations:
- message: vcenters cannot be added or removed once set
rule: 'size(self) != size(oldSelf) ? size(oldSelf) == 0
&& size(self) < 2 : true'
- message: vcenters must have at least 1 item
rule: 'size(self) != size(oldSelf) ? size(self) > 0 : true'
type: object
x-kubernetes-validations:
- message: apiServerInternalIPs list is required once set
rule: '!has(oldSelf.apiServerInternalIPs) || has(self.apiServerInternalIPs)'
- message: ingressIPs list is required once set
rule: '!has(oldSelf.ingressIPs) || has(self.ingressIPs)'
- message: vcenters can have at most 1 item when configured post-install
rule: '!has(oldSelf.vcenters) && has(self.vcenters) ? size(self.vcenters)
< 2 : true'
type: object
x-kubernetes-validations:
- message: vcenters can have at most 1 item when configured post-install
rule: '!has(oldSelf.vsphere) && has(self.vsphere) ? size(self.vsphere.vcenters)
< 2 : true'
- message: vcenters is required once set and cannot be removed
rule: 'has(oldSelf.vsphere) && has(oldSelf.vsphere.vcenters) ? (has(self.vsphere)
&& has(self.vsphere.vcenters)) : true'
- message: vcenters must have at least 1 item when initially configured
rule: '!has(oldSelf.vsphere) && has(self.vsphere) && has(self.vsphere.vcenters)
? size(self.vsphere.vcenters) > 0 : true'
type: object
status:
description: status holds observed values from the cluster. They may not
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -965,10 +965,11 @@ spec:
vcenters:
description: |-
vcenters holds the connection details for services to communicate with vCenter.
Currently, only a single vCenter is supported, but in tech preview 3 vCenters are supported.
Currently, up to 3 vCenters are supported.
Once the cluster has been installed, you are unable to change the current number of defined
vCenters except in the case where the cluster has been upgraded from a version of OpenShift
where the vsphere platform spec was not present. You may make modifications to the existing
vCenters except when 1.) the cluster has been upgraded from a version of OpenShift
where the vsphere platform spec was not present or 2.) in TechPreview you are able to add and
remove vCenters but may not remove all vCenters. You may make modifications to the existing
vCenters that are defined in the vcenters list in order to match with any added or modified
failure domains.
items:
Expand Down Expand Up @@ -1026,14 +1027,11 @@ spec:
rule: '!has(oldSelf.apiServerInternalIPs) || has(self.apiServerInternalIPs)'
- message: ingressIPs list is required once set
rule: '!has(oldSelf.ingressIPs) || has(self.ingressIPs)'
- message: vcenters can have at most 1 item when configured post-install
rule: '!has(oldSelf.vcenters) && has(self.vcenters) ? size(self.vcenters)
< 2 : true'
type: object
x-kubernetes-validations:
- message: vcenters can have at most 1 item when configured post-install
rule: '!has(oldSelf.vsphere) && has(self.vsphere) ? size(self.vsphere.vcenters)
< 2 : true'
rule: '!has(oldSelf.vsphere) && has(self.vsphere) ? (has(self.vsphere.vcenters)
&& size(self.vsphere.vcenters) < 2) : true'
type: object
status:
description: status holds observed values from the cluster. They may not
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1031,10 +1031,11 @@ spec:
vcenters:
description: |-
vcenters holds the connection details for services to communicate with vCenter.
Currently, only a single vCenter is supported, but in tech preview 3 vCenters are supported.
Currently, up to 3 vCenters are supported.
Once the cluster has been installed, you are unable to change the current number of defined
vCenters except in the case where the cluster has been upgraded from a version of OpenShift
where the vsphere platform spec was not present. You may make modifications to the existing
vCenters except when 1.) the cluster has been upgraded from a version of OpenShift
where the vsphere platform spec was not present or 2.) in TechPreview you are able to add and
remove vCenters but may not remove all vCenters. You may make modifications to the existing
vCenters that are defined in the vcenters list in order to match with any added or modified
failure domains.
items:
Expand Down Expand Up @@ -1092,14 +1093,11 @@ spec:
rule: '!has(oldSelf.apiServerInternalIPs) || has(self.apiServerInternalIPs)'
- message: ingressIPs list is required once set
rule: '!has(oldSelf.ingressIPs) || has(self.ingressIPs)'
- message: vcenters can have at most 1 item when configured post-install
rule: '!has(oldSelf.vcenters) && has(self.vcenters) ? size(self.vcenters)
< 2 : true'
type: object
x-kubernetes-validations:
- message: vcenters can have at most 1 item when configured post-install
rule: '!has(oldSelf.vsphere) && has(self.vsphere) ? size(self.vsphere.vcenters)
< 2 : true'
rule: '!has(oldSelf.vsphere) && has(self.vsphere) ? (has(self.vsphere.vcenters)
&& size(self.vsphere.vcenters) < 2) : true'
type: object
status:
description: status holds observed values from the cluster. They may not
Expand Down
1 change: 1 addition & 0 deletions config/v1/zz_generated.featuregated-crd-manifests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -377,6 +377,7 @@ infrastructures.config.openshift.io:
- OnPremDNSRecords
- VSphereHostVMGroupZonal
- VSphereMultiNetworks
- VSphereMultiVCenterDay2
FilenameOperatorName: config-operator
FilenameOperatorOrdering: "01"
FilenameRunLevel: "0000_10"
Expand Down
Loading