Modified printouts when releasing staging repo. 96/66796/1
authorBengt Thuree <bthuree@linuxfoundation.org>
Wed, 17 Feb 2021 05:30:22 +0000 (16:30 +1100)
committerBengt Thuree <bthuree@linuxfoundation.org>
Wed, 17 Feb 2021 05:32:26 +0000 (16:32 +1100)
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 <bthuree@linuxfoundation.org>
Change-Id: I7abc4b8fe612d14939ed0dd0c2d70f9a4ecf1774

lftools/nexus/cmd.py
releasenotes/notes/Modified-printouts-when-release-staging-repos-0b58c28e54ef6958.yaml [new file with mode: 0644]

index fb9d3f5..1bd9843 100644 (file)
@@ -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 (file)
index 0000000..3ceb2d6
--- /dev/null
@@ -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.