Skip to content

Commit dc53a56

Browse files
committed
fix: avoid offering versions that are not yet fully compiled
1 parent 84ffb51 commit dc53a56

File tree

2 files changed

+31
-6
lines changed

2 files changed

+31
-6
lines changed

asu/util.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
import json
55
import logging
66
import struct
7+
from dateutil import parser
8+
from datetime import datetime
79
from os import getgid, getuid
810
from pathlib import Path
911
from re import match
@@ -434,6 +436,19 @@ def parse_kernel_version(url: str) -> str:
434436
return ""
435437

436438

439+
def is_fully_compiled_version(version: str) -> bool:
440+
"""Check that a given version is at least 48h old"""
441+
response = client_get(
442+
settings.upstream_url + "/releases/" + version + "/.targets.json"
443+
)
444+
445+
if response.extensions["from_cache"]:
446+
last_modified = int(parser.parse(response.headers["Last-Modified"]).timestamp())
447+
if int(datetime.now().timestamp()) - last_modified < 172800:
448+
return False
449+
return True
450+
451+
437452
def reload_versions(app: FastAPI) -> bool:
438453
response = client_get(settings.upstream_url + "/.versions.json")
439454

@@ -451,6 +466,12 @@ def reload_versions(app: FastAPI) -> bool:
451466
if response.json()["upcoming_version"]:
452467
app.versions.append(response.json()["upcoming_version"])
453468

469+
# Avoid offering versions that are not yet fully compiled
470+
for label in ["stable_version", "oldstable_version", "upcoming_version"]:
471+
version = response.json()[label]
472+
if version and not is_fully_compiled_version(version):
473+
app.versions.remove(version)
474+
454475
for branch in settings.branches.keys():
455476
if branch != "SNAPSHOT":
456477
app.versions.append(f"{branch}-SNAPSHOT")

misc/squid.conf

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,18 @@ cache_dir ufs /var/spool/squid 50000 16 256
77
# Set memory cache size
88
cache_mem 5 GB
99

10-
# Prevent caching for one year uncompleted kernel modules during compilation (should be updated once a new release is published)
11-
refresh_pattern ^http://downloads.openwrt.org/releases/.*(23.05.[6-99]|24.10.[1-99]|25.*|SNAPSHOT)/targets/.* 0 100% 0 refresh-ims
10+
# Consider replacing 'downloads.openwrt.org' with '.*openwrt.*' to include multiple mirrors
11+
# Always revalidate imagebuilders and sha256sums with the origin server
12+
refresh_pattern ^http://downloads.openwrt.org/releases/.*/targets/.*(imagebuilder|sha256sums).* 0 100% 0 refresh-ims
1213

13-
# Kernel modules for releases are compiled once, never expires: cache for a year
14-
refresh_pattern ^http://downloads.openwrt.org/releases/.*/targets/.* 525600 0% 525600 override-expire
14+
# Always revalidate the content of snapshots with the origin server
15+
refresh_pattern -i ^http://downloads.openwrt.org/.*snapshot.* 0 100% 0 refresh-ims
1516

16-
# Prevent revalidate cached content with the origin server for 30min (should exist a fallback to no_proxy)
17-
refresh_pattern ^http://downloads.openwrt.org/.*[^imagebuilder].* 30 0% 30 override-expire
17+
# Kernel modules for releases are compiled once, never expires: cache for one year
18+
refresh_pattern ^http://downloads.openwrt.org/releases/.*/targets/.* 525600 100% 525600 override-expire
19+
20+
# Consider all the remaning packages as fresh for 30min (should exist a fallback to no_proxy)
21+
refresh_pattern ^http://downloads.openwrt.org/.* 30 100% 30 override-expire
1822

1923
# Always revalidate cached content with the origin server
2024
refresh_pattern . 0 100% 0 refresh-ims

0 commit comments

Comments
 (0)