Legoktm has uploaded a new change for review. ( https://gerrit.wikimedia.org/r/397236 )
Change subject: Rate-limit based on zuul queue size ...................................................................... Rate-limit based on zuul queue size If gate-and-submit has more than 5 jobs, wait before starting any new ones. Change-Id: Ifd5a00f8d914b9c5f8f8e325204a78a9c174847a --- M gerrit.py M upgrade.py 2 files changed, 30 insertions(+), 0 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/labs/libraryupgrader refs/changes/36/397236/1 diff --git a/gerrit.py b/gerrit.py index 9e70ad5..0e7a336 100644 --- a/gerrit.py +++ b/gerrit.py @@ -19,6 +19,7 @@ import json import requests +import time s = requests.Session() @@ -45,3 +46,31 @@ repos.add(repo) yield from sorted(repos) + + +def zuul_queue_length(q='gate-and-submit'): + # ?time is for cache busting, just like jQuery does + r = s.get('https://integration.wikimedia.org/zuul/status.json?' + str(time.time())) + r.raise_for_status() + + data = r.json() + for pipeline in data['pipelines']: + if pipeline['name'] != 'gate-and-submit': + continue + count = 0 + for change_q in pipeline['change_queues']: + if change_q['heads']: + count += sum(len(head) for head in change_q['heads']) + + return count + + # We never found the gate-and-submit queue? + return 0 + + +def wait_for_zuul_gate(count: int): + zuul = zuul_queue_length() + while zuul > count: + print('gate-and-submit has %s jobs, waiting...' % zuul) + time.sleep(10) + zuul = zuul_queue_length() \ No newline at end of file diff --git a/upgrade.py b/upgrade.py index 8fa8e95..a7bd459 100755 --- a/upgrade.py +++ b/upgrade.py @@ -132,6 +132,7 @@ name = run(repo, library, version, pw) processed.add(name) docker.wait_for_containers(count=2) + gerrit.wait_for_zuul_gate(count=5) if limit is not None and len(processed) > limit: print('Passed limit of %s, breaking' % limit) break -- To view, visit https://gerrit.wikimedia.org/r/397236 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Ifd5a00f8d914b9c5f8f8e325204a78a9c174847a Gerrit-PatchSet: 1 Gerrit-Project: labs/libraryupgrader Gerrit-Branch: master Gerrit-Owner: Legoktm <lego...@member.fsf.org> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits