fix: don't create missing proxies for hotspare
* also fixes setting creation time for pools * improves logging in proxy creation pipeline
This commit is contained in:
parent
b91e078e22
commit
1bc2960278
2 changed files with 13 additions and 5 deletions
|
@ -142,6 +142,7 @@ def auto_deprecate_proxies() -> None:
|
|||
Proxy.deprecated.is_(None),
|
||||
Origin.destroyed.is_not(None))
|
||||
.all())
|
||||
logging.debug("Origin destroyed: %s", origin_destroyed_proxies)
|
||||
for proxy in origin_destroyed_proxies:
|
||||
proxy.deprecate(reason="origin_destroyed")
|
||||
max_age_proxies = (db.session.query(Proxy)
|
||||
|
@ -152,6 +153,7 @@ def auto_deprecate_proxies() -> None:
|
|||
Origin.assets,
|
||||
Origin.auto_rotation)
|
||||
.all())
|
||||
logging.debug("Max age: %s", max_age_proxies)
|
||||
for proxy in max_age_proxies:
|
||||
max_age_cutoff = datetime.datetime.now(datetime.UTC) - datetime.timedelta(
|
||||
days=1, seconds=86400 * random.random()) # nosec: B311
|
||||
|
@ -232,6 +234,9 @@ class ProxyMetaAutomation(BaseAutomation):
|
|||
"""
|
||||
pools = Pool.query.all()
|
||||
for pool in pools:
|
||||
if pool.id == -1:
|
||||
continue # Skip hotspare pool
|
||||
logging.debug("Missing proxy check for %s", pool.pool_name)
|
||||
for group in pool.groups:
|
||||
for origin in group.origins:
|
||||
if origin.destroyed is not None:
|
||||
|
@ -240,6 +245,7 @@ class ProxyMetaAutomation(BaseAutomation):
|
|||
x for x in origin.proxies
|
||||
if x.pool_id == pool.id and x.deprecated is None and x.destroyed is None
|
||||
]
|
||||
logging.debug("Proxies for group %s: %s", group.group_name, proxies)
|
||||
if not proxies:
|
||||
logging.debug("Creating new proxy for %s in pool %s", origin, pool)
|
||||
if not promote_hot_spare_proxy(pool.id, origin):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue