Skip to content

Commit 0bf46aa

Browse files
committed
fix log collection with region name in providerID
Signed-off-by: MatthieuFin <[email protected]>
1 parent 6e8653b commit 0bf46aa

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed

test/e2e/shared/common.go

+8-4
Original file line numberDiff line numberDiff line change
@@ -174,9 +174,13 @@ func getOpenStackClusterFromMachine(ctx context.Context, client client.Client, m
174174
return openStackCluster, err
175175
}
176176

177-
// getIDFromProviderID returns the server ID part of a provider ID string.
178-
func getIDFromProviderID(providerID string) string {
179-
return strings.TrimPrefix(providerID, "openstack:///")
177+
// GetIDFromProviderID returns the server ID part of a provider ID string.
178+
func GetIDFromProviderID(providerID string) string {
179+
providerIDSplit := strings.SplitN(providerID, "://", 2)
180+
Expect(providerIDSplit[0]).To(Equal("openstack"))
181+
providerIDPathSplit := strings.SplitN(providerIDSplit[1], "/", 2)
182+
// providerIDPathSplit[0] contain region name, could be empty
183+
return providerIDPathSplit[1]
180184
}
181185

182186
type OpenStackLogCollector struct {
@@ -201,7 +205,7 @@ func (o OpenStackLogCollector) CollectMachineLog(ctx context.Context, management
201205
}
202206
ip := m.Status.Addresses[0].Address
203207

204-
srv, err := GetOpenStackServerWithIP(o.E2EContext, getIDFromProviderID(*m.Spec.ProviderID), openStackCluster)
208+
srv, err := GetOpenStackServerWithIP(o.E2EContext, GetIDFromProviderID(*m.Spec.ProviderID), openStackCluster)
205209
if err != nil {
206210
return fmt.Errorf("error getting OpenStack server: %w", err)
207211
}

test/e2e/suites/e2e/e2e_test.go

+1-5
Original file line numberDiff line numberDiff line change
@@ -1137,11 +1137,7 @@ func getInstanceIDForMachine(machine *clusterv1.Machine) string {
11371137
providerID := machine.Spec.ProviderID
11381138
Expect(providerID).NotTo(BeNil())
11391139

1140-
providerIDSplit := strings.SplitN(*providerID, "://", 2)
1141-
Expect(providerIDSplit[0]).To(Equal("openstack"))
1142-
providerIDPathSplit := strings.SplitN(providerIDSplit[1], "/", 2)
1143-
// providerIDPathSplit[0] contain region name, could be empty
1144-
return providerIDPathSplit[1]
1140+
return shared.GetIDFromProviderID(*machine.Spec.ProviderID)
11451141
}
11461142

11471143
func isErrorEventExists(namespace, machineDeploymentName, eventReason, errorMsg string, eList *corev1.EventList) bool {

0 commit comments

Comments
 (0)