Skip to content

Commit

Permalink
enabling instant node count reset
Browse files Browse the repository at this point in the history
  • Loading branch information
dchourasia committed Nov 4, 2024
1 parent d92a698 commit 343a7ff
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/check_instances_status.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down

0 comments on commit 343a7ff

Please sign in to comment.