Skip to content

Commit 9001382

Browse files
authored
Merge pull request #869 from helgi/remove_get_rc_status
ref(scheduler): remove get_rc_status in favour of using built in handling
2 parents 8decd83 + 1123837 commit 9001382

1 file changed

Lines changed: 12 additions & 14 deletions

File tree

rootfs/scheduler/__init__.py

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -229,15 +229,18 @@ def _update_application_service(self, namespace, name, app_type, port, routable=
229229
def scale(self, namespace, name, image, command, **kwargs):
230230
logger.info('scale {}, img {}, cmd "{}"'.format(name, image, command))
231231
replicas = kwargs.pop('replicas')
232-
if unhealthy(self.get_rc_status(namespace, name)):
233-
# add RC if it is missing for the namespace
234-
try:
235-
# Create RC with scale as 0 and then scale to get pod monitoring
236-
kwargs['replicas'] = 0
237-
self.create_rc(namespace, name, image, command, **kwargs)
238-
except KubeException:
239-
logger.exception("Creating RC {} failed}".format(name))
240-
raise
232+
try:
233+
self.get_rc(namespace, name)
234+
except KubeHTTPException as e:
235+
if e.response.status_code == 404:
236+
# add RC if it is missing for the namespace
237+
try:
238+
# Create RC with scale as 0 and then scale to get pod monitoring
239+
kwargs['replicas'] = 0
240+
self.create_rc(namespace, name, image, command, **kwargs)
241+
except KubeException:
242+
logger.exception("Creating RC {} failed".format(name))
243+
raise
241244

242245
# let the scale failure bubble up
243246
self._scale_rc(namespace, name, replicas)
@@ -708,11 +711,6 @@ def get_old_rc(self, namespace, app_type):
708711

709712
return controllers['items'][0]
710713

711-
def get_rc_status(self, namespace, name):
712-
url = self._api("/namespaces/{}/replicationcontrollers/{}", namespace, name)
713-
resp = self.session.get(url)
714-
return resp.status_code
715-
716714
def get_rc(self, namespace, name):
717715
url = self._api("/namespaces/{}/replicationcontrollers/{}", namespace, name)
718716
response = self.session.get(url)

0 commit comments

Comments
 (0)