Skip to content

Commit

Permalink
Allow configuration of Jira request timeout
Browse files Browse the repository at this point in the history
We saw several unfurl failures due to Jira request timeouts. Make
the timeout configurable instead of using the 20s default from Safir.
  • Loading branch information
rra committed Dec 5, 2024
1 parent 201e2ca commit 0a3ac9a
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 0 deletions.
3 changes: 3 additions & 0 deletions changelog.d/20241205_124257_rra_DM_47974.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
### New features

- Allow configuration of the timeout when making requests to the Jira server instead of only using the 20s default.
10 changes: 10 additions & 0 deletions src/unfurlbot/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,13 @@

from __future__ import annotations

from datetime import timedelta

from pydantic import Field, RedisDsn, SecretStr, field_validator
from pydantic_settings import BaseSettings, SettingsConfigDict
from safir.kafka import KafkaConnectionSettings
from safir.logging import LogLevel, Profile
from safir.pydantic import HumanTimedelta

__all__ = ["Config", "config"]

Expand Down Expand Up @@ -90,6 +93,13 @@ class Config(BaseSettings):
),
)

jira_timeout: HumanTimedelta = Field(
timedelta(seconds=20),
title="Jira request timeout",
description="How long to wait for a response from the Jira server.",
examples=["60s"],
)

gafaelfawr_token: SecretStr = Field(
...,
title="Gafaelfawr token",
Expand Down
1 change: 1 addition & 0 deletions src/unfurlbot/storage/jiraissues.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ async def get(self, path: str) -> dict:
response = await self._http_client.get(
f"{self._proxy_base}{path}",
headers={"Authorization": f"Bearer {self._token}"},
timeout=config.jira_timeout.total_seconds(),
)
response.raise_for_status() # add a proper error message
return response.json()
Expand Down

0 comments on commit 0a3ac9a

Please sign in to comment.