smiklosovic commented on code in PR #3966:
URL: https://github.com/apache/cassandra/pull/3966#discussion_r1987238670


##########
doc/scripts/process-native-protocol-specs-in-docker.sh:
##########
@@ -23,17 +23,39 @@ GO_VERSION="1.23.1"
 GO_TAR="go${GO_VERSION}.linux-amd64.tar.gz"
 TMPDIR="${TMPDIR:-/tmp}"
 
-# Step 0: Download and install Go
-echo "Downloading Go $GO_VERSION..."
-wget -q "https://golang.org/dl/$GO_TAR"; -O "$TMPDIR/$GO_TAR"
-
-echo "Installing Go..."
-tar -C "$TMPDIR" -xzf "$TMPDIR/$GO_TAR"
-rm "$TMPDIR/$GO_TAR"
-
-# Set Go environment variables
-export PATH="$PATH:$TMPDIR/go/bin"
-export GOPATH="$TMPDIR/go"
+check_go_version() {
+    if command -v go &>/dev/null; then
+        local installed_version
+        installed_version=$(go version | awk '{print $3}' | sed 's/go//')
+
+        if [ "$(printf '%s\n' "$GO_VERSION" "$installed_version" | sort -V | 
head -n1)" = "$GO_VERSION" ]; then
+            echo "Detected Go $installed_version (>= $GO_VERSION), skipping 
installation."
+            return 0
+        else
+            echo "Detected Go $installed_version (< $GO_VERSION), proceeding 
with installation."
+            return 1
+        fi
+    else
+        echo "Go env not found in your system, proceeding with installation."
+        return 1
+    fi
+}
+
+if ! check_go_version; then
+    # Step 0: Download and install Go
+    echo "Downloading Go $GO_VERSION..."
+    wget --timeout=30 --tries=2 --waitretry=5 -q 
"https://golang.org/dl/$GO_TAR"; -O "$TMPDIR/$GO_TAR" || echo "Download golang 
failed. Network timeout"

Review Comment:
   @maoling if this fails because e.g. we are genuinely offline (e.g. in an 
airplane / train), then this will echo network issue but it will keep executing 
the rest of the code. But if it was not downloaded, then `tar -C ...` fail 
because `TMPDIR/GO_TAR` does not exist etc. We should fail in a more graceful 
manner. 



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to