Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

config: allow to modify operations timeout #727

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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"
Loading