mirrors: record deprecation reason
This commit is contained in:
parent
cacb35a671
commit
18e046dc42
9 changed files with 96 additions and 26 deletions
|
@ -1,4 +1,5 @@
|
|||
import datetime
|
||||
from typing import Iterable
|
||||
|
||||
from app import app
|
||||
from app.extensions import db
|
||||
|
@ -9,8 +10,9 @@ from app.terraform import BaseAutomation
|
|||
|
||||
class BridgeAutomation(BaseAutomation):
|
||||
def create_missing(self):
|
||||
bridgeconfs = BridgeConf.query.filter(
|
||||
BridgeConf.provider == self.provider
|
||||
bridgeconfs: Iterable[BridgeConf] = BridgeConf.query.filter(
|
||||
BridgeConf.provider == self.provider,
|
||||
BridgeConf.destroyed == None
|
||||
).all()
|
||||
for bridgeconf in bridgeconfs:
|
||||
active_bridges = Bridge.query.filter(
|
||||
|
@ -27,10 +29,11 @@ class BridgeAutomation(BaseAutomation):
|
|||
elif len(active_bridges) > bridgeconf.number:
|
||||
active_bridge_count = len(active_bridges)
|
||||
for bridge in active_bridges:
|
||||
bridge.deprecate()
|
||||
bridge.deprecate("redundant")
|
||||
active_bridge_count -= 1
|
||||
if active_bridge_count == bridgeconf.number:
|
||||
break
|
||||
db.session.commit()
|
||||
|
||||
def destroy_expired(self):
|
||||
cutoff = datetime.datetime.utcnow() - datetime.timedelta(days=0)
|
||||
|
@ -40,6 +43,7 @@ class BridgeAutomation(BaseAutomation):
|
|||
).all() if b.conf.provider == self.provider]
|
||||
for bridge in bridges:
|
||||
bridge.destroy()
|
||||
db.session.commit()
|
||||
|
||||
def generate_terraform(self):
|
||||
self.write_terraform_config(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue