Skip to content

Commit

Permalink
Store backend_id we get from GitHub event
Browse files Browse the repository at this point in the history
This means that if even if we timed-out waiting for it to be assigned
when requesting the build, it is known when we do metadata fetch.

Fixes: 2123ff0 ("Extract build_id from job's display title")
  • Loading branch information
jon-turney committed Nov 23, 2023
1 parent 246c265 commit c570c8c
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 9 deletions.
6 changes: 2 additions & 4 deletions TODO
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,5 @@
- use a venv to avoid depending on user installation of required python modules
- don't be terrible

- authenticated ways for maintainers to interact with scallywag (via 'ssh [email protected] jobs <subcommand>' ?)
-- cancel a job
-- retry a job
-- deploy a successful job that run without deploy token

- fetcher should check if pending jobs have completed, in case we've missed a job conclusion status notification
14 changes: 9 additions & 5 deletions carpetbag.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,19 @@ def deployable_job(u):
(u.package != 'playground'))


def update_status(u):
def update_backend_id(u):
logging.info(vars(u))

with sqlite3.connect(dbfile) as conn:
# if the id isn't available, determine it from backend_id
if not hasattr(u, 'buildnumber'):
cursor = conn.execute('SELECT id FROM jobs WHERE backend_id = ?', (u.backend_id,))
u.buildnumber = cursor.fetchone()[0]
conn.execute('UPDATE jobs SET backend_id = ? WHERE id = ?', (u.backend_id, u.buildnumber))

conn.close()


def update_status(u):
logging.info(vars(u))

with sqlite3.connect(dbfile) as conn:
conn.execute('UPDATE jobs SET status = ?, logurl = ?, duration = ? WHERE id = ?',
(u.status, u.buildurl, u.duration, u.buildnumber))

Expand Down
4 changes: 4 additions & 0 deletions gh-hook.cgi
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,10 @@ def hook():

u = process(data)
if u:
# ensure backend_id is set, if it was previously unknown due to timeout waiting for it to be assigned
if hasattr(u, 'buildnumber'):
carpetbag.update_backend_id(u)

carpetbag.update_status(u)

return '200 OK', ''
Expand Down

0 comments on commit c570c8c

Please sign in to comment.