Skip to content

Commit 081a12c

Browse files
authored
Merge pull request #220 from openzim/healthcheck-fixes
fix wrong collections URL and success
2 parents 1631e9f + 00dc112 commit 081a12c

2 files changed

Lines changed: 7 additions & 7 deletions

File tree

healthcheck/src/healthcheck/status/auth.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ async def _generate_oauth_access_token(self) -> None:
4949
Context.cms_oauth_client_id, Context.cms_oauth_client_secret
5050
),
5151
timeout=Context.requests_timeout,
52-
check_name="zimfarm-api-authentication",
52+
check_name="cms-api-authentication",
5353
)
5454
if response.json:
5555
self._access_token = cast(str, response.json["access_token"])
@@ -58,7 +58,7 @@ async def _generate_oauth_access_token(self) -> None:
5858
)
5959

6060
async def _generate_local_access_token(self) -> None:
61-
check_name = "zimfarm-api-authentication"
61+
check_name = "cms-api-authentication"
6262
if self._refresh_token:
6363
response = await query_api(
6464
f"{Context.cms_api_url}/auth/refresh",
@@ -135,13 +135,13 @@ async def authenticate() -> Result[Token]:
135135
f"{Context.cms_api_url}/auth/me",
136136
method="GET",
137137
headers={"Authorization": f"Bearer {token.access_token}"},
138-
check_name="zimfarm-api-authentication",
138+
check_name="cms-api-authentication",
139139
)
140140

141141
if response.success:
142142
logger.debug(
143143
f"Authentication successful using {Context.auth_mode} mode",
144-
extra={"checkname": "zimfarm-api-authentication"},
144+
extra={"checkname": "cms-api-authentication"},
145145
)
146146

147147
return Result(

healthcheck/src/healthcheck/status/collections.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ async def check_collection_catalog_generation(
3434
session: aiohttp.ClientSession, collection: CollectionLightSchema
3535
) -> CollectionCatalogStatus:
3636
async with session.get(
37-
f"{Context.cms_api_url}/{collection.id}/catalog.xml",
37+
f"{Context.cms_api_url}/collections/{collection.id}/catalog.xml",
3838
timeout=aiohttp.ClientTimeout(total=Context.catalog_generation_timeout),
3939
) as resp:
4040
return CollectionCatalogStatus(
@@ -83,7 +83,7 @@ async def check_catalog_generation() -> Result[CatalogStatus]:
8383
)
8484

8585
return Result(
86-
success=bool(failures),
87-
status_code=HTTPStatus.OK if len(failures) > 0 else HTTPStatus.NOT_FOUND,
86+
success=False if failures else True,
87+
status_code=HTTPStatus.NOT_FOUND if failures else HTTPStatus.OK,
8888
data=CatalogStatus(collections=catalog_statuses),
8989
)

0 commit comments

Comments
 (0)