[autotest-client-tests][PATCH 2/3] UBUNTU: SAUCE: ubuntu_nvidia_server_driver: nvidia-fs: Loop through all CUDA images

dann frazier dann.frazier at canonical.com
Tue Jun 21 21:21:52 UTC 2022


The list of images tags from the docker registry is paginaged, and
today we're only searching the first page. The image we currently
want has fallen off the first page, so we now need to fix this and
search through all the pages.

Note: We could optimize this by adding an image name filter to
reduce the overall number of pages (currently 111).

Signed-off-by: dann frazier <dann.frazier at canonical.com>
---
 .../nvidia-fs/01-run-test.sh                  | 20 +++++++++++--------
 1 file changed, 12 insertions(+), 8 deletions(-)

diff --git a/ubuntu_nvidia_server_driver/nvidia-fs/01-run-test.sh b/ubuntu_nvidia_server_driver/nvidia-fs/01-run-test.sh
index b44bedb4..fbb6368e 100755
--- a/ubuntu_nvidia_server_driver/nvidia-fs/01-run-test.sh
+++ b/ubuntu_nvidia_server_driver/nvidia-fs/01-run-test.sh
@@ -22,20 +22,24 @@ driver_recommended_cuda_version() {
 
 find_latest_cuda_container_tag_by_branch() {
     local branch="$1" # e.g. 11.4
+    local tmpfile="$(mktemp)"
+    local url="https://registry.hub.docker.com/v2/repositories/nvidia/cuda/tags"
     source ./00-vars.gen # pick up LXD_OS_VER
 
     # List all of the available nvidia cuda image tags, filter for
     # devel/ubuntu images that match our cuda x.y, and sort numerically
     # to find the newest minor (x.y.z) version.
     #
-    # Output is paginated by default. To get all the items in one go,
-    # set a page_size greater than the likely number of items (1024)
-    curl -L -s \
-	 'https://registry.hub.docker.com/v2/repositories/nvidia/cuda/tags?page_size=1024' | \
-	jq '."results"[]["name"]' | \
-	tr -d \" | \
-	grep -E "^${branch}(\.[0-9]+)*-devel-ubuntu${LXD_OS_VER}$" | \
-	sort -n | tail -1
+    # Output is paginated, this loops through each page.
+    while [ "$url" != "null" ]; do
+        curl -L -s "$url" > "$tmpfile"
+        url="$(jq '."next"' < "$tmpfile" | tr -d \")"
+        jq '."results"[]["name"]' < "$tmpfile" |
+            tr -d \"
+    done |
+        grep -E "^${branch}(\.[0-9]+)*-devel-ubuntu${LXD_OS_VER}$" | \
+        sort -n | tail -1
+    rm -f "$tmpfile"
 }
 
 gen_vars() {
-- 
2.36.1




More information about the kernel-team mailing list