diff --git a/asu/api.py b/asu/api.py index dc7f3940..5d60350c 100644 --- a/asu/api.py +++ b/asu/api.py @@ -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: @@ -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) diff --git a/asu/asu.py b/asu/asu.py index d3e47c84..312466ef 100644 --- a/asu/asu.py +++ b/asu/asu.py @@ -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: @@ -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 diff --git a/asu/janitor.py b/asu/janitor.py index e5bb0546..42d5531a 100644 --- a/asu/janitor.py +++ b/asu/janitor.py @@ -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() @@ -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", ) diff --git a/misc/config.py b/misc/config.py index 7a861aac..63f66465 100644 --- a/misc/config.py +++ b/misc/config.py @@ -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"