From 3e0bafac4baf15f813c9f7240461fb4e9c50e6db Mon Sep 17 00:00:00 2001 From: Andrei Matveyeu Date: Thu, 6 Mar 2025 10:25:21 +0100 Subject: [PATCH 1/5] library/environment.py: increase etcd lease time Change-Id: Iff3c6c30ff0db23e916630ec5b4c51666adc72c1 --- python/src/etos_api/library/environment.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/python/src/etos_api/library/environment.py b/python/src/etos_api/library/environment.py index f7a458a..d05c3b9 100644 --- a/python/src/etos_api/library/environment.py +++ b/python/src/etos_api/library/environment.py @@ -82,7 +82,7 @@ async def load(path: ETCDPath) -> Optional[dict]: return None -async def save_json(path: ETCDPath, data: dict, expire=3600) -> None: +async def save_json(path: ETCDPath, data: dict, expire=86400) -> None: """Save data as json to an ETCD path. :param path: The path to store data on. From 342dd2318290fee3cdf117f736660daf705789ae Mon Sep 17 00:00:00 2001 From: Andrei Matveyeu Date: Fri, 7 Mar 2025 10:49:30 +0100 Subject: [PATCH 2/5] use configuration parameter for etcd lease expiration time Change-Id: I39e641c746893c682e9a7f5715dea8641c907fff --- python/src/etos_api/library/environment.py | 13 +++++++++---- python/src/etos_api/routers/v0/router.py | 2 +- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/python/src/etos_api/library/environment.py b/python/src/etos_api/library/environment.py index d05c3b9..e942a65 100644 --- a/python/src/etos_api/library/environment.py +++ b/python/src/etos_api/library/environment.py @@ -33,10 +33,11 @@ class Configuration(BaseModel): log_area_provider: str -async def configure_testrun(configuration: Configuration) -> None: +async def configure_testrun(configuration: Configuration, expire: int) -> None: """Configure an ETOS testrun with the configuration passed by user. :param configuration: The configuration to save. + :param expire: etcd lease expiration time in seconds """ testrun = ETCDPath(f"/testrun/{configuration.suite_id}") providers = ETCDPath("/environment/provider") @@ -45,30 +46,34 @@ async def configure_testrun(configuration: Configuration) -> None: providers.join(f"log-area/{configuration.log_area_provider}"), configuration.log_area_provider, testrun.join("provider/log-area"), + expire, ) await do_configure( providers.join(f"execution-space/{configuration.execution_space_provider}"), configuration.execution_space_provider, testrun.join("provider/execution-space"), + expire, ) await do_configure( providers.join(f"iut/{configuration.iut_provider}"), configuration.iut_provider, testrun.join("provider/iut"), + expire, ) await save_json(testrun.join("provider/dataset"), configuration.dataset) -async def do_configure(path: ETCDPath, provider_id: str, testrun: ETCDPath) -> None: +async def do_configure(path: ETCDPath, provider_id: str, testrun: ETCDPath, expire: int) -> None: """Configure a provider based on provider ID and save it to a testrun. :param path: Path to load provider from. :param provider_id: The ID of the provider to load. :param testrun: Where to store the loaded provider. + :param expire: etcd lease expiration time in seconds """ if (provider := await load(path)) is None: raise AssertionError(f"{provider_id} does not exist") - await save_json(testrun, provider) + await save_json(testrun, provider, expire) async def load(path: ETCDPath) -> Optional[dict]: @@ -82,7 +87,7 @@ async def load(path: ETCDPath) -> Optional[dict]: return None -async def save_json(path: ETCDPath, data: dict, expire=86400) -> None: +async def save_json(path: ETCDPath, data: dict, expire: int) -> None: """Save data as json to an ETCD path. :param path: The path to store data on. diff --git a/python/src/etos_api/routers/v0/router.py b/python/src/etos_api/routers/v0/router.py index 6e412ce..5a0c2ed 100644 --- a/python/src/etos_api/routers/v0/router.py +++ b/python/src/etos_api/routers/v0/router.py @@ -152,7 +152,7 @@ async def _start(etos: StartEtosRequest, span: Span) -> dict: log_area_provider=etos.log_area_provider, ) try: - await configure_testrun(config) + await configure_testrun(config, etos_library.debug.default_test_result_timeout) except AssertionError as exception: LOGGER.critical(exception) raise HTTPException( From fc92f052cb88ac99837ebe6015e1d0a8b0e178b5 Mon Sep 17 00:00:00 2001 From: Andrei Matveyeu Date: Fri, 7 Mar 2025 10:53:46 +0100 Subject: [PATCH 3/5] minor fix Change-Id: If2d73d340d757a56d0d604d6d50151218e97dab1 --- python/src/etos_api/library/environment.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/python/src/etos_api/library/environment.py b/python/src/etos_api/library/environment.py index e942a65..c8619c2 100644 --- a/python/src/etos_api/library/environment.py +++ b/python/src/etos_api/library/environment.py @@ -60,7 +60,7 @@ async def configure_testrun(configuration: Configuration, expire: int) -> None: testrun.join("provider/iut"), expire, ) - await save_json(testrun.join("provider/dataset"), configuration.dataset) + await save_json(testrun.join("provider/dataset"), configuration.dataset, expire) async def do_configure(path: ETCDPath, provider_id: str, testrun: ETCDPath, expire: int) -> None: From 58bbae326cf1ef9ed2a33678a407646aa49f10e1 Mon Sep 17 00:00:00 2001 From: Andrei Matveyeu Date: Fri, 7 Mar 2025 12:05:13 +0100 Subject: [PATCH 4/5] add safety margin for etcd leases Change-Id: Ib32c7b9bea282f88bf4bb5c7e728f675ab76fb3c --- python/src/etos_api/routers/v0/router.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/python/src/etos_api/routers/v0/router.py b/python/src/etos_api/routers/v0/router.py index 5a0c2ed..28f20f4 100644 --- a/python/src/etos_api/routers/v0/router.py +++ b/python/src/etos_api/routers/v0/router.py @@ -152,7 +152,9 @@ async def _start(etos: StartEtosRequest, span: Span) -> dict: log_area_provider=etos.log_area_provider, ) try: - await configure_testrun(config, etos_library.debug.default_test_result_timeout) + # 10 minutes safety margin for etcd configuration entries + etcd_lease_expiration_time = etos_library.debug.default_test_result_timeout + 10 * 60 + await configure_testrun(config, etcd_lease_expiration_time) except AssertionError as exception: LOGGER.critical(exception) raise HTTPException( From be9e45c6d98b78ba0705192be3d4f69d899c07e8 Mon Sep 17 00:00:00 2001 From: Andrei Matveyeu Date: Fri, 7 Mar 2025 12:07:35 +0100 Subject: [PATCH 5/5] comment fix Change-Id: I15ec379849bbfabd242274b4cb46eec45403ec93 --- python/src/etos_api/routers/v0/router.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/python/src/etos_api/routers/v0/router.py b/python/src/etos_api/routers/v0/router.py index 28f20f4..eda36c0 100644 --- a/python/src/etos_api/routers/v0/router.py +++ b/python/src/etos_api/routers/v0/router.py @@ -152,7 +152,7 @@ async def _start(etos: StartEtosRequest, span: Span) -> dict: log_area_provider=etos.log_area_provider, ) try: - # 10 minutes safety margin for etcd configuration entries + # etcd lease expiration will have 10 minutes safety margin: etcd_lease_expiration_time = etos_library.debug.default_test_result_timeout + 10 * 60 await configure_testrun(config, etcd_lease_expiration_time) except AssertionError as exception: