Skip to content

Commit

Permalink
Merge pull request #1544 from metal3-io-bot/cherry-pick-1528-to-relea…
Browse files Browse the repository at this point in the history
…se-1.6

[release-1.6] 🐛 e2e: Specify ip address pool for retreiving ip for accessing node
  • Loading branch information
metal3-io-bot authored Mar 21, 2024
2 parents ee318cf + 43434ab commit 265d4e4
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
10 changes: 7 additions & 3 deletions test/e2e/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -584,7 +584,7 @@ func MachineToVMName(ctx context.Context, cli client.Client, m *clusterv1.Machin
}

// MachineTiIPAddress gets IPAddress based on machine, from machine -> m3machine -> m3data -> IPAddress.
func MachineToIPAddress(ctx context.Context, cli client.Client, m *clusterv1.Machine) (string, error) {
func MachineToIPAddress(ctx context.Context, cli client.Client, m *clusterv1.Machine, ippool ipamv1.IPPool) (string, error) {
m3Machine := &infrav1.Metal3Machine{}
err := cli.Get(ctx, types.NamespacedName{
Namespace: m.Spec.InfrastructureRef.Namespace,
Expand Down Expand Up @@ -619,7 +619,7 @@ func MachineToIPAddress(ctx context.Context, cli client.Client, m *clusterv1.Mac
}
for i, ip := range IPAddresses.Items {
for _, owner := range ip.OwnerReferences {
if owner.Name == m3Data.Name {
if owner.Name == m3Data.Name && ip.Spec.Pool.Name == ippool.Name {
IPAddress = &IPAddresses.Items[i]
}
}
Expand Down Expand Up @@ -723,7 +723,11 @@ func (Metal3LogCollector) CollectMachineLog(ctx context.Context, cli client.Clie
}
creds := kubeadmCP.Spec.KubeadmConfigSpec.Users[0]

ip, err := MachineToIPAddress(ctx, cli, m)
// get baremetal ip pool for retreiving ip addresses of controlpane and worker nodes
baremetalv4Pool, _ := GetIPPools(ctx, cli, m.Spec.ClusterName, m.Namespace)
Expect(baremetalv4Pool).ToNot(BeEmpty())

ip, err := MachineToIPAddress(ctx, cli, m, baremetalv4Pool[0])
if err != nil {
return fmt.Errorf("couldn't get IP address of machine: %w", err)
}
Expand Down
8 changes: 6 additions & 2 deletions test/e2e/healthchek.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,18 @@ func healthcheck(ctx context.Context, inputGetter func() HealthCheckInput) {
clusterName := input.ClusterName
controlplaneM3Machines, workerM3Machines := GetMetal3Machines(ctx, cli, clusterName, namespace)

// get baremetal ip pool for retreiving ip addresses of controlpane and worker nodes
baremetalv4Pool, _ := GetIPPools(ctx, cli, input.ClusterName, input.Namespace)
Expect(baremetalv4Pool).ToNot(BeEmpty())

// Worker
By("Healthchecking the workers")
workerHealthcheck, err := DeployWorkerHealthCheck(ctx, cli, namespace, clusterName)
Expect(err).ToNot(HaveOccurred())
workerMachineName, err := Metal3MachineToMachineName(workerM3Machines[0])
Expect(err).ToNot(HaveOccurred())
workerMachine := GetMachine(ctx, cli, client.ObjectKey{Name: workerMachineName, Namespace: namespace})
workerIP, err := MachineToIPAddress(ctx, cli, &workerMachine)
workerIP, err := MachineToIPAddress(ctx, cli, &workerMachine, baremetalv4Pool[0])
Expect(err).ToNot(HaveOccurred())
Expect(runCommand("", "", workerIP, "metal3", "systemctl stop kubelet")).To(Succeed())
// Wait until node is marked unhealthy and then check that it becomes healthy again
Expand All @@ -64,7 +68,7 @@ func healthcheck(ctx context.Context, inputGetter func() HealthCheckInput) {
controlplaneMachineName, err := Metal3MachineToMachineName(controlplaneM3Machines[0])
Expect(err).ToNot(HaveOccurred())
controlplaneMachine := GetMachine(ctx, cli, client.ObjectKey{Name: controlplaneMachineName, Namespace: namespace})
controlplaneIP, err := MachineToIPAddress(ctx, cli, &controlplaneMachine)
controlplaneIP, err := MachineToIPAddress(ctx, cli, &controlplaneMachine, baremetalv4Pool[0])
Expect(err).ToNot(HaveOccurred())
Expect(runCommand("", "", controlplaneIP, "metal3", "systemctl stop kubelet")).To(Succeed())
// Wait until node is marked unhealthy and then check that it becomes healthy again
Expand Down

0 comments on commit 265d4e4

Please sign in to comment.