Changeset View
Changeset View
Standalone View
Standalone View
swh/icinga_plugins/vault.py
Show First 20 Lines • Show All 108 Lines • ▼ Show 20 Lines | def main(self): | ||||
"CRITICAL", | "CRITICAL", | ||||
f"cooking directory {dir_id.hex()} took {total_time:.2f}s " | f"cooking directory {dir_id.hex()} took {total_time:.2f}s " | ||||
f"and succeeded, but fetch failed with status code " | f"and succeeded, but fetch failed with status code " | ||||
f"{fetch_response.status_code}.", | f"{fetch_response.status_code}.", | ||||
total_time=total_time, | total_time=total_time, | ||||
) | ) | ||||
return 2 | return 2 | ||||
content_type = fetch_response.headers.get("Content-Type") | |||||
if content_type != "application/gzip": | |||||
self.print_result( | |||||
"CRITICAL", | |||||
f"Unexpected Content-Type when downloading bundle: {content_type}", | |||||
total_time=total_time, | |||||
) | |||||
return 2 | |||||
response_length = 0 | response_length = 0 | ||||
for chunk in fetch_response.iter_content(decode_unicode=False): | for chunk in fetch_response.iter_content(decode_unicode=False): | ||||
response_length += len(chunk) | response_length += len(chunk) | ||||
if response_length == 0: | if response_length == 0: | ||||
self.print_result( | self.print_result( | ||||
"CRITICAL", | "CRITICAL", | ||||
f"cooking directory {dir_id.hex()} took {total_time:.2f}s " | f"cooking directory {dir_id.hex()} took {total_time:.2f}s " | ||||
Show All 12 Lines |