Copilot commented on code in PR #861:
URL: https://github.com/apache/solr-operator/pull/861#discussion_r4367082016


##########
hack/release/smoke_test/test_cluster.sh:
##########
@@ -104,6 +104,26 @@ function remove_solr_helm_repo() {
   fi
 }
 
+# Wait until a backgrounded 'kubectl port-forward' is accepting connections.
+#
+# A fixed sleep races with the port-forward: on a loaded machine the forward 
can print
+# "Forwarding from ..." only after the first request has already been refused, 
and with
+# 'set -e' that aborts the whole smoke test. Any HTTP response means the 
forward is up,
+# so a non-zero curl exit (7 for a refused connection) is what we retry on.
+function wait_for_port_forward() {
+  local port="$1"
+  local waited=0
+  while [[ "${waited}" -lt 60 ]]; do
+    if curl --silent --max-time 2 --output /dev/null 
"http://127.0.0.1:${port}/";; then
+      return 0
+    fi
+    waited=$((waited + 1))
+    sleep 1
+  done

Review Comment:
   The loop counts attempts rather than elapsed time. When the port is 
unreachable but does not immediately refuse the connection, each `curl` can 
consume its 2-second `--max-time` and is followed by a 1-second sleep, so this 
helper can wait about 180 seconds instead of the documented 60-second limit. 
Track a wall-clock deadline (and bound each probe by the remaining time) so a 
failed forward fails within 60 seconds.



-- 
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