Skip to content

fix: when handling errors, program should exit after log

Jenny Kim requested to merge jk/exit-when-error into main

What

Addresses the problem of program hanging after logging an error message then successfully completing (exit code 0) when given either an invalid url or an empty url.

This also discovered that the check:generate_load_pages check is targetting a staging url that is currently unavailable, so we're removing it temporarily. (discussion thread)

For issue: delivery#19849 (closed)

Why

We were noticing that while some jobs like this one exit as expected (exit code 1, immediately) upon encountering an error, some jobs like this one that has an invalid url (instance wasn't available) would output an error code, but exit with exit code 0, after sleeping for the set duration.

locally reproducible:

./cmbr -instance "https://nonsense.none" -duration "1m"
ERRO[0000] request failed                                correlation_id= error="Get \"https://nonsense.none\": dial tcp: lookup nonsense.none: no such host" gitlab_server= status=0 url="https://nonsense.none"
# no output for the rest of 1m

./cmbr -instance "" -duration "1m"
ERRO[0000] failed to visit starting instance             error="Missing URL" url=
# no output for the rest of 1m

Turns out that in the case of the proper exit, Fatalf function was used in the logging process (code).

Initial thoughts were that the error log output did not exit the program because it would repeat the request for the remainder of the duration (but didn't output more errors), but debugging proved otherwise; it just sleeps for the rest of the duration set. It would be good to exit right after the error message in that case.

Edited by Jenny Kim

Merge request reports