Browse Source

Use a status code to detect unknown vs. missing tenant

Re-use http status codes for this, since it's just arbitrary
machine-reable info for now anyway and that way we can just splat the
payload into the HTTPNotFound when it's missing.
Use 204 for the tenant not being ready yet, since it's a valid request
there just isn't any data right now.

Change-Id: Ife3de557d48a12c85671643877106479e77d7fd6
changes/79/545879/3
Monty Taylor 4 years ago
parent
commit
30db1d979a
No known key found for this signature in database GPG Key ID: 7BAE94BC7141A594
  1. 11
      zuul/scheduler.py
  2. 4
      zuul/web/__init__.py

11
zuul/scheduler.py

@ -1153,10 +1153,15 @@ class Scheduler(threading.Thread):
tenant = self.abide.tenants.get(tenant_name)
if not tenant:
if tenant_name not in self.unparsed_abide.known_tenants:
return json.dumps({"message": "Unknown tenant"})
return json.dumps({
"message": "Unknown tenant",
"code": 404
})
self.log.warning("Tenant %s isn't loaded" % tenant_name)
return json.dumps(
{"message": "Tenant %s isn't ready" % tenant_name})
return json.dumps({
"message": "Tenant %s isn't ready" % tenant_name,
"code": 204
})
for pipeline in tenant.layout.pipelines.values():
pipelines.append(pipeline.formatStatusJSON(websocket_url))
return json.dumps(data)

4
zuul/web/__init__.py

@ -172,8 +172,8 @@ class GearmanHandler(object):
self.cache[tenant] = json.loads(job.data[0])
self.cache_time[tenant] = time.time()
payload = self.cache[tenant]
if payload.get('message') == 'Unknown tenant':
return web.HTTPNotFound()
if payload.get('code') == 404:
return web.HTTPNotFound(reason=payload['message'])
if result_filter:
payload = result_filter.filterPayload(payload)
resp = web.json_response(payload)

Loading…
Cancel
Save