Skip to content

Commit 0f59a4f

Browse files
committed
correction
Signed-off-by: Matthias Büchse <[email protected]>
1 parent 346e120 commit 0f59a4f

File tree

1 file changed

+20
-20
lines changed

1 file changed

+20
-20
lines changed

Tests/kaas/plugin/plugin_clusterstacks.py

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -113,26 +113,26 @@ def create_cluster(self):
113113
# 409 means that the object already exists; don't treat that as error
114114
if e.status != 409:
115115
raise
116-
name = self.config['name']
117-
secret_name = f'{name}-kubeconfig'
118-
api_instance = kubernetes.client.CustomObjectsApi(api_client)
119-
while True:
120-
# mimic `kubectl get machines` (it's a bit more involved with the API)
121-
res = api_instance.list_namespaced_custom_object('cluster.x-k8s.io', 'v1beta1', self.namespace, 'machines')
122-
items = [
123-
(item['metadata']['name'], item['status']['phase'].lower())
124-
for item in res['items']
125-
if item['spec']['clusterName'] == name
126-
]
127-
working = [item[0] for item in items if item[1] != 'provisioned']
128-
if not working:
129-
break
130-
logger.debug('waiting 30 s for machines to become ready:', items)
131-
time.sleep(30)
132-
# mimic `kubectl get secrets NAME -o=jsonpath='{.data.value}' | base64 -d > kubeconfig.yaml`
133-
res = kubernetes.client.CoreV1Api(api_client).read_namespaced_secret(secret_name, self.namespace)
134-
with open(os.path.join(self.cwd, 'kubeconfig.yaml'), 'wb') as fileobj:
135-
fileobj.write(base64.standard_b64decode(res.data['value'].encode()))
116+
name = self.config['name']
117+
secret_name = f'{name}-kubeconfig'
118+
api_instance = kubernetes.client.CustomObjectsApi(api_client)
119+
while True:
120+
# mimic `kubectl get machines` (it's a bit more involved with the API)
121+
res = api_instance.list_namespaced_custom_object('cluster.x-k8s.io', 'v1beta1', self.namespace, 'machines')
122+
items = [
123+
(item['metadata']['name'], item['status']['phase'].lower())
124+
for item in res['items']
125+
if item['spec']['clusterName'] == name
126+
]
127+
working = [item[0] for item in items if item[1] != 'provisioned']
128+
if not working:
129+
break
130+
logger.debug('waiting 30 s for machines to become ready:', items)
131+
time.sleep(30)
132+
# mimic `kubectl get secrets NAME -o=jsonpath='{.data.value}' | base64 -d > kubeconfig.yaml`
133+
res = kubernetes.client.CoreV1Api(api_client).read_namespaced_secret(secret_name, self.namespace)
134+
with open(os.path.join(self.cwd, 'kubeconfig.yaml'), 'wb') as fileobj:
135+
fileobj.write(base64.standard_b64decode(res.data['value'].encode()))
136136

137137
def delete_cluster(self):
138138
cluster_name = self.config['name']

0 commit comments

Comments
 (0)