From 343a7ff74c2372b4169c0f6fa3c9114b29fdade8 Mon Sep 17 00:00:00 2001 From: Deepak Chourasia Date: Mon, 4 Nov 2024 15:42:15 +0530 Subject: [PATCH] enabling instant node count reset --- src/check_instances_status.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/check_instances_status.py b/src/check_instances_status.py index c843a49..a49f226 100644 --- a/src/check_instances_status.py +++ b/src/check_instances_status.py @@ -146,6 +146,22 @@ def sync_hcp_node_pools(cluster:oc_cluster): if response.status_code == 200: totalNodes += newReplicas print(f'now total nodes are {totalNodes}') + + try: + if cluster.name == 'trustyai-rob': + payload = {'id': id,'labels':{},'taints':[],'replicas': replicas} + response = requests.patch(f'{api_server_base_url}/clusters_mgmt/v1/clusters/{cluster.id}/node_pools/{id}', + data=json.dumps(payload), + headers={'Authorization': f'Bearer {ocm_api_token}', 'Content-Type': 'application/json'}) + + print(f'reset the machine pool {id} with the original replica count {replicas} for cluster {cluster.name}') + print(response.status_code) + if response.status_code == 200: + totalNodes += replicas - newReplicas + print(f'now total nodes are back to {totalNodes}') + except: + print(traceback.format_exc()) + return totalNodes