From a28b151d3c565b52eaf8a728ed4304a8579e340f Mon Sep 17 00:00:00 2001 From: Srihari Date: Wed, 11 Mar 2026 17:00:02 +0530 Subject: [PATCH] fix: Fix regstry Rest API tests intermittent failure Signed-off-by: Srihari --- sdk/python/feast/infra/registry/sql.py | 22 ++++++++++++------- .../tests/integration/rest_api/conftest.py | 15 +++++++++++-- 2 files changed, 27 insertions(+), 10 deletions(-) diff --git a/sdk/python/feast/infra/registry/sql.py b/sdk/python/feast/infra/registry/sql.py index 2332d0fb3d0..e76291cdb01 100644 --- a/sdk/python/feast/infra/registry/sql.py +++ b/sdk/python/feast/infra/registry/sql.py @@ -302,15 +302,21 @@ def _sync_feast_metadata_to_projects_table(self): # Find object in feast_metadata_projects but not in projects projects_to_sync = set(feast_metadata_projects.keys()) - set(projects_set) for project_name in projects_to_sync: - self.apply_project( - Project( - name=project_name, - created_timestamp=datetime.fromtimestamp( - feast_metadata_projects[project_name], tz=timezone.utc + try: + self.apply_project( + Project( + name=project_name, + created_timestamp=datetime.fromtimestamp( + feast_metadata_projects[project_name], tz=timezone.utc + ), ), - ), - commit=True, - ) + commit=True, + ) + except IntegrityError: + logger.info( + "Project %s already created in projects table by another process.", + project_name, + ) if self.purge_feast_metadata: with self.write_engine.begin() as conn: diff --git a/sdk/python/tests/integration/rest_api/conftest.py b/sdk/python/tests/integration/rest_api/conftest.py index 6e55d5825f2..d7aa0b4a3c5 100644 --- a/sdk/python/tests/integration/rest_api/conftest.py +++ b/sdk/python/tests/integration/rest_api/conftest.py @@ -37,7 +37,12 @@ def get(self, endpoint, params=None): return requests.get(url, params=params, verify=False) -def _wait_for_http_ready(route_url: str, timeout: int = 180, interval: int = 5) -> None: +def _wait_for_http_ready( + route_url: str, + timeout: int = 300, + interval: int = 5, + initial_delay: int = 30, +) -> None: """ Poll the HTTP endpoint until it returns a non-502 response. @@ -46,9 +51,15 @@ def _wait_for_http_ready(route_url: str, timeout: int = 180, interval: int = 5) start before the Feast server is ready, causing all requests to return 502. """ health_url = f"{route_url}/api/v1/projects" - deadline = time.time() + timeout last_status = None + if initial_delay > 0: + print( + f"\n Waiting {initial_delay}s for backend to start after apply/dataset creation..." + ) + time.sleep(initial_delay) + + deadline = time.time() + timeout print( f"\n Waiting for HTTP endpoint to become ready (timeout={timeout}s): {health_url}" )