Skip to content

Commit

Permalink
Add a 30s sleep as work around for log download race (#109)
Browse files Browse the repository at this point in the history
* Add a 30s sleep as work around for log download race

We have no guarantee that all the logs have been downloaded when
we remove the main and sub suites from ETCD. This gives a potential
log area provider and the client a little more time to facilitate
download of the logs that were created last in the test run.

Also included a fix for an old annoying bug that provided a lackluster
error message to the user.
  • Loading branch information
fredjn authored Aug 30, 2024
1 parent 3d1c4c9 commit 9abd94d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
8 changes: 8 additions & 0 deletions src/environment_provider/environment.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
# limitations under the License.
"""Backend for the environment requests."""
import json
import time
import traceback
from typing import Optional, Union

Expand Down Expand Up @@ -121,6 +122,13 @@ def release_full_environment(etos: ETOS, jsontas: JsonTas, suite_id: str) -> tup
"""
failure = None
registry = ProviderRegistry(etos, jsontas, suite_id)
# TODO: Remove the sleeping when we can communicate the log urls to the
# etos-client using internal messaging via SSE.
#
# We need to sleep here for a while to prevent us from deleting the
# references to the last log files created. This is to ensure that
# etos-client has enough time to find and download them.
time.sleep(30)
for suite, metadata in registry.testrun.join("suite").read_all():
suite = json.loads(suite)
for sub_suite in suite.get("sub_suites", []):
Expand Down
4 changes: 3 additions & 1 deletion src/environment_provider/environment_provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -564,7 +564,9 @@ def run(self) -> dict:
except Exception as exception: # pylint:disable=broad-except
self.cleanup()
traceback.print_exc()
self.logger.error("Failed creating environment for test. %r", extra={"user_log": True})
self.logger.error(
"Failed creating environment for test. %r", exception, extra={"user_log": True}
)
return {"error": str(exception), "details": traceback.format_exc()}
finally:
if self.etos.publisher is not None and not self.etos.debug.disable_sending_events:
Expand Down

0 comments on commit 9abd94d

Please sign in to comment.