-
Notifications
You must be signed in to change notification settings - Fork 36
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
hack/cleanup-ag: spurious affinity group cleaner #302
Conversation
This cleanup tool helps to remove CloudStack affinity groups from CAPC management cluster which are not assigned to any instances, which may have been created as a side effect of other operations. This tool checks all the cloudstackaffinitygroups using its CloudStack cluster specific credential(s) and uses cmk to check if the affinity group have no instances assigned. In dry-run, it outputs such affinity groups otherwise it deletes them. Signed-off-by: Rohit Yadav <[email protected]>
✅ Deploy Preview for kubernetes-sigs-cluster-api-cloudstack ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
/assign @vishesh92 |
Codecov ReportPatch and project coverage have no change.
Additional details and impacted files@@ Coverage Diff @@
## main #302 +/- ##
=======================================
Coverage 24.95% 24.95%
=======================================
Files 59 59
Lines 5558 5558
=======================================
Hits 1387 1387
Misses 4035 4035
Partials 136 136 ☔ View full report in Codecov by Sentry. |
Signed-off-by: Rohit Yadav <[email protected]>
Thanks @weizhouapache @vishesh92 - incorporated your comments, pl re-review. |
Signed-off-by: Rohit Yadav <[email protected]>
Signed-off-by: Rohit Yadav <[email protected]>
Signed-off-by: Rohit Yadav <[email protected]>
/hold Holding for manual QA cc @kiranchavala |
Signed-off-by: Rohit Yadav <[email protected]>
Thanks @chrisdoherty4 I've addressed the comments; Sample output: > ./cleanup-affinity-groups.sh -n default -v -d
[debug] [options] DRY_RUN=true
[debug] [options] VERBOSE=true
[debug] [options] NAMESPACE=default
[debug] [options] KUBECONFIG=/Users/rohit/.kube/config
[debug] Affinity groups in the namespace default:
antiaffinity-capc-cluster-control-plane-746e19e9-ea06-4ca3-b9b1-ebeb4753e6c7-failure-domain-1
antiaffinity-capc-cluster-md-0-7f8d8bf7c8x9hgbs-87c66d26-2f3c-4270-80b9-1ec8718a80fc-failure-domain-1
antiaffinity-capc-cluster-md-0-7f8d8bf7c8xxbz89-e6760745-3e51-4eb0-8352-3c04ff3fc40a-failure-domain-1
proaffinity-capc-cluster2-control-plane-f3cab1ca-32a0-4a41-ad2f-a681bd5a60c8-failure-domain-1
proaffinity-capc-cluster2-md-0-74f9cbf9dxj65ks-d9536d30-07dd-433d-bd93-c78e22f3a1dd-failure-domain-1
proaffinity-capc-cluster2-md-0-74f9cbf9dxxb468-7f429cd3-5ab5-4efe-9508-3bf75bf3f5a9-failure-domain-1
[info] Checking CloudStack Affinity Group: antiaffinity-capc-cluster-control-plane-746e19e9-ea06-4ca3-b9b1-ebeb4753e6c7-failure-domain-1
[debug] Using CloudStack Control Plane URL: http://192.168.1.10:8080/client/api and CloudStack Account: capc and User: capc
[info] Checking CloudStack Affinity Group: antiaffinity-capc-cluster-md-0-7f8d8bf7c8x9hgbs-87c66d26-2f3c-4270-80b9-1ec8718a80fc-failure-domain-1
[debug] Using CloudStack Control Plane URL: http://192.168.1.10:8080/client/api and CloudStack Account: capc and User: capc
[info] Checking CloudStack Affinity Group: antiaffinity-capc-cluster-md-0-7f8d8bf7c8xxbz89-e6760745-3e51-4eb0-8352-3c04ff3fc40a-failure-domain-1
[debug] Using CloudStack Control Plane URL: http://192.168.1.10:8080/client/api and CloudStack Account: capc and User: capc
[info] Found Affinity Group (2aaf526b-d27d-4881-81da-2eacaaa6af18) with no instances assigned: antiaffinity-capc-cluster-md-0-7f8d8bf7c8xxbz89-e6760745-3e51-4eb0-8352-3c04ff3fc40a-failure-domain-1
[info] [dryrun] Affinity Group (2aaf526b-d27d-4881-81da-2eacaaa6af18) antiaffinity-capc-cluster-md-0-7f8d8bf7c8xxbz89-e6760745-3e51-4eb0-8352-3c04ff3fc40a-failure-domain-1 has been removed
[info] Checking CloudStack Affinity Group: proaffinity-capc-cluster2-control-plane-f3cab1ca-32a0-4a41-ad2f-a681bd5a60c8-failure-domain-1
[debug] Using CloudStack Control Plane URL: http://192.168.1.10:8080/client/api and CloudStack Account: capc and User: capc
[info] Checking CloudStack Affinity Group: proaffinity-capc-cluster2-md-0-74f9cbf9dxj65ks-d9536d30-07dd-433d-bd93-c78e22f3a1dd-failure-domain-1
[debug] Using CloudStack Control Plane URL: http://192.168.1.10:8080/client/api and CloudStack Account: capc and User: capc
[info] Found Affinity Group (8461d42f-2b10-4d2b-b584-532b1cf09f0f) with no instances assigned: proaffinity-capc-cluster2-md-0-74f9cbf9dxj65ks-d9536d30-07dd-433d-bd93-c78e22f3a1dd-failure-domain-1
[info] [dryrun] Affinity Group (8461d42f-2b10-4d2b-b584-532b1cf09f0f) proaffinity-capc-cluster2-md-0-74f9cbf9dxj65ks-d9536d30-07dd-433d-bd93-c78e22f3a1dd-failure-domain-1 has been removed
[info] Checking CloudStack Affinity Group: proaffinity-capc-cluster2-md-0-74f9cbf9dxxb468-7f429cd3-5ab5-4efe-9508-3bf75bf3f5a9-failure-domain-1
[debug] Using CloudStack Control Plane URL: http://192.168.1.10:8080/client/api and CloudStack Account: capc and User: capc
[info] Found Affinity Group (2da2d9e4-caf8-4a35-965f-59782512e944) with no instances assigned: proaffinity-capc-cluster2-md-0-74f9cbf9dxxb468-7f429cd3-5ab5-4efe-9508-3bf75bf3f5a9-failure-domain-1
[info] [dryrun] Affinity Group (2da2d9e4-caf8-4a35-965f-59782512e944) proaffinity-capc-cluster2-md-0-74f9cbf9dxxb468-7f429cd3-5ab5-4efe-9508-3bf75bf3f5a9-failure-domain-1 has been removed Sample output with dryrun:
Sample output without dryrun or verbose: > ./cleanup-affinity-groups.sh -n default
[info] Checking CloudStack Affinity Group: antiaffinity-capc-cluster-control-plane-746e19e9-ea06-4ca3-b9b1-ebeb4753e6c7-failure-domain-1
[info] Checking CloudStack Affinity Group: antiaffinity-capc-cluster-md-0-7f8d8bf7c8x9hgbs-87c66d26-2f3c-4270-80b9-1ec8718a80fc-failure-domain-1
[info] Checking CloudStack Affinity Group: antiaffinity-capc-cluster-md-0-7f8d8bf7c8xxbz89-e6760745-3e51-4eb0-8352-3c04ff3fc40a-failure-domain-1
[info] Found Affinity Group (2aaf526b-d27d-4881-81da-2eacaaa6af18) with no instances assigned: antiaffinity-capc-cluster-md-0-7f8d8bf7c8xxbz89-e6760745-3e51-4eb0-8352-3c04ff3fc40a-failure-domain-1
cloudstackaffinitygroup.infrastructure.cluster.x-k8s.io "antiaffinity-capc-cluster-md-0-7f8d8bf7c8xxbz89-e6760745-3e51-4eb0-8352-3c04ff3fc40a-failure-domain-1" deleted
[info] Affinity Group (2aaf526b-d27d-4881-81da-2eacaaa6af18) antiaffinity-capc-cluster-md-0-7f8d8bf7c8xxbz89-e6760745-3e51-4eb0-8352-3c04ff3fc40a-failure-domain-1 has been removed
[info] Checking CloudStack Affinity Group: proaffinity-capc-cluster2-control-plane-f3cab1ca-32a0-4a41-ad2f-a681bd5a60c8-failure-domain-1
[info] Checking CloudStack Affinity Group: proaffinity-capc-cluster2-md-0-74f9cbf9dxj65ks-d9536d30-07dd-433d-bd93-c78e22f3a1dd-failure-domain-1
[info] Checking CloudStack Affinity Group: proaffinity-capc-cluster2-md-0-74f9cbf9dxxb468-7f429cd3-5ab5-4efe-9508-3bf75bf3f5a9-failure-domain-1
[info] Found Affinity Group (2da2d9e4-caf8-4a35-965f-59782512e944) with no instances assigned: proaffinity-capc-cluster2-md-0-74f9cbf9dxxb468-7f429cd3-5ab5-4efe-9508-3bf75bf3f5a9-failure-domain-1
cloudstackaffinitygroup.infrastructure.cluster.x-k8s.io "proaffinity-capc-cluster2-md-0-74f9cbf9dxxb468-7f429cd3-5ab5-4efe-9508-3bf75bf3f5a9-failure-domain-1" deleted
[info] Affinity Group (2da2d9e4-caf8-4a35-965f-59782512e944) proaffinity-capc-cluster2-md-0-74f9cbf9dxxb468-7f429cd3-5ab5-4efe-9508-3bf75bf3f5a9-failure-domain-1 has been removed |
Signed-off-by: Rohit Yadav <[email protected]>
/lgtm |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
lgtm |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/lgtm
Tested the tool manually and its working fine with all options
./cleanup-affinity-groups.sh -d
./cleanup-affinity-groups.sh -v
./cleanup-affinity-groups.sh
./cleanup-affinity-groups.sh -n default
./cleanup-affinity-groups.sh -n default -v -d
./cleanup-affinity-groups.sh -n default -d
@kiranchavala: changing LGTM is restricted to collaborators In response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
/unhold |
/approve |
@rohityadavcloud: you cannot LGTM your own PR. In response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: chrisdoherty4, kiranchavala, rohityadavcloud, weizhouapache The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
Issue #, if available:
Related to #240
Description of changes:
This cleanup tool helps to remove CloudStack affinity groups from CAPC management cluster which are not assigned to any instances, which may have been created as a side effect of other operations. This tool checks all the cloudstackaffinitygroups using its CloudStack cluster specific credential(s) and uses cmk to check if the affinity group have no instances assigned. In dry-run, it outputs such affinity groups otherwise it deletes them.
Testing performed:
anti
orpro
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.