Skip to content

Commit 78bf064

Browse files
committed
Merge pull request #717 from helgi/rc_ready
ref(scheduler): move "is RC ready" into a new function
2 parents 47c679f + 1ceb842 commit 78bf064

1 file changed

Lines changed: 10 additions & 3 deletions

File tree

rootfs/scheduler/__init__.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -374,7 +374,7 @@ def deploy(self, namespace, name, image, command, **kwargs): # noqa
374374
logger.debug('RC {} already exists under Namespace {}. Stopping deploy'.format(name, namespace)) # noqa
375375
return
376376
except KubeHTTPException:
377-
new_rc = self._create_rc(namespace, name, image, command, **kwargs)
377+
new_rc = self._create_rc(namespace, name, image, command, **kwargs).json()
378378

379379
# Get the desired number to scale to
380380
if old_rc:
@@ -1053,6 +1053,15 @@ def _create_rc(self, namespace, name, image, command, **kwargs): # noqa
10531053
error(resp, 'create ReplicationController "{}" in Namespace "{}"', name, namespace)
10541054
logger.debug('template used: {}'.format(json.dumps(template, indent=4)))
10551055

1056+
self._wait_for_rc_ready(namespace, name)
1057+
1058+
return resp
1059+
1060+
def _wait_for_rc_ready(self, namespace, name):
1061+
"""
1062+
Waits for status/observedGeneration and metadata/generation to match
1063+
Indicates RC is ready
1064+
"""
10561065
for _ in range(30):
10571066
try:
10581067
rc = self._get_rc(namespace, name).json()
@@ -1067,8 +1076,6 @@ def _create_rc(self, namespace, name, image, command, **kwargs): # noqa
10671076
if e.response.status_code == 404:
10681077
time.sleep(1)
10691078

1070-
return resp.json()
1071-
10721079
def _update_rc(self, namespace, name, data):
10731080
url = self._api("/namespaces/{}/replicationcontrollers/{}", namespace, name)
10741081
response = self.session.put(url, json=data)

0 commit comments

Comments
 (0)