Skip to content

change ipxe scripts to generate static address based templates - #85

Merged
ibrokethecloud merged 1 commit into
harvester:mainfrom
ibrokethecloud:static-address-ipxe-script
Mar 22, 2026
Merged

change ipxe scripts to generate static address based templates#85
ibrokethecloud merged 1 commit into
harvester:mainfrom
ibrokethecloud:static-address-ipxe-script

Conversation

@ibrokethecloud

@ibrokethecloud ibrokethecloud commented Mar 20, 2026

Copy link
Copy Markdown
Collaborator

change ipxe script to generate static address to work around dracut / networkmanager issues when network may have multiple dhcp servers

Problem:

Solution:

change ipxe script to generate static address to work around dracut / networkmanager issues when network may have multiple dhcp servers

Related Issue(s):

harvester/harvester#10258

Test plan:

Additional documentation or context

… networkmanager issues when network may have multiple dhcp servers

Signed-off-by: Gaurav Mehta <gaurav.mehta@suse.com>
Copilot AI review requested due to automatic review settings March 20, 2026 06:51

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Updates Harvester seeder’s Tinkerbell iPXE generation to boot with a static network configuration (instead of relying on DHCP during initramfs), to mitigate dracut/NetworkManager issues in environments with multiple DHCP servers.

Changes:

  • Extend generateIPXEScript to accept IP/netmask/gateway and render a static ip=...:off kernel cmdline.
  • Always set a persistent ifname=netboot:<mac> mapping via AfterInstallChrootCommands in generated cloud-config.
  • Update the existing unit test call site for the new generateIPXEScript signature.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.

File Description
pkg/tink/tink.go Pass static network params into iPXE template; adjust cloud-config post-install grubenv cmdline behavior.
pkg/tink/tink_test.go Update test invocation for the new iPXE generator signature.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread pkg/tink/tink.go
Comment on lines 248 to 250
iflinkwait -t 5000
kernel ${base}/harvester-${version}-vmlinuz-${arch} initrd=harvester-${version}-initrd-${arch} ip=dhcp net.ifnames=1 rd.cos.disable rd.noverifyssl BOOTIF={{ .MacAddress }} root=live:${base}/harvester-${version}-rootfs-${arch}.squashfs console=tty1 harvester.install.automatic=true boot_cmd='echo include_ping_test=yes >> /etc/conf.d/net-online' harvester.install.config_url={{ .HegelEndpoint }} {{if gt .VlanID 1}}ifname=netboot:{{ .MacAddress }} vlan=vlan{{ .VlanID }}:netboot {{end}}
kernel ${base}/harvester-${version}-vmlinuz-${arch} initrd=harvester-${version}-initrd-${arch} ip={{ .IP }}::{{ .Gateway }}:{{ .Netmask }}::netboot:off net.ifnames=1 rd.cos.disable rd.noverifyssl BOOTIF={{ .MacAddress }} ifname=netboot:{{ .MacAddress }} root=live:${base}/harvester-${version}-rootfs-${arch}.squashfs console=tty1 harvester.install.automatic=true boot_cmd='echo include_ping_test=yes >> /etc/conf.d/net-online' harvester.install.config_url={{ .HegelEndpoint }} {{if gt .VlanID 1}}vlan=vlan{{ .VlanID }}:netboot {{end}}
initrd ${base}/harvester-${version}-initrd-${arch}

Copilot AI Mar 20, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

generateIPXEScript now requires IP/netmask/gateway and always emits a static ip=...:off kernel parameter. If any of these fields are empty (e.g. unexpected inventory status/pool status), the generated kernel cmdline will be malformed and can break provisioning. Consider validating these inputs and falling back to the previous ip=dhcp behavior when they are not all set.

Copilot uses AI. Check for mistakes.
Comment thread pkg/tink/tink_test.go
Comment on lines +274 to 275
_, err := generateIPXEScript("v1.1.3", "http://imagestore/iso", "hegelEndpoint", "ab:cd:ef:gh:ij", "amd64", 1, "192.168.1.101", "255.255.255.0", "192.168.1.1")
assert.NoError(err, "expect no error during generation of ipxe script")

Copilot AI Mar 20, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The unit test only asserts that generateIPXEScript returns no error, but it doesn’t verify the new behavior (static addressing params and ifname=netboot mapping) in the generated script. Adding assertions for the rendered kernel line would prevent regressions in the new workaround logic.

Suggested change
_, err := generateIPXEScript("v1.1.3", "http://imagestore/iso", "hegelEndpoint", "ab:cd:ef:gh:ij", "amd64", 1, "192.168.1.101", "255.255.255.0", "192.168.1.1")
assert.NoError(err, "expect no error during generation of ipxe script")
script, err := generateIPXEScript("v1.1.3", "http://imagestore/iso", "hegelEndpoint", "ab:cd:ef:gh:ij", "amd64", 1, "192.168.1.101", "255.255.255.0", "192.168.1.1")
assert.NoError(err, "expect no error during generation of ipxe script")
assert.Contains(script, "ifname=netboot", "expected kernel params to include ifname=netboot mapping")
assert.Contains(script, "192.168.1.101", "expected kernel params to include static IP address")
assert.Contains(script, "255.255.255.0", "expected kernel params to include subnet mask")
assert.Contains(script, "192.168.1.1", "expected kernel params to include gateway")

Copilot uses AI. Check for mistakes.
Comment thread pkg/tink/tink.go
Comment on lines 216 to 218
// and uses the same for create / join of node
func generateIPXEScript(harvesterVersion, isoURL, hegelEndpoint, macAddress, arch string, vlanID int) (string, error) {
func generateIPXEScript(harvesterVersion, isoURL, hegelEndpoint, macAddress, arch string, vlanID int, ip string, netmask string, gateway string) (string, error) {

Copilot AI Mar 20, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The generateIPXEScript signature has grown to include multiple network parameters, making call sites harder to read and easier to misuse (argument order bugs). Consider passing a small struct (e.g. a network config object) or reusing an existing network type to group ip/netmask/gateway together.

Copilot uses AI. Check for mistakes.
Comment thread pkg/tink/tink.go
@ibrokethecloud
ibrokethecloud requested a review from starbops March 20, 2026 07:19

@starbops starbops left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks.

@ibrokethecloud
ibrokethecloud merged commit a4b0884 into harvester:main Mar 22, 2026
8 checks passed
@ibrokethecloud

Copy link
Copy Markdown
Collaborator Author

@mergify backport v1.8

@mergify

mergify Bot commented Mar 22, 2026

Copy link
Copy Markdown
Contributor

backport v1.8

✅ Backports have been created

Details

@mergify

mergify Bot commented Aug 21, 2026

Copy link
Copy Markdown
Contributor

backport v1.8

✅ Backports have been created

Details

Cherry-pick of a4b0884 has failed:

On branch mergify/bp/v1.8/pr-85
Your branch is up to date with 'origin/v1.8'.

You are currently cherry-picking commit a4b0884.
  (fix conflicts and run "git cherry-pick --continue")
  (use "git cherry-pick --skip" to skip this patch)
  (use "git cherry-pick --abort" to cancel the cherry-pick operation)

Unmerged paths:
  (use "git add <file>..." to mark resolution)
	both modified:   pkg/tink/tink.go

no changes added to commit (use "git add" and/or "git commit -a")

To fix up this pull request, you can check it out locally. See documentation: https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/reviewing-changes-in-pull-requests/checking-out-pull-requests-locally

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants