Skip to content

Commit 337b0ee

Browse files
committed
Fail and display error message in case the CKS ISO arch doesnt match the selected template arch
1 parent a44dde0 commit 337b0ee

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

plugins/integrations/kubernetes-service/src/main/java/com/cloud/kubernetes/cluster/KubernetesClusterManagerImpl.java

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1304,6 +1304,9 @@ public KubernetesCluster createManagedKubernetesCluster(CreateKubernetesClusterC
13041304

13051305
final Network defaultNetwork = getKubernetesClusterNetworkIfMissing(cmd.getName(), zone, owner, (int)controlNodeCount, (int)clusterSize, cmd.getExternalLoadBalancerIpAddress(), cmd.getNetworkId());
13061306
final VMTemplateVO finalTemplate = getKubernetesServiceTemplate(zone, deployDestination.getCluster().getHypervisorType());
1307+
1308+
compareKubernetesIsoArchToSelectedTemplateArch(clusterKubernetesVersion, finalTemplate);
1309+
13071310
final long cores = serviceOffering.getCpu() * (controlNodeCount + clusterSize);
13081311
final long memory = serviceOffering.getRamSize() * (controlNodeCount + clusterSize);
13091312

@@ -1332,6 +1335,21 @@ public KubernetesClusterVO doInTransaction(TransactionStatus status) {
13321335
return cluster;
13331336
}
13341337

1338+
private void compareKubernetesIsoArchToSelectedTemplateArch(KubernetesSupportedVersion clusterKubernetesVersion, VMTemplateVO finalTemplate) {
1339+
VMTemplateVO cksIso = templateDao.findById(clusterKubernetesVersion.getIsoId());
1340+
if (cksIso == null) {
1341+
String err = String.format("Cannot find Kubernetes ISO associated to the Kubernetes version %s (id=%s)",
1342+
clusterKubernetesVersion.getName(), clusterKubernetesVersion.getUuid());
1343+
throw new CloudRuntimeException(err);
1344+
}
1345+
if (!cksIso.getArch().equals(finalTemplate.getArch())) {
1346+
String err = String.format("The selected Kubernetes ISO %s arch (%s) doesn't match the template %s arch (%s) " +
1347+
"to deploy the Kubernetes cluster",
1348+
clusterKubernetesVersion.getName(), cksIso.getArch(), finalTemplate.getName(), finalTemplate.getArch());
1349+
throw new CloudRuntimeException(err);
1350+
}
1351+
}
1352+
13351353
private SecurityGroup getOrCreateSecurityGroupForAccount(Account owner) {
13361354
String securityGroupName = String.format("%s-%s", KubernetesClusterActionWorker.CKS_CLUSTER_SECURITY_GROUP_NAME, owner.getUuid());
13371355
String securityGroupDesc = String.format("%s and account %s", KubernetesClusterActionWorker.CKS_SECURITY_GROUP_DESCRIPTION, owner.getName());

0 commit comments

Comments
 (0)