Skip to content

Commit a6c0ea1

Browse files
committed
fix(healthcheck): URL is required but set_healthcheck did not account for that
1 parent 4fe5d7c commit a6c0ea1

2 files changed

Lines changed: 12 additions & 0 deletions

File tree

rootfs/api/models/config.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,8 @@ def set_healthchecks(self):
6161
# fetch set health values and any defaults
6262
# this approach allows new health items to be added without issues
6363
health = self.healthcheck()
64+
if not health:
65+
return
6466

6567
# HTTP GET related
6668
self.values['HEALTHCHECK_URL'] = health['path']

rootfs/api/tests/test_config.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -644,6 +644,16 @@ def test_healthchecks(self, mock_requests):
644644
self.assertEqual(response.status_code, 201)
645645
app_id = response.data['id']
646646

647+
# Set healthcheck URL to get defaults set
648+
body = {'values': json.dumps({'HEALTHCHECK_INITIAL_DELAY': '25'})}
649+
resp = self.client.post(
650+
'/v2/apps/{app_id}/config'.format(**locals()),
651+
body
652+
)
653+
self.assertEqual(resp.status_code, 201)
654+
self.assertIn('HEALTHCHECK_INITIAL_DELAY', resp.data['values'])
655+
self.assertEqual(resp.data['values']['HEALTHCHECK_INITIAL_DELAY'], '25')
656+
647657
# Set healthcheck URL to get defaults set
648658
body = {'values': json.dumps({'HEALTHCHECK_URL': '/health'})}
649659
resp = self.client.post(

0 commit comments

Comments
 (0)