Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

server,cks: check if vm is cks node during vm destroy #9057

Draft
wants to merge 6 commits into
base: 4.19
Choose a base branch
from

Conversation

shwstppr
Copy link
Contributor

@shwstppr shwstppr commented May 8, 2024

Description

Fixes #8902

Types of changes

  • Breaking change (fix or feature that would cause existing functionality to change)
  • New feature (non-breaking change which adds functionality)
  • Bug fix (non-breaking change which fixes an issue)
  • Enhancement (improves an existing feature and functionality)
  • Cleanup (Code refactoring and cleanup, that may add test cases)
  • build/CI

Feature/Enhancement Scale or Bug Severity

Feature/Enhancement Scale

  • Major
  • Minor

Bug Severity

  • BLOCKER
  • Critical
  • Major
  • Minor
  • Trivial

Screenshots (if appropriate):

How Has This Been Tested?

How did you try to break this feature and the system with this change?

Fixes apache#8902

Signed-off-by: Abhishek Kumar <abhishek.mrt22@gmail.com>
@codecov-commenter
Copy link

codecov-commenter commented May 8, 2024

Codecov Report

Attention: Patch coverage is 29.78723% with 33 lines in your changes are missing coverage. Please review.

Project coverage is 14.96%. Comparing base (87e7c57) to head (11b2156).
Report is 5 commits behind head on 4.19.

Files Patch % Lines
...va/com/cloud/utils/component/ComponentContext.java 0.00% 14 Missing ⚠️
.../src/main/java/com/cloud/vm/UserVmManagerImpl.java 0.00% 10 Missing ⚠️
...tes/cluster/dao/KubernetesClusterVmMapDaoImpl.java 0.00% 8 Missing ⚠️
...ubernetes/cluster/KubernetesClusterHelperImpl.java 93.33% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##               4.19    #9057      +/-   ##
============================================
- Coverage     14.96%   14.96%   -0.01%     
+ Complexity    10995    10988       -7     
============================================
  Files          5373     5373              
  Lines        469005   469071      +66     
  Branches      58953    61186    +2233     
============================================
- Hits          70198    70184      -14     
- Misses       391036   391120      +84     
+ Partials       7771     7767       -4     
Flag Coverage Δ
uitests 4.31% <ø> (ø)
unittests 15.66% <29.78%> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Signed-off-by: Abhishek Kumar <abhishek.mrt22@gmail.com>
@weizhouapache
Copy link
Member

@shwstppr
I am not sure if we should disallow the operation.

would it be a valid use case for users to

  • drain the node in CKS
  • remove the node vm from cloudstack
  • scale the cks cluster to get a new node

for your information, in Autoscale VM group, users can destroy a specific VM when the vm group is disabled.
the corresponding reference/map in database and load balancer rules are also removed.
of course, cks cluster is totally different from AS vm group.

Copy link
Contributor

@sureshanaparti sureshanaparti left a comment

Choose a reason for hiding this comment

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

clgtm

return;
}
logger.error(String.format("VM ID: %s is a part of Kubernetes cluster ID: %d", userVm.getId(), vmMapVO.getClusterId()));
throw new CloudRuntimeException("Instance is a part of a Kubernetes cluster");
Copy link
Contributor

Choose a reason for hiding this comment

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

specify the Kubernetes cluster id/name in the msg passed to the response?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

will add


@Override
public ControlledEntity findByUuid(String uuid) {
return kubernetesClusterDao.findByUuid(uuid);
}

@Override
public void checkVmCanBeDestroyed(UserVm userVm) {
Copy link
Contributor

Choose a reason for hiding this comment

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

can destroy allowed with force option?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

do you mean adding a new API param as there is no force param in destroyVirtualMachine?

Copy link
Contributor

Choose a reason for hiding this comment

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

yes, with force param in destroy call.

Copy link
Member

Choose a reason for hiding this comment

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

+1

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@sureshanaparti @vishesh92 I'm not completely in favour of adding the parameter. Deleting specific node of a k8s cluster is already covered by scaleKubernetesCluster API
see #9057 (comment)

Do we have any other specific case for which we should allow the operation?

@sureshanaparti sureshanaparti added this to the 4.19.1.0 milestone May 8, 2024
@shwstppr
Copy link
Contributor Author

shwstppr commented May 8, 2024

@shwstppr I am not sure if we should disallow the operation.

would it be a valid use case for users to

* drain the node in CKS

* remove the node vm from cloudstack

* scale the cks cluster to get a new node

for your information, in Autoscale VM group, users can destroy a specific VM when the vm group is disabled. the corresponding reference/map in database and load balancer rules are also removed. of course, cks cluster is totally different from AS vm group.

@weizhouapache understood. Though destroying a valid cks node is also allowed right now.
@Pearl1594 @nvazquez do we plan to add an API to remove a VM/node from CKS cluster?
If there is, then the case mentioned by Wei should get handled? User can:

  • drain node
  • remove it from k8s cluster
  • destroy the vm

@weizhouapache
Copy link
Member

@shwstppr I am not sure if we should disallow the operation.
would it be a valid use case for users to

* drain the node in CKS

* remove the node vm from cloudstack

* scale the cks cluster to get a new node

for your information, in Autoscale VM group, users can destroy a specific VM when the vm group is disabled. the corresponding reference/map in database and load balancer rules are also removed. of course, cks cluster is totally different from AS vm group.

@weizhouapache understood. Though destroying a valid cks node is also allowed right now. @Pearl1594 @nvazquez do we plan to add an API to remove a VM/node from CKS cluster? If there is, then the case mentioned by Wei should get handled? User can:

  • drain node
  • remove it from k8s cluster
  • destroy the vm

thanks @shwstppr
looks like a good idea to add a new API .

@shwstppr shwstppr marked this pull request as draft May 9, 2024 10:58
@shwstppr
Copy link
Contributor Author

shwstppr commented May 9, 2024

@weizhouapache on the special case discussed earlier, @Pearl1594 made me aware that we already have an option with scaleKubernetesCluster API to delete a specific node using nodeids param. We also show a delete action in the UI so the use-case that you mentioned should get covered by that,
image

Signed-off-by: Abhishek Kumar <abhishek.mrt22@gmail.com>
Signed-off-by: Abhishek Kumar <abhishek.mrt22@gmail.com>
@weizhouapache
Copy link
Member

@weizhouapache on the special case discussed earlier, @Pearl1594 made me aware that we already have an option with scaleKubernetesCluster API to delete a specific node using nodeids param. We also show a delete action in the UI so the use-case that you mentioned should get covered by that,
image

That is great, thanks @shwstppr

Overall this pr looks good to me.

Can we add the information above in the error message, if user tries to delete a cks node?

Signed-off-by: Abhishek Kumar <abhishek.mrt22@gmail.com>
@shwstppr
Copy link
Contributor Author

@blueorangutan package

@blueorangutan
Copy link

@shwstppr a [SL] Jenkins job has been kicked to build packages. It will be bundled with KVM, XenServer and VMware SystemVM templates. I'll keep you posted as I make progress.

@blueorangutan
Copy link

Packaging result [SF]: ✖️ el7 ✖️ el8 ✖️ el9 ✖️ debian ✖️ suse15. SL-JID 9656

Signed-off-by: Abhishek Kumar <abhishek.mrt22@gmail.com>
@shwstppr
Copy link
Contributor Author

@blueorangutan package

@blueorangutan
Copy link

@shwstppr a [SL] Jenkins job has been kicked to build packages. It will be bundled with KVM, XenServer and VMware SystemVM templates. I'll keep you posted as I make progress.

@blueorangutan
Copy link

Packaging result [SF]: ✔️ el7 ✔️ el8 ✔️ el9 ✔️ debian ✔️ suse15. SL-JID 9665

@shwstppr
Copy link
Contributor Author

@blueorangutan package

@blueorangutan
Copy link

@shwstppr a [SL] Jenkins job has been kicked to build packages. It will be bundled with KVM, XenServer and VMware SystemVM templates. I'll keep you posted as I make progress.

@blueorangutan
Copy link

Packaging result [SF]: ✔️ el7 ✔️ el8 ✔️ el9 ✔️ debian ✔️ suse15. SL-JID 9695

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: In Progress
Development

Successfully merging this pull request may close these issues.

None yet

7 participants