aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGeert Stappers <stappers@stappers.it>2023-01-09 19:18:40 +0100
committerGitHub <noreply@github.com>2023-01-09 10:18:40 -0800
commitd20143854cb65e86f39c49a8109fd03612c2044f (patch)
tree67365e926c8cc7a388ffdaead6425c94b6e61fdb
parentbdf7df6d7be8bb887334d3b623c999c9adc06843 (diff)
style: add clarifying comments in polling iPXE scripts
* String changes in internal/polling/polling.go The most important one, from the point of view of human user, is the addition of telling that a maximum retry has been reached. The poll script got rid of the way too long line. That is done by using "iPXE script continueing line character", \, backslash. Poll interval shorter, from ten seconds to seven seconds, also from 10000 ms to more readable 7000 ms (clearly three zeros (how many zeros are in 10000? (four or five?))). Added information about a loop that only looks like a loop. A minor `s/iPXE/iPXE client/`. In directory test/integ-test/expected-results/ are poll-unknown.txt and poll.txt updated for getting a clean `make test`. * style: build on top of latest contribution In particular, mentioning 'maxRetry' exposes implementation code to the end user, which we should avoid. Co-authored-by: Raul Benencia <raul@thousandeyes.com>
-rw-r--r--internal/polling/polling.go12
-rw-r--r--test/integ-test/expected-results/poll-unknown.txt7
-rw-r--r--test/integ-test/expected-results/poll.txt7
3 files changed, 20 insertions, 6 deletions
diff --git a/internal/polling/polling.go b/internal/polling/polling.go
index cfd489f..7b1235b 100644
--- a/internal/polling/polling.go
+++ b/internal/polling/polling.go
@@ -42,16 +42,20 @@ const (
"#\n" +
"# Do\n" +
"# curl http://{{.baseURL}}/poll/1/06-66-de-ad-be-ef\n" +
- "# to get an idea about what iPXE will receive.\n"
+ "# to get an idea about what the iPXE client will receive.\n"
maxRetry = 10
retryScript = "#!ipxe\n" +
- "prompt --key 0x02 --timeout 10000 shoelaces: Press Ctrl-B for manual override... && " +
- "chain -ar http://{{.baseURL}}/ipxemenu || " +
- "chain -ar http://{{.baseURL}}/poll/1/{{.macAddress}}\n"
+ "prompt --key 0x02 --timeout 7000 shoelaces: Press Ctrl-B for manual override... \\\n" +
+ " && chain -ar http://{{.baseURL}}/ipxemenu \\\n" +
+ " || chain -ar http://{{.baseURL}}/poll/1/{{.macAddress}}\n\n" +
+ "# Note: the iPXE client will see the above code as an endless loop.\n" +
+ "# However, Shoelaces will break that loop after a fixed number of retries.\n"
timeoutScript = "#!ipxe\n" +
+ "echo\n" +
+ "echo Shoelaces reached the maximum number of retries\n" +
"exit\n"
// BootAction is used when a user selects a script for the polling
diff --git a/test/integ-test/expected-results/poll-unknown.txt b/test/integ-test/expected-results/poll-unknown.txt
index f17022f..0e35aa6 100644
--- a/test/integ-test/expected-results/poll-unknown.txt
+++ b/test/integ-test/expected-results/poll-unknown.txt
@@ -1,2 +1,7 @@
#!ipxe
-prompt --key 0x02 --timeout 10000 shoelaces: Press Ctrl-B for manual override... && chain -ar http://localhost:18888/ipxemenu || chain -ar http://localhost:18888/poll/1/06-66-de-ad-be-ef
+prompt --key 0x02 --timeout 7000 shoelaces: Press Ctrl-B for manual override... \
+ && chain -ar http://localhost:18888/ipxemenu \
+ || chain -ar http://localhost:18888/poll/1/06-66-de-ad-be-ef
+
+# Note: the iPXE client will see the above code as an endless loop.
+# However, Shoelaces will break that loop after a fixed number of retries.
diff --git a/test/integ-test/expected-results/poll.txt b/test/integ-test/expected-results/poll.txt
index dbba541..a941b7a 100644
--- a/test/integ-test/expected-results/poll.txt
+++ b/test/integ-test/expected-results/poll.txt
@@ -1,2 +1,7 @@
#!ipxe
-prompt --key 0x02 --timeout 10000 shoelaces: Press Ctrl-B for manual override... && chain -ar http://localhost:18888/ipxemenu || chain -ar http://localhost:18888/poll/1/ff-ff-ff-ff-ff-ff
+prompt --key 0x02 --timeout 7000 shoelaces: Press Ctrl-B for manual override... \
+ && chain -ar http://localhost:18888/ipxemenu \
+ || chain -ar http://localhost:18888/poll/1/ff-ff-ff-ff-ff-ff
+
+# Note: the iPXE client will see the above code as an endless loop.
+# However, Shoelaces will break that loop after a fixed number of retries.
nihil fit ex nihilo