comms: retry othrys reset login
This commit is contained in:
parent
0b09f46bb1
commit
a1f1c9ada0
@ -2,7 +2,7 @@
|
||||
apiVersion: batch/v1
|
||||
kind: Job
|
||||
metadata:
|
||||
name: othrys-room-reset-5
|
||||
name: othrys-room-reset-6
|
||||
namespace: comms
|
||||
spec:
|
||||
backoffLimit: 0
|
||||
@ -41,7 +41,7 @@ spec:
|
||||
set -euo pipefail
|
||||
pip install --no-cache-dir requests >/dev/null
|
||||
python - <<'PY'
|
||||
import os, sys, urllib.parse, requests
|
||||
import os, sys, time, urllib.parse, requests
|
||||
|
||||
BASE = os.environ["SYNAPSE_BASE"]
|
||||
AUTH_BASE = os.environ.get("AUTH_BASE", BASE)
|
||||
@ -172,7 +172,17 @@ spec:
|
||||
r.raise_for_status()
|
||||
return r.json()["event_id"]
|
||||
|
||||
token = login(SEEDER_USER, SEEDER_PASS)
|
||||
def login_with_retry():
|
||||
last = None
|
||||
for attempt in range(1, 6):
|
||||
try:
|
||||
return login(SEEDER_USER, SEEDER_PASS)
|
||||
except Exception as exc: # noqa: BLE001
|
||||
last = exc
|
||||
time.sleep(attempt * 2)
|
||||
raise last
|
||||
|
||||
token = login_with_retry()
|
||||
|
||||
old_room_id = resolve_alias(token, ROOM_ALIAS)
|
||||
if not old_room_id:
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user