Skip to content

Commit 06cb0c7

Browse files
authored
Merge pull request #1217 from chrischdi/pr-fix-e2e-conformance-bastion-sec-nil
🐛 controllers/openstackcluster_controller.go fix nil pointer and dump openstack ports
2 parents c3d843f + b32a5da commit 06cb0c7

File tree

2 files changed

+27
-5
lines changed

2 files changed

+27
-5
lines changed

controllers/openstackcluster_controller.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -372,9 +372,11 @@ func bastionToInstanceSpec(openStackCluster *infrav1.OpenStackCluster, clusterNa
372372

373373
instanceSpec.SecurityGroups = openStackCluster.Spec.Bastion.Instance.SecurityGroups
374374
if openStackCluster.Spec.ManagedSecurityGroups {
375-
instanceSpec.SecurityGroups = append(instanceSpec.SecurityGroups, infrav1.SecurityGroupParam{
376-
UUID: openStackCluster.Status.BastionSecurityGroup.ID,
377-
})
375+
if openStackCluster.Status.BastionSecurityGroup != nil {
376+
instanceSpec.SecurityGroups = append(instanceSpec.SecurityGroups, infrav1.SecurityGroupParam{
377+
UUID: openStackCluster.Status.BastionSecurityGroup.ID,
378+
})
379+
}
378380
}
379381

380382
instanceSpec.Networks = openStackCluster.Spec.Bastion.Instance.Networks

test/e2e/shared/openstack.go

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,10 @@ func dumpOpenStack(_ context.Context, e2eCtx *E2EContext, bootstrapClusterProxyN
112112
if err := dumpOpenStackImages(providerClient, clientOpts, logPath); err != nil {
113113
_, _ = fmt.Fprintf(GinkgoWriter, "error dumping OpenStack images: %s\n", err)
114114
}
115+
116+
if err := dumpOpenStackPorts(e2eCtx, logPath); err != nil {
117+
_, _ = fmt.Fprintf(GinkgoWriter, "error dumping OpenStack ports: %s\n", err)
118+
}
115119
}
116120

117121
func dumpOpenStackImages(providerClient *gophercloud.ProviderClient, clientOpts *clientconfig.ClientOpts, logPath string) error {
@@ -134,9 +138,25 @@ func dumpOpenStackImages(providerClient *gophercloud.ProviderClient, clientOpts
134138
if err != nil {
135139
return fmt.Errorf("error marshalling images %v: %s", imagesList, err)
136140
}
137-
if err := os.WriteFile(path.Join(logPath, "images.txt"), imagesJSON, 0o600); err != nil {
138-
return fmt.Errorf("error writing seversJSON %s: %s", imagesJSON, err)
141+
if err := os.WriteFile(path.Join(logPath, "images.json"), imagesJSON, 0o600); err != nil {
142+
return fmt.Errorf("error writing images.json %s: %s", imagesJSON, err)
143+
}
144+
return nil
145+
}
146+
147+
func dumpOpenStackPorts(e2eCtx *E2EContext, logPath string) error {
148+
portsList, err := DumpOpenStackPorts(e2eCtx, ports.ListOpts{})
149+
if err != nil {
150+
return err
151+
}
152+
portsJSON, err := json.MarshalIndent(portsList, "", " ")
153+
if err != nil {
154+
return fmt.Errorf("error marshalling ports %v: %s", portsList, err)
155+
}
156+
if err := os.WriteFile(path.Join(logPath, "ports.json"), portsJSON, 0o600); err != nil {
157+
return fmt.Errorf("error writing ports.json %s: %s", portsJSON, err)
139158
}
159+
140160
return nil
141161
}
142162

0 commit comments

Comments
 (0)