From: Bengt Thuree Date: Wed, 17 Feb 2021 05:30:22 +0000 (+1100) Subject: Modified printouts when releasing staging repo. X-Git-Tag: v0.35.2~6^2 X-Git-Url: https://gerrit.linuxfoundation.org/infra/gitweb?a=commitdiff_plain;h=92d7644ab5b0a456ea82209483441b2a6a87be6d;p=releng%2Flftools.git Modified printouts when releasing staging repo. Modified printouts to be more human friendly. Still waiting every 20 seconds. Checking result every 40 seconds. Issue-Id: RELENG-3398 Signed-off-by: Bengt Thuree Change-Id: I7abc4b8fe612d14939ed0dd0c2d70f9a4ecf1774 --- diff --git a/lftools/nexus/cmd.py b/lftools/nexus/cmd.py index fb9d3f54..1bd9843c 100644 --- a/lftools/nexus/cmd.py +++ b/lftools/nexus/cmd.py @@ -492,6 +492,8 @@ def release_staging_repos(repos, verify, nexus_url=""): log.info("Sending data: {}".format(data)) request_url = "{}/staging/bulk/promote".format(_nexus.baseurl) log.info("Request URL: {}".format(request_url)) + log.info("Requesting Nexus to release {}".format(repo)) + response = requests.post(request_url, json=data, auth=_nexus.auth) if response.status_code != 201: @@ -499,22 +501,25 @@ def release_staging_repos(repos, verify, nexus_url=""): "Release failed with the following error:" "\n{}: {}".format(response.status_code, response.text) ) else: - log.info("Successfully released {}".format(str(repo))) + log.info("Nexus is now working on releasing {}".format(str(repo))) # Hang out until the repo is fully closed - log.info("Polling for repo to enter the closed state.") + log.info("Waiting for Nexus to complete releasing {}".format(str(repo))) closed = False + wait_seconds = 20 + wait_itteration = 0 activity_url = "{}/staging/repository/{}/activity".format(_nexus.baseurl, repo) while closed is False: - response = requests.get(activity_url, auth=_nexus.auth).text - root = et.fromstring(response) # nosec - events = root.findall("./stagingActivity") - for event in events: - name = event.find("name") - if name.text == "close": - stopped = event.find("stopped") - log.info("Repo closed at: {}".format(stopped.text)) - closed = True - else: - log.info("Repo is not fully closed, sleeping for five minutes.") - sleep(300) + sleep(wait_seconds) + wait_itteration = wait_itteration + 1 + log.info("Still waiting... {:>4d} seconds gone".format(total_wait_seconds * wait_itteration)) + if (wait_itteration % 2) != 0: + response = requests.get(activity_url, auth=_nexus.auth).text + root = et.fromstring(response) # nosec + events = root.findall("./stagingActivity") + for event in events: + name = event.find("name") + if name.text == "close": + stopped = event.find("stopped") + log.info("Repo released and closed at: {}".format(stopped.text)) + closed = True diff --git a/releasenotes/notes/Modified-printouts-when-release-staging-repos-0b58c28e54ef6958.yaml b/releasenotes/notes/Modified-printouts-when-release-staging-repos-0b58c28e54ef6958.yaml new file mode 100644 index 00000000..3ceb2d62 --- /dev/null +++ b/releasenotes/notes/Modified-printouts-when-release-staging-repos-0b58c28e54ef6958.yaml @@ -0,0 +1,5 @@ +--- +other: + - | + Changed the printouts to console when releasing a staging repo. + Printout every 20 seconds, and checking if released every 40 second.