Skip to content

Commit ec466fd

Browse files
committed
Fix the nil pointing issue
When a workflow is set without ExtraConfigMap in ansible controller the pod won't be able to start because the pointer won't be pointing at nothing. Changed the condition to allow avoiding this issue. not tested, waiting for a test enviornment to work on this Jira: https://issues.redhat.com/browse/OSPRH-11191
1 parent 06ff0ea commit ec466fd

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

pkg/ansibletest/volumes.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ func GetVolumes(
106106
volumes = append(volumes, extraVol)
107107
}
108108

109-
if len(instance.Spec.Workflow) > 0 {
109+
if len(instance.Spec.Workflow) > 0 && *instance.Spec.Workflow[externalWorkflowCounter].ExtraConfigmapsMounts != nil {
110110
for _, vol := range *instance.Spec.Workflow[externalWorkflowCounter].ExtraConfigmapsMounts {
111111
extraWorkflowVol := corev1.Volume{
112112
Name: vol.Name,
@@ -204,7 +204,7 @@ func GetVolumeMounts(mountCerts bool, instance *testv1beta1.AnsibleTest, externa
204204
volumeMounts = append(volumeMounts, extraConfigmapsMounts)
205205
}
206206

207-
if len(instance.Spec.Workflow) > 0 {
207+
if len(instance.Spec.Workflow) > 0 && *instance.Spec.Workflow[externalWorkflowCounter].ExtraConfigmapsMounts != nil {
208208
for _, vol := range *instance.Spec.Workflow[externalWorkflowCounter].ExtraConfigmapsMounts {
209209

210210
extraConfigmapsMounts := corev1.VolumeMount{
@@ -217,5 +217,6 @@ func GetVolumeMounts(mountCerts bool, instance *testv1beta1.AnsibleTest, externa
217217
volumeMounts = append(volumeMounts, extraConfigmapsMounts)
218218
}
219219
}
220+
220221
return volumeMounts
221222
}

0 commit comments

Comments
 (0)