CKS: Allow affinity group selection during cluster creation#12386
CKS: Allow affinity group selection during cluster creation#12386Damans227 wants to merge 34 commits intoapache:mainfrom
Conversation
…to CreateKubernetesClusterCmd
…ndling and enhance node type validation tests
…ubernetesClusterVO
…bernetesClusterManagerImpl
…lusterVO to support multiple IDs
…erviceHelper and related classes
…ting kubernetes_cluster
|
Packaging result [SF]: ✔️ el8 ✔️ el9 ✔️ el10 ✔️ debian ✔️ suse15. SL-JID 16294 |
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #12386 +/- ##
============================================
+ Coverage 17.76% 17.88% +0.11%
- Complexity 15859 16062 +203
============================================
Files 5923 5932 +9
Lines 530470 531718 +1248
Branches 64823 65001 +178
============================================
+ Hits 94243 95094 +851
- Misses 425682 425992 +310
- Partials 10545 10632 +87
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
[SF] Trillian test result (tid-15195)
|
test/integration/component/test_kubernetes_cluster_affinity_groups.py
Outdated
Show resolved
Hide resolved
test/integration/component/test_kubernetes_cluster_affinity_groups.py
Outdated
Show resolved
Hide resolved
engine/schema/src/main/resources/META-INF/db/schema-42210to42300.sql
Outdated
Show resolved
Hide resolved
| List<KubernetesUserVmResponse> vmResponses = new ArrayList<>(); | ||
| List<KubernetesClusterVmMapVO> vmList = kubernetesClusterVmMapDao.listByClusterId(kubernetesCluster.getId()); | ||
| ResponseView respView = ResponseView.Restricted; | ||
| ResponseView userVmResponseView = ResponseView.Restricted; |
...ernetes-service/src/main/java/com/cloud/kubernetes/cluster/KubernetesClusterManagerImpl.java
Show resolved
Hide resolved
|
Added docs pr: apache/cloudstack-documentation#620 |
engine/schema/src/main/resources/META-INF/db/schema-42210to42300.sql
Outdated
Show resolved
Hide resolved
...bernetes-service/src/main/java/com/cloud/kubernetes/cluster/KubernetesServiceHelperImpl.java
Outdated
Show resolved
Hide resolved
|
@blueorangutan package |
|
@harikrishna-patnala a [SL] Jenkins job has been kicked to build packages. It will be bundled with no SystemVM templates. I'll keep you posted as I make progress. |
|
Packaging result [SF]: ✔️ el8 ✔️ el9 ✔️ el10 ✔️ debian ✔️ suse15. SL-JID 16675 |
|
@blueorangutan package |
|
@nvazquez a [SL] Jenkins job has been kicked to build packages. It will be bundled with no SystemVM templates. I'll keep you posted as I make progress. |
|
Packaging result [SF]: ✔️ el8 ✔️ el9 ✔️ el10 ✔️ debian ✔️ suse15. SL-JID 16800 |
|
@blueorangutan test |
|
@nvazquez a [SL] Trillian-Jenkins test job (ol8 mgmt + kvm-ol8) has been kicked to run smoke tests |
DaanHoogland
left a comment
There was a problem hiding this comment.
clgtm (afaics) , will need some 3rd person testing, but looks really promissing.
|
[SF] Trillian test result (tid-15442)
|
| @Override | ||
| public List<Long> listAffinityGroupIdsByClusterIdAndNodeType(long clusterId, String nodeType) { | ||
| List<KubernetesClusterAffinityGroupMapVO> maps = listByClusterIdAndNodeType(clusterId, nodeType); | ||
| return maps.stream().map(KubernetesClusterAffinityGroupMapVO::getAffinityGroupId).collect(Collectors.toList()); |
There was a problem hiding this comment.
I think a null check should be needed at this point, to cover cases in which the affinity group is not passed for the node type
| } | ||
|
|
||
| protected List<Long> getAffinityGroupIdsForNodeType(KubernetesClusterNodeType nodeType) { | ||
| return new ArrayList<>(kubernetesClusterAffinityGroupMapDao.listAffinityGroupIdsByClusterIdAndNodeType( |
There was a problem hiding this comment.
Here as well, can we add checks for null or empty list?
|
|
||
| protected void setAffinityGroupResponseForNodeType(KubernetesClusterResponse response, long clusterId, String nodeType) { | ||
| List<Long> affinityGroupIds = kubernetesClusterAffinityGroupMapDao.listAffinityGroupIdsByClusterIdAndNodeType(clusterId, nodeType); | ||
| if (affinityGroupIds == null || affinityGroupIds.isEmpty()) { |
There was a problem hiding this comment.
Minor: can use CollectionUtils.isEmpty(affinityGroupIds) here
| Long nodeHostId = node.getHostId(); | ||
| String nodeHostName = getHostName(nodeHostId); | ||
|
|
||
| if ("host anti-affinity".equalsIgnoreCase(affinityGroupType)) { |
There was a problem hiding this comment.
What about adding the following checks to not rely on a string comparisson?
- Inject
AffinityGroupServiceon the class level - Add the following method on
AffinityGroupServiceinterface:protected Map<String, AffinityGroupProcessor> getAffinityTypeToProcessorMap() - Mark this method as public on
AffinityGroupServiceImpl(definition already exists) - Obtain the
AffinityGroupProcessorfor the affinity group type (adding null checks) and replace the string comparisson toprocessor instanceof HostAntiAffinityProcessorandprocessor isinstanceof HostAffinityProcessor
What do you think?
| } | ||
|
|
||
| protected void validateNewNodesAntiAffinity(List<Long> nodeIds, AffinityGroupVO affinityGroup, KubernetesCluster cluster) { | ||
| if (!"host anti-affinity".equalsIgnoreCase(affinityGroup.getType())) { |
Description
This PR adds support for specifying affinity groups during CKS (CloudStack Kubernetes Service) cluster creation, allowing users to control VM placement for high availability.
Changes:
nodeaffinitygroupsparameter forcreateKubernetesClusterAPIDesign doc:
https://cwiki.apache.org/confluence/display/CLOUDSTACK/Allow+users+to+select+affinity+group+during+managed+CKS+cluster+creation
Types of changes
Feature/Enhancement Scale or Bug Severity
Feature/Enhancement Scale
Bug Severity
cmk based api testing:
Screen recording
Screencast.from.2026-01-13.06-47-14.mp4
Screenshots
How Has This Been Tested?
How did you try to break this feature and the system with this change?