Skip to content

Commit 7e919e2

Browse files
veera-damisettirootroot
authored
MULTIARCH-5544: Added support to create s390x NodePool with kubevirt platform (#6239)
* feat: Updated nodepool_controller to support s390x nodepool for kubevirt platform and updated unit tests Adds support to create s390x nodepool with kubevirt platform by updating nodepool controller and its unit tests * feat: Updated CRD manifests to include s390x as a supported architecture and updated vendored dependencies This adds changes to update nodepool CRD manifests to include s390x as a supported architecture * feat: Added CEL Validations for s390x Nodepool architecture This adds changes to add CEL Validations to Nodepool architecture * feat: Added vendor changes for CEL Validations for s390x Nodepool architecture This vendor changes to add CEL Validations to Nodepool architecture * feat: Updated CEL Validations for s390x Nodepool architecture to nodepool level These changes updates CEL Validations for s390x Nodepool architecture to nodepool level * test: Added test cases for nodepool arch validation in create_cluster_test.go These changes adds test cases for handling nodepool arch validation for kubevirt platform * test: Added test cases for nodepool arch validation in create_cluster_test.go These changes adds test cases for handling nodepool arch validation for kubevirt platform * feat: Updated test cases for nodepool arch validation in create_cluster_test.go These changes updates test cases for nodepool arch validation in create_cluster_test.go * test: updated test case name Signed-off-by: DAMISETTI-VEERABHADRARAO <[email protected]> * fix: ran make verify for fixing the check Signed-off-by: root <[email protected]> * fix: Resolving commits in test/e2e/create_cluster_test.go Signed-off-by: root <[email protected]> * fix: updated test/e2e/create_cluster_test.go using make verify Signed-off-by: root <[email protected]> --------- Signed-off-by: DAMISETTI-VEERABHADRARAO <[email protected]> Signed-off-by: root <[email protected]> Signed-off-by: root <[email protected]> Co-authored-by: root <[email protected]> Co-authored-by: root <[email protected]>
1 parent 9c695e2 commit 7e919e2

File tree

12 files changed

+57
-10
lines changed

12 files changed

+57
-10
lines changed

api/hypershift/v1beta1/nodepool_types.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@ type NodePool struct {
100100
// +kubebuilder:validation:XValidation:rule="!has(oldSelf.arch) || has(self.arch)", message="Arch is required once set"
101101
// +kubebuilder:validation:XValidation:rule="self.arch != 'arm64' || has(self.platform.aws) || has(self.platform.azure) || has(self.platform.agent) || self.platform.type == 'None'", message="Setting Arch to arm64 is only supported for AWS, Azure, Agent and None"
102102
// +kubebuilder:validation:XValidation:rule="!has(self.replicas) || !has(self.autoScaling)", message="Both replicas or autoScaling should not be set"
103+
// +kubebuilder:validation:XValidation:rule="self.arch != 's390x' || has(self.platform.kubevirt)", message="s390x is only supported on KubeVirt platform"
103104
// +kubebuilder:validation:XValidation:rule="!has(self.platform.aws) || self.platform.aws.imageType != 'Windows' || self.arch == 'amd64'", message="ImageType 'Windows' requires arch 'amd64' (AWS only)"
104105
type NodePoolSpec struct {
105106
// clusterName is the name of the HostedCluster this NodePool belongs to.
@@ -226,10 +227,9 @@ type NodePoolSpec struct {
226227
// arch is the preferred processor architecture for the NodePool. Different platforms might have different supported architectures.
227228
// TODO: This is set as optional to prevent validation from failing due to a limitation on client side validation with open API machinery:
228229
// https://github.com/kubernetes/kubernetes/issues/108768#issuecomment-1253912215
229-
// TODO Add s390x to enum validation once the architecture is supported
230230
//
231231
// +kubebuilder:default:=amd64
232-
// +kubebuilder:validation:Enum=arm64;amd64;ppc64le
232+
// +kubebuilder:validation:Enum=arm64;amd64;ppc64le;s390x
233233
// +kubebuilder:validation:XValidation:rule="self == oldSelf", message="Arch is immutable"
234234
// +optional
235235
Arch string `json:"arch,omitempty"`

api/hypershift/v1beta1/zz_generated.featuregated-crd-manifests/nodepools.hypershift.openshift.io/AAA_ungated.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ spec:
8989
- arm64
9090
- amd64
9191
- ppc64le
92+
- s390x
9293
type: string
9394
x-kubernetes-validations:
9495
- message: Arch is immutable
@@ -1458,6 +1459,8 @@ spec:
14581459
|| has(self.platform.agent) || self.platform.type == 'None'
14591460
- message: Both replicas or autoScaling should not be set
14601461
rule: '!has(self.replicas) || !has(self.autoScaling)'
1462+
- message: s390x is only supported on KubeVirt platform
1463+
rule: self.arch != 's390x' || has(self.platform.kubevirt)
14611464
- message: ImageType 'Windows' requires arch 'amd64' (AWS only)
14621465
rule: '!has(self.platform.aws) || self.platform.aws.imageType != ''Windows''
14631466
|| self.arch == ''amd64'''

api/hypershift/v1beta1/zz_generated.featuregated-crd-manifests/nodepools.hypershift.openshift.io/OpenStack.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ spec:
8989
- arm64
9090
- amd64
9191
- ppc64le
92+
- s390x
9293
type: string
9394
x-kubernetes-validations:
9495
- message: Arch is immutable
@@ -1644,6 +1645,8 @@ spec:
16441645
|| has(self.platform.agent) || self.platform.type == 'None'
16451646
- message: Both replicas or autoScaling should not be set
16461647
rule: '!has(self.replicas) || !has(self.autoScaling)'
1648+
- message: s390x is only supported on KubeVirt platform
1649+
rule: self.arch != 's390x' || has(self.platform.kubevirt)
16471650
- message: ImageType 'Windows' requires arch 'amd64' (AWS only)
16481651
rule: '!has(self.platform.aws) || self.platform.aws.imageType != ''Windows''
16491652
|| self.arch == ''amd64'''

cmd/cluster/core/create.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -712,12 +712,12 @@ func (opts *RawCreateOptions) Validate(ctx context.Context) (*ValidatedCreateOpt
712712
}
713713
}
714714

715-
// Validate arch is only hyperv1.ArchitectureAMD64 or hyperv1.ArchitectureARM64 or hyperv1.ArchitecturePPC64LE
716715
arch := strings.ToLower(opts.Arch)
717716
switch arch {
718717
case hyperv1.ArchitectureAMD64:
719718
case hyperv1.ArchitectureARM64:
720719
case hyperv1.ArchitecturePPC64LE:
720+
case hyperv1.ArchitectureS390X:
721721
default:
722722
return nil, fmt.Errorf("specified arch %q is not supported", opts.Arch)
723723
}

cmd/install/assets/hypershift-operator/zz_generated.crd-manifests/nodepools-CustomNoUpgrade.crd.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ spec:
9292
- arm64
9393
- amd64
9494
- ppc64le
95+
- s390x
9596
type: string
9697
x-kubernetes-validations:
9798
- message: Arch is immutable
@@ -1647,6 +1648,8 @@ spec:
16471648
|| has(self.platform.agent) || self.platform.type == 'None'
16481649
- message: Both replicas or autoScaling should not be set
16491650
rule: '!has(self.replicas) || !has(self.autoScaling)'
1651+
- message: s390x is only supported on KubeVirt platform
1652+
rule: self.arch != 's390x' || has(self.platform.kubevirt)
16501653
- message: ImageType 'Windows' requires arch 'amd64' (AWS only)
16511654
rule: '!has(self.platform.aws) || self.platform.aws.imageType != ''Windows''
16521655
|| self.arch == ''amd64'''

cmd/install/assets/hypershift-operator/zz_generated.crd-manifests/nodepools-Default.crd.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ spec:
9292
- arm64
9393
- amd64
9494
- ppc64le
95+
- s390x
9596
type: string
9697
x-kubernetes-validations:
9798
- message: Arch is immutable
@@ -1461,6 +1462,8 @@ spec:
14611462
|| has(self.platform.agent) || self.platform.type == 'None'
14621463
- message: Both replicas or autoScaling should not be set
14631464
rule: '!has(self.replicas) || !has(self.autoScaling)'
1465+
- message: s390x is only supported on KubeVirt platform
1466+
rule: self.arch != 's390x' || has(self.platform.kubevirt)
14641467
- message: ImageType 'Windows' requires arch 'amd64' (AWS only)
14651468
rule: '!has(self.platform.aws) || self.platform.aws.imageType != ''Windows''
14661469
|| self.arch == ''amd64'''

cmd/install/assets/hypershift-operator/zz_generated.crd-manifests/nodepools-TechPreviewNoUpgrade.crd.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ spec:
9292
- arm64
9393
- amd64
9494
- ppc64le
95+
- s390x
9596
type: string
9697
x-kubernetes-validations:
9798
- message: Arch is immutable
@@ -1647,6 +1648,8 @@ spec:
16471648
|| has(self.platform.agent) || self.platform.type == 'None'
16481649
- message: Both replicas or autoScaling should not be set
16491650
rule: '!has(self.replicas) || !has(self.autoScaling)'
1651+
- message: s390x is only supported on KubeVirt platform
1652+
rule: self.arch != 's390x' || has(self.platform.kubevirt)
16501653
- message: ImageType 'Windows' requires arch 'amd64' (AWS only)
16511654
rule: '!has(self.platform.aws) || self.platform.aws.imageType != ''Windows''
16521655
|| self.arch == ''amd64'''

docs/content/reference/api.md

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1138,8 +1138,7 @@ string
11381138
<em>(Optional)</em>
11391139
<p>arch is the preferred processor architecture for the NodePool. Different platforms might have different supported architectures.
11401140
TODO: This is set as optional to prevent validation from failing due to a limitation on client side validation with open API machinery:
1141-
<a href="https://github.com/kubernetes/kubernetes/issues/108768#issuecomment-1253912215">https://github.com/kubernetes/kubernetes/issues/108768#issuecomment-1253912215</a>
1142-
TODO Add s390x to enum validation once the architecture is supported</p>
1141+
<a href="https://github.com/kubernetes/kubernetes/issues/108768#issuecomment-1253912215">https://github.com/kubernetes/kubernetes/issues/108768#issuecomment-1253912215</a></p>
11431142
</td>
11441143
</tr>
11451144
</table>
@@ -10325,8 +10324,7 @@ string
1032510324
<em>(Optional)</em>
1032610325
<p>arch is the preferred processor architecture for the NodePool. Different platforms might have different supported architectures.
1032710326
TODO: This is set as optional to prevent validation from failing due to a limitation on client side validation with open API machinery:
10328-
<a href="https://github.com/kubernetes/kubernetes/issues/108768#issuecomment-1253912215">https://github.com/kubernetes/kubernetes/issues/108768#issuecomment-1253912215</a>
10329-
TODO Add s390x to enum validation once the architecture is supported</p>
10327+
<a href="https://github.com/kubernetes/kubernetes/issues/108768#issuecomment-1253912215">https://github.com/kubernetes/kubernetes/issues/108768#issuecomment-1253912215</a></p>
1033010328
</td>
1033110329
</tr>
1033210330
</tbody>

hypershift-operator/controllers/nodepool/nodepool_controller.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -446,7 +446,7 @@ func isArchAndPlatformSupported(nodePool *hyperv1.NodePool) bool {
446446
supported = true
447447
}
448448
case hyperv1.KubevirtPlatform:
449-
if nodePool.Spec.Arch == hyperv1.ArchitectureAMD64 {
449+
if nodePool.Spec.Arch == hyperv1.ArchitectureAMD64 || nodePool.Spec.Arch == hyperv1.ArchitectureS390X {
450450
supported = true
451451
}
452452
case hyperv1.OpenStackPlatform:

hypershift-operator/controllers/nodepool/nodepool_controller_test.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1334,6 +1334,18 @@ func TestIsArchAndPlatformSupported(t *testing.T) {
13341334
},
13351335
expect: true,
13361336
},
1337+
{
1338+
name: "supported arch and platform used - s390x",
1339+
nodePool: &hyperv1.NodePool{
1340+
Spec: hyperv1.NodePoolSpec{
1341+
Platform: hyperv1.NodePoolPlatform{
1342+
Type: hyperv1.KubevirtPlatform,
1343+
},
1344+
Arch: hyperv1.ArchitectureS390X,
1345+
},
1346+
},
1347+
expect: true,
1348+
},
13371349
{
13381350
name: "supported platform with multiple arch baremetal - arm64",
13391351
nodePool: &hyperv1.NodePool{

0 commit comments

Comments
 (0)