Resend message while waiting for ostree ref
If the signing machinery crashes, we don't want to wait forever. This way at least we can shout for help periodically. Signed-off-by: Lubomír Sedlář <lsedlar@redhat.com> Fixes: https://pagure.io/pungi/issue/1350 JIRA: COMPOSE-4166
This commit is contained in:
parent
4734f9859a
commit
16d6e5b0dd
@ -21,6 +21,9 @@ import os
|
|||||||
import sys
|
import sys
|
||||||
import time
|
import time
|
||||||
|
|
||||||
|
RESEND_INTERVAL = 300 # In seconds
|
||||||
|
SLEEP_TIME = 5
|
||||||
|
|
||||||
|
|
||||||
def is_ref_updated(ref_file, commit):
|
def is_ref_updated(ref_file, commit):
|
||||||
"""The ref is updated when the file points to the correct commit."""
|
"""The ref is updated when the file points to the correct commit."""
|
||||||
@ -66,21 +69,19 @@ def main():
|
|||||||
fedmsg.init(**config)
|
fedmsg.init(**config)
|
||||||
topic = "compose.%s" % opts.cmd.replace("-", ".").lower()
|
topic = "compose.%s" % opts.cmd.replace("-", ".").lower()
|
||||||
|
|
||||||
count = 0
|
def wait_for(msg, test, *args):
|
||||||
while not os.path.exists(path):
|
time_slept = 0
|
||||||
ts_log("Commit not signed yet, waiting...")
|
while not test(*args):
|
||||||
count += 1
|
ts_log(msg)
|
||||||
if count >= 60: # Repeat every 5 minutes
|
time_slept += SLEEP_TIME
|
||||||
print("Repeating notification")
|
if time_slept >= RESEND_INTERVAL:
|
||||||
fedmsg.publish(topic=topic, modname="pungi", msg=data)
|
ts_log("Repeating notification")
|
||||||
count = 0
|
fedmsg.publish(topic=topic, modname="pungi", msg=data)
|
||||||
time.sleep(5)
|
time_slept = 0
|
||||||
|
time.sleep(SLEEP_TIME)
|
||||||
print("Found signature, waiting for ref to be updated.")
|
|
||||||
|
|
||||||
|
wait_for("Commit not signed yet", os.path.exists, path)
|
||||||
|
ts_log("Found signature, waiting for ref to be updated.")
|
||||||
ref_file = os.path.join(repo, "refs/heads", data["ref"])
|
ref_file = os.path.join(repo, "refs/heads", data["ref"])
|
||||||
while not is_ref_updated(ref_file, commit):
|
wait_for("Ref is not yet up-to-date", is_ref_updated, ref_file, commit)
|
||||||
ts_log("Ref is not yet up-to-date, waiting...")
|
ts_log("Ref is up-to-date. All done!")
|
||||||
time.sleep(5)
|
|
||||||
|
|
||||||
print("Ref is up-to-date. All done!")
|
|
||||||
|
Loading…
Reference in New Issue
Block a user