Skip to content

Commit

Permalink
k3s: exit update_ip_alias when more than 2mn have passed
Browse files Browse the repository at this point in the history
  • Loading branch information
karmab committed Mar 16, 2024
1 parent 3ae6ab6 commit e1d8f12
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions kvirt/cluster/k3s/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,20 @@


def update_ip_alias(config, nodes):
timeout = 0
cmd_one = ['kubectl', 'get', 'nodes', '-o=jsonpath={range .items[?(@.spec.podCIDR)]}{.metadata.name}{\'\\n\'}{end}']
while True:
if timeout > 240:
error(f"Timeout waiting for {nodes} nodes to have a Pod CIDR assigned")
return
pprint(f"Waiting 5s for {nodes} nodes to have a Pod CIDR assigned")
result = run(cmd_one, capture_output=True, text=True)
current_nodes = len(result.stdout.splitlines())
if current_nodes == nodes:
break
else:
sleep(5)
timeout += 5
for node in yaml.safe_load(os.popen("kubectl get node -o yaml").read())['items']:
try:
name, pod_cidr = node['metadata']['name'], node['spec']['podCIDR']
Expand Down

0 comments on commit e1d8f12

Please sign in to comment.