From d20143854cb65e86f39c49a8109fd03612c2044f Mon Sep 17 00:00:00 2001 From: Geert Stappers Date: Mon, 9 Jan 2023 19:18:40 +0100 Subject: 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 --- internal/polling/polling.go | 12 ++++++++---- test/integ-test/expected-results/poll-unknown.txt | 7 ++++++- test/integ-test/expected-results/poll.txt | 7 ++++++- 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. -- cgit v1.2.3