Defensively handle errors examining app requests. #922
@ -274,34 +274,43 @@ def command(ctx, kube_config, laconic_config, image_registry, deployment_parent_
|
|||||||
requests_by_name = {}
|
requests_by_name = {}
|
||||||
skipped_by_name = {}
|
skipped_by_name = {}
|
||||||
for r in requests:
|
for r in requests:
|
||||||
if r.id in previous_requests and previous_requests[r.id].get("status", "") != "RETRY":
|
status = None
|
||||||
print(f"Skipping request {r.id}, we've already seen it.")
|
try:
|
||||||
continue
|
if r.id in previous_requests and previous_requests[r.id].get("status", "") != "RETRY":
|
||||||
|
print(f"Skipping request {r.id}, we've already seen it.")
|
||||||
|
continue
|
||||||
|
|
||||||
app = laconic.get_record(r.attributes.application)
|
app = laconic.get_record(r.attributes.application)
|
||||||
if not app:
|
if not app:
|
||||||
print("Skipping request %s, cannot locate app." % r.id)
|
print(f"Skipping request {r.id}, cannot locate app.")
|
||||||
continue
|
status = "SEEN"
|
||||||
|
continue
|
||||||
|
|
||||||
requested_name = r.attributes.dns
|
requested_name = r.attributes.dns
|
||||||
if not requested_name:
|
if not requested_name:
|
||||||
requested_name = generate_hostname_for_app(app)
|
requested_name = generate_hostname_for_app(app)
|
||||||
print("Generating name %s for request %s." % (requested_name, r.id))
|
print("Generating name %s for request %s." % (requested_name, r.id))
|
||||||
|
|
||||||
if requested_name in skipped_by_name or requested_name in requests_by_name:
|
if requested_name in skipped_by_name or requested_name in requests_by_name:
|
||||||
print("Ignoring request %s, it has been superseded." % r.id)
|
print("Ignoring request %s, it has been superseded." % r.id)
|
||||||
continue
|
continue
|
||||||
|
|
||||||
if skip_by_tag(r, include_tags, exclude_tags):
|
if skip_by_tag(r, include_tags, exclude_tags):
|
||||||
print("Skipping request %s, filtered by tag (include %s, exclude %s, present %s)" % (r.id,
|
print("Skipping request %s, filtered by tag (include %s, exclude %s, present %s)" % (r.id,
|
||||||
include_tags,
|
include_tags,
|
||||||
exclude_tags,
|
exclude_tags,
|
||||||
r.attributes.tags))
|
r.attributes.tags))
|
||||||
skipped_by_name[requested_name] = r
|
skipped_by_name[requested_name] = r
|
||||||
continue
|
continue
|
||||||
|
|
||||||
print("Found request %s to run application %s on %s." % (r.id, r.attributes.application, requested_name))
|
print("Found request %s to run application %s on %s." % (r.id, r.attributes.application, requested_name))
|
||||||
requests_by_name[requested_name] = r
|
requests_by_name[requested_name] = r
|
||||||
|
except Exception as e:
|
||||||
|
print(f"ERROR examining request {r.id}: " + str(e))
|
||||||
|
status = "ERROR"
|
||||||
|
finally:
|
||||||
|
if status:
|
||||||
|
dump_known_requests(state_file, [r], status)
|
||||||
|
|
||||||
# Find deployments.
|
# Find deployments.
|
||||||
deployments = laconic.app_deployments()
|
deployments = laconic.app_deployments()
|
||||||
|
@ -172,7 +172,7 @@ class LaconicRegistryClient:
|
|||||||
name_or_id,
|
name_or_id,
|
||||||
]
|
]
|
||||||
|
|
||||||
parsed = [AttrDict(r) for r in json.loads(logged_cmd(self.log_file, *args))]
|
parsed = [AttrDict(r) for r in json.loads(logged_cmd(self.log_file, *args)) if r]
|
||||||
if len(parsed):
|
if len(parsed):
|
||||||
self._add_to_cache(parsed)
|
self._add_to_cache(parsed)
|
||||||
return parsed[0]
|
return parsed[0]
|
||||||
|
Loading…
Reference in New Issue
Block a user