Skip to content

Commit

Permalink
Merge pull request #5258 from enxebre/relax-ibm-network-cel
Browse files Browse the repository at this point in the history
NO-JIRA: Relax networking cel validation for IBMCloud
  • Loading branch information
openshift-merge-bot[bot] authored Dec 9, 2024
2 parents 3f21b14 + 0046f9d commit ed84741
Show file tree
Hide file tree
Showing 22 changed files with 89 additions and 163 deletions.
7 changes: 3 additions & 4 deletions api/hypershift/v1beta1/hostedcluster_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,9 @@ const (
// +kubebuilder:validation:XValidation:rule=`self.platform.type == "Azure" ? self.services.exists(s, s.service == "Konnectivity" && s.servicePublishingStrategy.type == "Route" && s.servicePublishingStrategy.route.hostname != "") : true`,message="Azure platform requires Konnectivity Route service with a hostname to be defined"
// +kubebuilder:validation:XValidation:rule=`self.platform.type == "Azure" ? self.services.exists(s, s.service == "Ignition" && s.servicePublishingStrategy.type == "Route" && s.servicePublishingStrategy.route.hostname != "") : true`,message="Azure platform requires Ignition Route service with a hostname to be defined"
// +kubebuilder:validation:XValidation:rule=`has(self.issuerURL) || !has(self.serviceAccountSigningKey)`,message="If serviceAccountSigningKey is set, issuerURL must be set"

// TODO(alberto): Use CEL cidr library for all these validation when all management clusters are >= 1.31.
// TODO(alberto): Move this down to the networking section when IBMCloud has finished valid input migration.
// +kubebuilder:validation:XValidation:rule=`(self.platform.type == "IBMCloud" || !has(self.networking.machineNetwork) && self.networking.clusterNetwork.all(c, self.networking.serviceNetwork.all(s, c.cidr != s.cidr)) || (has(self.networking.machineNetwork) && (self.networking.machineNetwork.all(m, self.networking.clusterNetwork.all(c, m.cidr != c.cidr)) && self.networking.machineNetwork.all(m, self.networking.serviceNetwork.all(s, m.cidr != s.cidr)) && self.networking.clusterNetwork.all(c, self.networking.serviceNetwork.all(s, c.cidr != s.cidr)))))`,message="CIDR ranges in machineNetwork, clusterNetwork, and serviceNetwork must be unique and non-overlapping"
type HostedClusterSpec struct {
// release specifies the desired OCP release payload for all the hosted cluster components.
// This includes those components running management side like the Kube API Server and the CVO but also the operands which land in the hosted cluster data plane like the ingress controller, ovn agents, etc.
Expand Down Expand Up @@ -853,9 +855,6 @@ type DNSSpec struct {
// clusterNetworking specifies network configuration for a cluster.
// All CIDRs must be unique. Additional validation to check for CIDRs overlap and consistent network stack is performed by the controllers.
// Failing that validation will result in the HostedCluster being degraded and the validConfiguration condition being false.
// TODO this is available in vanilla kube from 1.31 API servers and in Openshift from 4.16.
// TODO(alberto): Use CEL cidr library for all these validation when all management clusters are >= 1.31.
// +kubebuilder:validation:XValidation:rule="(!has(self.machineNetwork) && self.clusterNetwork.all(c, self.serviceNetwork.all(s, c.cidr != s.cidr)) || (has(self.machineNetwork) && (self.machineNetwork.all(m, self.clusterNetwork.all(c, m.cidr != c.cidr)) && self.machineNetwork.all(m, self.serviceNetwork.all(s, m.cidr != s.cidr)) && self.clusterNetwork.all(c, self.serviceNetwork.all(s, c.cidr != s.cidr)))))",message="CIDR ranges in machineNetwork, clusterNetwork, and serviceNetwork must be unique and non-overlapping"
type ClusterNetworking struct {
// machineNetwork is the list of IP address pools for machines.
// This might be used among other things to generate appropriate networking security groups in some clouds providers.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2514,14 +2514,6 @@ spec:
once set.
rule: self == oldSelf
type: object
x-kubernetes-validations:
- message: CIDR ranges in machineNetwork, clusterNetwork, and serviceNetwork
must be unique and non-overlapping
rule: (!has(self.machineNetwork) && self.clusterNetwork.all(c, self.serviceNetwork.all(s,
c.cidr != s.cidr)) || (has(self.machineNetwork) && (self.machineNetwork.all(m,
self.clusterNetwork.all(c, m.cidr != c.cidr)) && self.machineNetwork.all(m,
self.serviceNetwork.all(s, m.cidr != s.cidr)) && self.clusterNetwork.all(c,
self.serviceNetwork.all(s, c.cidr != s.cidr)))))
nodeSelector:
additionalProperties:
type: string
Expand Down Expand Up @@ -4088,6 +4080,14 @@ spec:
!= "") : true'
- message: If serviceAccountSigningKey is set, issuerURL must be set
rule: has(self.issuerURL) || !has(self.serviceAccountSigningKey)
- message: CIDR ranges in machineNetwork, clusterNetwork, and serviceNetwork
must be unique and non-overlapping
rule: (self.platform.type == "IBMCloud" || !has(self.networking.machineNetwork)
&& self.networking.clusterNetwork.all(c, self.networking.serviceNetwork.all(s,
c.cidr != s.cidr)) || (has(self.networking.machineNetwork) && (self.networking.machineNetwork.all(m,
self.networking.clusterNetwork.all(c, m.cidr != c.cidr)) && self.networking.machineNetwork.all(m,
self.networking.serviceNetwork.all(s, m.cidr != s.cidr)) && self.networking.clusterNetwork.all(c,
self.networking.serviceNetwork.all(s, c.cidr != s.cidr)))))
status:
description: Status is the latest observed status of the HostedCluster.
properties:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2510,14 +2510,6 @@ spec:
once set.
rule: self == oldSelf
type: object
x-kubernetes-validations:
- message: CIDR ranges in machineNetwork, clusterNetwork, and serviceNetwork
must be unique and non-overlapping
rule: (!has(self.machineNetwork) && self.clusterNetwork.all(c, self.serviceNetwork.all(s,
c.cidr != s.cidr)) || (has(self.machineNetwork) && (self.machineNetwork.all(m,
self.clusterNetwork.all(c, m.cidr != c.cidr)) && self.machineNetwork.all(m,
self.serviceNetwork.all(s, m.cidr != s.cidr)) && self.clusterNetwork.all(c,
self.serviceNetwork.all(s, c.cidr != s.cidr)))))
nodeSelector:
additionalProperties:
type: string
Expand Down Expand Up @@ -4333,6 +4325,14 @@ spec:
!= "") : true'
- message: If serviceAccountSigningKey is set, issuerURL must be set
rule: has(self.issuerURL) || !has(self.serviceAccountSigningKey)
- message: CIDR ranges in machineNetwork, clusterNetwork, and serviceNetwork
must be unique and non-overlapping
rule: (self.platform.type == "IBMCloud" || !has(self.networking.machineNetwork)
&& self.networking.clusterNetwork.all(c, self.networking.serviceNetwork.all(s,
c.cidr != s.cidr)) || (has(self.networking.machineNetwork) && (self.networking.machineNetwork.all(m,
self.networking.clusterNetwork.all(c, m.cidr != c.cidr)) && self.networking.machineNetwork.all(m,
self.networking.serviceNetwork.all(s, m.cidr != s.cidr)) && self.networking.clusterNetwork.all(c,
self.networking.serviceNetwork.all(s, c.cidr != s.cidr)))))
status:
description: Status is the latest observed status of the HostedCluster.
properties:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2531,14 +2531,6 @@ spec:
once set.
rule: self == oldSelf
type: object
x-kubernetes-validations:
- message: CIDR ranges in machineNetwork, clusterNetwork, and serviceNetwork
must be unique and non-overlapping
rule: (!has(self.machineNetwork) && self.clusterNetwork.all(c, self.serviceNetwork.all(s,
c.cidr != s.cidr)) || (has(self.machineNetwork) && (self.machineNetwork.all(m,
self.clusterNetwork.all(c, m.cidr != c.cidr)) && self.machineNetwork.all(m,
self.serviceNetwork.all(s, m.cidr != s.cidr)) && self.clusterNetwork.all(c,
self.serviceNetwork.all(s, c.cidr != s.cidr)))))
nodeSelector:
additionalProperties:
type: string
Expand Down Expand Up @@ -4097,6 +4089,14 @@ spec:
!= "") : true'
- message: If serviceAccountSigningKey is set, issuerURL must be set
rule: has(self.issuerURL) || !has(self.serviceAccountSigningKey)
- message: CIDR ranges in machineNetwork, clusterNetwork, and serviceNetwork
must be unique and non-overlapping
rule: (self.platform.type == "IBMCloud" || !has(self.networking.machineNetwork)
&& self.networking.clusterNetwork.all(c, self.networking.serviceNetwork.all(s,
c.cidr != s.cidr)) || (has(self.networking.machineNetwork) && (self.networking.machineNetwork.all(m,
self.networking.clusterNetwork.all(c, m.cidr != c.cidr)) && self.networking.machineNetwork.all(m,
self.networking.serviceNetwork.all(s, m.cidr != s.cidr)) && self.networking.clusterNetwork.all(c,
self.networking.serviceNetwork.all(s, c.cidr != s.cidr)))))
status:
description: Status is the latest observed status of the HostedCluster.
properties:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2752,14 +2752,6 @@ spec:
once set.
rule: self == oldSelf
type: object
x-kubernetes-validations:
- message: CIDR ranges in machineNetwork, clusterNetwork, and serviceNetwork
must be unique and non-overlapping
rule: (!has(self.machineNetwork) && self.clusterNetwork.all(c, self.serviceNetwork.all(s,
c.cidr != s.cidr)) || (has(self.machineNetwork) && (self.machineNetwork.all(m,
self.clusterNetwork.all(c, m.cidr != c.cidr)) && self.machineNetwork.all(m,
self.serviceNetwork.all(s, m.cidr != s.cidr)) && self.clusterNetwork.all(c,
self.serviceNetwork.all(s, c.cidr != s.cidr)))))
nodeSelector:
additionalProperties:
type: string
Expand Down Expand Up @@ -4318,6 +4310,14 @@ spec:
!= "") : true'
- message: If serviceAccountSigningKey is set, issuerURL must be set
rule: has(self.issuerURL) || !has(self.serviceAccountSigningKey)
- message: CIDR ranges in machineNetwork, clusterNetwork, and serviceNetwork
must be unique and non-overlapping
rule: (self.platform.type == "IBMCloud" || !has(self.networking.machineNetwork)
&& self.networking.clusterNetwork.all(c, self.networking.serviceNetwork.all(s,
c.cidr != s.cidr)) || (has(self.networking.machineNetwork) && (self.networking.machineNetwork.all(m,
self.networking.clusterNetwork.all(c, m.cidr != c.cidr)) && self.networking.machineNetwork.all(m,
self.networking.serviceNetwork.all(s, m.cidr != s.cidr)) && self.networking.clusterNetwork.all(c,
self.networking.serviceNetwork.all(s, c.cidr != s.cidr)))))
status:
description: Status is the latest observed status of the HostedCluster.
properties:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2523,14 +2523,6 @@ spec:
once set.
rule: self == oldSelf
type: object
x-kubernetes-validations:
- message: CIDR ranges in machineNetwork, clusterNetwork, and serviceNetwork
must be unique and non-overlapping
rule: (!has(self.machineNetwork) && self.clusterNetwork.all(c, self.serviceNetwork.all(s,
c.cidr != s.cidr)) || (has(self.machineNetwork) && (self.machineNetwork.all(m,
self.clusterNetwork.all(c, m.cidr != c.cidr)) && self.machineNetwork.all(m,
self.serviceNetwork.all(s, m.cidr != s.cidr)) && self.clusterNetwork.all(c,
self.serviceNetwork.all(s, c.cidr != s.cidr)))))
nodeSelector:
additionalProperties:
type: string
Expand Down Expand Up @@ -4089,6 +4081,14 @@ spec:
!= "") : true'
- message: If serviceAccountSigningKey is set, issuerURL must be set
rule: has(self.issuerURL) || !has(self.serviceAccountSigningKey)
- message: CIDR ranges in machineNetwork, clusterNetwork, and serviceNetwork
must be unique and non-overlapping
rule: (self.platform.type == "IBMCloud" || !has(self.networking.machineNetwork)
&& self.networking.clusterNetwork.all(c, self.networking.serviceNetwork.all(s,
c.cidr != s.cidr)) || (has(self.networking.machineNetwork) && (self.networking.machineNetwork.all(m,
self.networking.clusterNetwork.all(c, m.cidr != c.cidr)) && self.networking.machineNetwork.all(m,
self.networking.serviceNetwork.all(s, m.cidr != s.cidr)) && self.networking.clusterNetwork.all(c,
self.networking.serviceNetwork.all(s, c.cidr != s.cidr)))))
status:
description: Status is the latest observed status of the HostedCluster.
properties:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2662,14 +2662,6 @@ spec:
once set.
rule: self == oldSelf
type: object
x-kubernetes-validations:
- message: CIDR ranges in machineNetwork, clusterNetwork, and serviceNetwork
must be unique and non-overlapping
rule: (!has(self.machineNetwork) && self.clusterNetwork.all(c, self.serviceNetwork.all(s,
c.cidr != s.cidr)) || (has(self.machineNetwork) && (self.machineNetwork.all(m,
self.clusterNetwork.all(c, m.cidr != c.cidr)) && self.machineNetwork.all(m,
self.serviceNetwork.all(s, m.cidr != s.cidr)) && self.clusterNetwork.all(c,
self.serviceNetwork.all(s, c.cidr != s.cidr)))))
nodeSelector:
additionalProperties:
type: string
Expand Down Expand Up @@ -4228,6 +4220,14 @@ spec:
!= "") : true'
- message: If serviceAccountSigningKey is set, issuerURL must be set
rule: has(self.issuerURL) || !has(self.serviceAccountSigningKey)
- message: CIDR ranges in machineNetwork, clusterNetwork, and serviceNetwork
must be unique and non-overlapping
rule: (self.platform.type == "IBMCloud" || !has(self.networking.machineNetwork)
&& self.networking.clusterNetwork.all(c, self.networking.serviceNetwork.all(s,
c.cidr != s.cidr)) || (has(self.networking.machineNetwork) && (self.networking.machineNetwork.all(m,
self.networking.clusterNetwork.all(c, m.cidr != c.cidr)) && self.networking.machineNetwork.all(m,
self.networking.serviceNetwork.all(s, m.cidr != s.cidr)) && self.networking.clusterNetwork.all(c,
self.networking.serviceNetwork.all(s, c.cidr != s.cidr)))))
status:
description: Status is the latest observed status of the HostedCluster.
properties:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2510,14 +2510,6 @@ spec:
once set.
rule: self == oldSelf
type: object
x-kubernetes-validations:
- message: CIDR ranges in machineNetwork, clusterNetwork, and serviceNetwork
must be unique and non-overlapping
rule: (!has(self.machineNetwork) && self.clusterNetwork.all(c, self.serviceNetwork.all(s,
c.cidr != s.cidr)) || (has(self.machineNetwork) && (self.machineNetwork.all(m,
self.clusterNetwork.all(c, m.cidr != c.cidr)) && self.machineNetwork.all(m,
self.serviceNetwork.all(s, m.cidr != s.cidr)) && self.clusterNetwork.all(c,
self.serviceNetwork.all(s, c.cidr != s.cidr)))))
nodeSelector:
additionalProperties:
type: string
Expand Down Expand Up @@ -4564,6 +4556,14 @@ spec:
!= "") : true'
- message: If serviceAccountSigningKey is set, issuerURL must be set
rule: has(self.issuerURL) || !has(self.serviceAccountSigningKey)
- message: CIDR ranges in machineNetwork, clusterNetwork, and serviceNetwork
must be unique and non-overlapping
rule: (self.platform.type == "IBMCloud" || !has(self.networking.machineNetwork)
&& self.networking.clusterNetwork.all(c, self.networking.serviceNetwork.all(s,
c.cidr != s.cidr)) || (has(self.networking.machineNetwork) && (self.networking.machineNetwork.all(m,
self.networking.clusterNetwork.all(c, m.cidr != c.cidr)) && self.networking.machineNetwork.all(m,
self.networking.serviceNetwork.all(s, m.cidr != s.cidr)) && self.networking.clusterNetwork.all(c,
self.networking.serviceNetwork.all(s, c.cidr != s.cidr)))))
status:
description: Status is the latest observed status of the HostedCluster.
properties:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2431,14 +2431,6 @@ spec:
once set.
rule: self == oldSelf
type: object
x-kubernetes-validations:
- message: CIDR ranges in machineNetwork, clusterNetwork, and serviceNetwork
must be unique and non-overlapping
rule: (!has(self.machineNetwork) && self.clusterNetwork.all(c, self.serviceNetwork.all(s,
c.cidr != s.cidr)) || (has(self.machineNetwork) && (self.machineNetwork.all(m,
self.clusterNetwork.all(c, m.cidr != c.cidr)) && self.machineNetwork.all(m,
self.serviceNetwork.all(s, m.cidr != s.cidr)) && self.clusterNetwork.all(c,
self.serviceNetwork.all(s, c.cidr != s.cidr)))))
nodeSelector:
additionalProperties:
type: string
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2427,14 +2427,6 @@ spec:
once set.
rule: self == oldSelf
type: object
x-kubernetes-validations:
- message: CIDR ranges in machineNetwork, clusterNetwork, and serviceNetwork
must be unique and non-overlapping
rule: (!has(self.machineNetwork) && self.clusterNetwork.all(c, self.serviceNetwork.all(s,
c.cidr != s.cidr)) || (has(self.machineNetwork) && (self.machineNetwork.all(m,
self.clusterNetwork.all(c, m.cidr != c.cidr)) && self.machineNetwork.all(m,
self.serviceNetwork.all(s, m.cidr != s.cidr)) && self.clusterNetwork.all(c,
self.serviceNetwork.all(s, c.cidr != s.cidr)))))
nodeSelector:
additionalProperties:
type: string
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2448,14 +2448,6 @@ spec:
once set.
rule: self == oldSelf
type: object
x-kubernetes-validations:
- message: CIDR ranges in machineNetwork, clusterNetwork, and serviceNetwork
must be unique and non-overlapping
rule: (!has(self.machineNetwork) && self.clusterNetwork.all(c, self.serviceNetwork.all(s,
c.cidr != s.cidr)) || (has(self.machineNetwork) && (self.machineNetwork.all(m,
self.clusterNetwork.all(c, m.cidr != c.cidr)) && self.machineNetwork.all(m,
self.serviceNetwork.all(s, m.cidr != s.cidr)) && self.clusterNetwork.all(c,
self.serviceNetwork.all(s, c.cidr != s.cidr)))))
nodeSelector:
additionalProperties:
type: string
Expand Down
Loading

0 comments on commit ed84741

Please sign in to comment.