fix(proxy): reset added timestamp on hot spare promotion
This commit is contained in:
parent
8115966aca
commit
5d00dc8fe1
1 changed files with 4 additions and 2 deletions
|
@ -168,13 +168,14 @@ def promote_hot_spare_proxy(pool_id: int, origin: Origin) -> bool:
|
|||
|
||||
This function searches for a 'hot spare' proxy (a proxy in reserve pool with pool_id == -1)
|
||||
for the given origin. If a proxy is found, it is promoted to the specified pool by changing its pool ID.
|
||||
The added timestamp is also reset to the time at which the hot spare was promoted.
|
||||
|
||||
:param pool_id: The pool to which the 'hot spare' proxy is to be promoted.
|
||||
:param origin: The origin of the 'hot spare' proxy to be promoted.
|
||||
:return: True if a 'hot spare' proxy was found and promoted, False otherwise.
|
||||
|
||||
.. note:: In the database, the pool ID -1 signifies a reserve pool of 'hot spare' proxies. This pool does not
|
||||
appear in the pool table and is only used as a sentinel value.
|
||||
.. note:: In the database, the pool ID -1 signifies a reserve pool of 'hot spare' proxies. This pool is created by
|
||||
default in the schema migrations.
|
||||
"""
|
||||
proxy = Proxy.query.filter(
|
||||
Proxy.pool_id == -1,
|
||||
|
@ -183,6 +184,7 @@ def promote_hot_spare_proxy(pool_id: int, origin: Origin) -> bool:
|
|||
if not proxy:
|
||||
return False
|
||||
proxy.pool_id = pool_id
|
||||
proxy.added = datetime.datetime.utcnow()
|
||||
return True
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue