Skip to content

Commit

Permalink
Make iPXE script kernel, initrd retries configurable:
Browse files Browse the repository at this point in the history
This allows for transient network issues to not cause
the iPXE script to fail downloading kernel and
initramfs.

Signed-off-by: Jacob Weinstock <[email protected]>
  • Loading branch information
jacobweinstock committed May 13, 2024
1 parent 20323fa commit cf4aad5
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 0 deletions.
1 change: 1 addition & 0 deletions cmd/smee/flag.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ func ipxeHTTPScriptFlags(c *config, fs *flag.FlagSet) {
fs.StringVar(&c.ipxeHTTPScript.hookURL, "osie-url", "", "[http] URL where OSIE (HookOS) images are located")
fs.StringVar(&c.ipxeHTTPScript.tinkServer, "tink-server", "", "[http] IP:Port for the Tink server")
fs.BoolVar(&c.ipxeHTTPScript.tinkServerUseTLS, "tink-server-tls", false, "[http] use TLS for Tink server")
fs.IntVar(&c.ipxeHTTPScript.retries, "ipxe-script-retries", 0, "[http] number of retries to attempt when fetching kernel and initrd files in the iPXE script")
}

func dhcpFlags(c *config, fs *flag.FlagSet) {
Expand Down
1 change: 1 addition & 0 deletions cmd/smee/flag_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ FLAGS
-http-addr [http] local IP:Port to listen on for iPXE HTTP script requests (default "%[1]v:80")
-http-ipxe-binary-enabled [http] enable iPXE HTTP binary server (default "true")
-http-ipxe-script-enabled [http] enable iPXE HTTP script server (default "true")
-ipxe-script-retries [http] number of retries to attempt when fetching kernel and initrd files in the iPXE script (default "0")
-osie-url [http] URL where OSIE (HookOS) images are located
-tink-server [http] IP:Port for the Tink server
-tink-server-tls [http] use TLS for Tink server (default "false")
Expand Down
2 changes: 2 additions & 0 deletions cmd/smee/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ type ipxeHTTPScript struct {
tinkServerUseTLS bool
trustedProxies string
disableDiscoverTrustedProxies bool
retries int
}

type dhcpConfig struct {
Expand Down Expand Up @@ -219,6 +220,7 @@ func main() {
PublicSyslogFQDN: cfg.dhcp.syslogIP,
TinkServerTLS: cfg.ipxeHTTPScript.tinkServerUseTLS,
TinkServerGRPCAddr: cfg.ipxeHTTPScript.tinkServer,
IPXEScriptRetries: cfg.ipxeHTTPScript.retries,
}
// serve ipxe script from the "/" URI.
handlers["/"] = jh.HandlerFunc()
Expand Down
1 change: 1 addition & 0 deletions internal/ipxe/script/hook.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,4 +52,5 @@ type Hook struct {
TraceID string
VLANID string // string number between 1-4095
WorkerID string // example 3c:ec:ef:4c:4f:54 or worker1
Retries int // number of retries to attempt when fetching kernel and initrd files
}
2 changes: 2 additions & 0 deletions internal/ipxe/script/ipxe.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ type Handler struct {
PublicSyslogFQDN string
TinkServerTLS bool
TinkServerGRPCAddr string
IPXEScriptRetries int
}

type data struct {
Expand Down Expand Up @@ -227,6 +228,7 @@ func (h *Handler) defaultScript(span trace.Span, hw data) (string, error) {
TinkGRPCAuthority: h.TinkServerGRPCAddr,
VLANID: hw.VLANID,
WorkerID: wID,
Retries: h.IPXEScriptRetries,
}
if sc := span.SpanContext(); sc.IsSampled() {
auto.TraceID = sc.TraceID().String()
Expand Down

0 comments on commit cf4aad5

Please sign in to comment.