Skip to content

Commit

Permalink
config: allow to modify operations timeout
Browse files Browse the repository at this point in the history
  • Loading branch information
a-gave committed Feb 5, 2024
1 parent 287b967 commit 8210d6c
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 5 deletions.
4 changes: 2 additions & 2 deletions asu/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ def api_v1_build_post():
job_id=request_hash,
result_ttl=result_ttl,
failure_ttl=failure_ttl,
job_timeout="10m",
job_timeout=current_app.config["GLOBAL_TIMEOUT"] or "10m",
)
else:
if job.is_finished:
Expand Down Expand Up @@ -344,7 +344,7 @@ def api_build_post():
job_id=request_hash,
result_ttl=result_ttl,
failure_ttl=failure_ttl,
job_timeout="10m",
job_timeout=current_app.config["GLOBAL_TIMEOUT"] or "10m",
)

return return_job(job)
3 changes: 2 additions & 1 deletion asu/asu.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ def create_app(test_config: dict = None) -> Flask:
BRANCHES_FILE=getenv("BRANCHES_FILE"),
MAX_CUSTOM_ROOTFS_SIZE_MB=100,
REPOSITORY_ALLOW_LIST=[],
GLOBAL_TIMEOUT=getenv("GLOBAL_TIMEOUT") or "10m"
)

if not test_config:
Expand Down Expand Up @@ -138,7 +139,7 @@ def overview():
"REPOSITORY_ALLOW_LIST": app.config["REPOSITORY_ALLOW_LIST"],
"REDIS_URL": app.config["REDIS_URL"],
},
job_timeout="10m",
job_timeout=app.config["GLOBAL_TIMEOUT"],
)

return app
14 changes: 12 additions & 2 deletions asu/janitor.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,16 @@
from asu import __version__
from asu.common import get_redis_client, is_modified

from pathlib import Path
import importlib.util

for config_file in ["/etc/asu/config.py", "misc/config.py"]:
if Path(config_file).exists():
spec = importlib.util.spec_from_file_location("spec", config_file)
settings = importlib.util.module_from_spec(spec)
spec.loader.exec_module(settings)
break

bp = Blueprint("janitor", __name__)

session = requests.Session()
Expand Down Expand Up @@ -235,8 +245,8 @@ def update(config):
logging.exception("Failed to update")

Queue(connection=get_redis_client(config)).enqueue_in(
timedelta(minutes=10),
timedelta(minutes=hasattr(settings, 'GLOBAL_TIMEOUT') and int(settings.GLOBAL_TIMEOUT[:-1]) or 10),
update,
config,
job_timeout="10m",
job_timeout=hasattr(settings, 'GLOBAL_TIMEOUT') and settings.GLOBAL_TIMEOUT or "10m",
)
3 changes: 3 additions & 0 deletions misc/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,3 +44,6 @@

# where to downlaod the images from
# UPSTREAM_PATH = "https://downloads.openwrt.org"

# global operations timeout (used in downloading the requested imagebuilder and updating of profiles.json)
# GLOBAL_TIMEOUT = "30m"

0 comments on commit 8210d6c

Please sign in to comment.