From bea7d8933a6da98fbbaca140a6732bc9c91af21e Mon Sep 17 00:00:00 2001 From: Andrei Matveyeu Date: Mon, 14 Oct 2024 09:58:52 +0200 Subject: [PATCH] Revert "More robust testrunner validation retry logic (#80)" This reverts commit 0904d92fda153df1a361e6b787cbc1fb97d3c15f. --- python/src/etos_api/library/docker.py | 6 ++--- python/src/etos_api/library/validator.py | 28 ++++++++++++------------ 2 files changed, 16 insertions(+), 18 deletions(-) diff --git a/python/src/etos_api/library/docker.py b/python/src/etos_api/library/docker.py index 8e1ca04..8294189 100644 --- a/python/src/etos_api/library/docker.py +++ b/python/src/etos_api/library/docker.py @@ -92,10 +92,8 @@ async def authorize( else: query[key] = value.strip('"') - if not isinstance(url, str) or not ( - url.startswith("http://") or url.startswith("https://") - ): - raise ValueError(f"No realm URL found in www-authenticate header: {www_auth_header}") + if not url: + raise ValueError(f"No realm found in www-authenticate header: {www_auth_header}") async with session.get(url, params=query) as response: response.raise_for_status() diff --git a/python/src/etos_api/library/validator.py b/python/src/etos_api/library/validator.py index c35c530..68cab17 100644 --- a/python/src/etos_api/library/validator.py +++ b/python/src/etos_api/library/validator.py @@ -16,7 +16,11 @@ """ETOS API suite validator module.""" import logging import asyncio +<<<<<<< HEAD import time +======= +import random +>>>>>>> parent of 0904d92 (More robust testrunner validation retry logic (#80)) from typing import List, Union from uuid import UUID @@ -267,24 +271,20 @@ async def validate(self, test_suite_url): test_runners.add(constraint.value) docker = Docker() for test_runner in test_runners: - if await TestRunnerValidationCache.is_test_runner_valid(test_runner): - self.logger.info("Using cached test runner validation result: %s", test_runner) - continue - for attempt in range(5): - if attempt > 0: - span.add_event(f"Test runner validation unsuccessful, retry #{attempt}") - self.logger.warning( - "Test runner %s validation unsuccessful, retry #%d", - test_runner, - attempt, - ) + for attempt in range(3): result = await docker.digest(test_runner) if result: # only passed validations shall be cached await TestRunnerValidationCache.set_timestamp(test_runner, time.time()) break - # Total wait time with 5 attempts: 55 seconds - sleep_time = (attempt + 1) ** 2 - await asyncio.sleep(sleep_time) + span.add_event( + f"Test runner validation unsuccessful, retrying {3 - attempt} more times" + ) + self.logger.warning( + "Test runner %s validation unsuccessful, retrying %d more times", + test_runner, + 3 - attempt, + ) + await asyncio.sleep(random.randint(1, 3)) assert result is not None, f"Test runner {test_runner} not found"