Skip to content

Commit d8e0d52

Browse files
committed
E2E: Cleanup libvit DHCP config
Use Ironic dnsmasq container for DHCP. This requires a workaround for now, since the keepalived image we use doesn't support any other IP range than /32. Signed-off-by: Lennart Jern <[email protected]>
1 parent 5bdf34b commit d8e0d52

File tree

5 files changed

+38
-6
lines changed

5 files changed

+38
-6
lines changed

hack/e2e/net.xml

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,5 @@
66
</nat>
77
</forward>
88
<bridge name='metal3'/>
9-
<ip address='192.168.222.1' netmask='255.255.255.0'>
10-
<dhcp>
11-
<range start='192.168.222.3' end='192.168.222.99'/>
12-
<bootp file='http://192.168.222.2:6180/boot.ipxe'/>
13-
</dhcp>
14-
</ip>
9+
<ip address='192.168.222.1' netmask='255.255.255.0'/>
1510
</network>

test/e2e/common.go

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -778,3 +778,31 @@ type WaitForIronicInput struct {
778778
Namespace string
779779
Intervals []interface{} // e.g. []interface{}{time.Minute * 15, time.Second * 5}
780780
}
781+
782+
// ConfigureProvisioningNetwork adds the provisioning IP with /24 netmask to the kind cluster node.
783+
// TODO(lentzi90): Implement support for this in the keepalived image we use.
784+
// This is a workaround for the fact that keepalived only adds a /32 address, which causes
785+
// dnsmasq to fail with "no address range available for DHCP request" because it cannot
786+
// find a matching subnet for the DHCP range.
787+
// See https://github.com/metal3-io/baremetal-operator/issues/2792
788+
func ConfigureProvisioningNetwork(ctx context.Context, clusterName string, provisioningIP string) {
789+
containerName := clusterName + "-control-plane"
790+
// Add the provisioning IP with /24 netmask to eth0
791+
// This allows dnsmasq to see the DHCP range as part of the local subnet
792+
ipWithCIDR := provisioningIP + "/24"
793+
794+
Logf("Configuring provisioning network: adding %s to %s", ipWithCIDR, containerName)
795+
796+
cmd := testexec.NewCommand(
797+
testexec.WithCommand("docker"),
798+
testexec.WithArgs("exec", containerName, "ip", "addr", "add", ipWithCIDR, "dev", "eth0"),
799+
)
800+
801+
stdout, stderr, err := cmd.Run(ctx)
802+
// Ignore "RTNETLINK answers: File exists" error - the address may already be configured
803+
if err != nil && !strings.Contains(string(stderr), "File exists") {
804+
Logf("Warning: failed to configure provisioning network: %v\nstdout: %s\nstderr: %s", err, string(stdout), string(stderr))
805+
} else {
806+
Logf("Provisioning network configured successfully")
807+
}
808+
}

test/e2e/config/fixture.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ variables:
3535
CERT_MANAGER_VERSION: "v1.17.1"
3636
SSH_CHECK_PROVISIONED: "false"
3737
FETCH_IRONIC_NODES: "false"
38+
IRONIC_PROVISIONING_IP: "192.168.222.2"
3839
# Boot mode can be legacy, UEFI or UEFISecureBoot
3940
BOOT_MODE: "UEFI"
4041

test/e2e/e2e_suite_test.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,10 @@ var _ = SynchronizedBeforeSuite(func() []byte {
9393
})
9494
Expect(clusterProvider).ToNot(BeNil(), "Failed to create a cluster")
9595
kubeconfigPath = clusterProvider.GetKubeconfigPath()
96+
97+
// Configure provisioning network for dnsmasq to work properly.
98+
// TODO(lentzi90): This is a workaround. Fix it properly and get rid of it.
99+
ConfigureProvisioningNetwork(ctx, "bmo-e2e", e2eConfig.GetVariable("IRONIC_PROVISIONING_IP"))
96100
}
97101
Expect(kubeconfigPath).To(BeAnExistingFile(), "Failed to get the kubeconfig file for the cluster")
98102

test/e2e/upgrade_test.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -378,6 +378,10 @@ var _ = Describe("Upgrade", Label("optional", "upgrade"), func() {
378378
})
379379
Expect(upgradeClusterProvider).ToNot(BeNil(), "Failed to create a cluster")
380380
kubeconfigPath = upgradeClusterProvider.GetKubeconfigPath()
381+
382+
// Configure provisioning network for dnsmasq to work properly.
383+
// TODO(lentzi90): This is a workaround. Fix it properly and get rid of it.
384+
ConfigureProvisioningNetwork(ctx, upgradeClusterName, e2eConfig.GetVariable("IRONIC_PROVISIONING_IP"))
381385
}
382386
Expect(kubeconfigPath).To(BeAnExistingFile(), "Failed to get the kubeconfig file for the cluster")
383387
scheme := runtime.NewScheme()

0 commit comments

Comments
 (0)