Skip to content

Commit 14b8527

Browse files
committed
Merge pull request #564 from helgi/healthcheck_container
fix(scheduler): apply healthcheck to the right application container instead of assuming
2 parents a959ded + 0f23722 commit 14b8527

1 file changed

Lines changed: 8 additions & 4 deletions

File tree

rootfs/scheduler/__init__.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -917,7 +917,8 @@ def _delete_rc(self, namespace, name):
917917

918918
def _healthcheck(self, controller, path='/', port=8080, delay=30, timeout=1):
919919
# FIXME this logic ideally should live higher up
920-
if controller['spec']['selector']['type'] not in ['web', 'cmd']:
920+
app_type = controller['spec']['selector']['type']
921+
if app_type not in ['web', 'cmd']:
921922
return controller
922923

923924
namespace = controller['spec']['selector']['app']
@@ -956,9 +957,12 @@ def _healthcheck(self, controller, path='/', port=8080, delay=30, timeout=1):
956957
},
957958
}
958959

959-
# Because it comes from a JSON template, need to hit the first key
960-
# FIXME: assumption that container 0 is the app
961-
controller['spec']['template']['spec']['containers'][0].update(healthcheck)
960+
# Update only the application container with the health check
961+
container_name = '{}-{}'.format(namespace, app_type)
962+
containers = controller['spec']['template']['spec']['containers']
963+
for container in containers:
964+
if container['name'] == container_name:
965+
container.update(healthcheck)
962966

963967
return controller
964968

0 commit comments

Comments
 (0)