Skip to content

Commit

Permalink
Fix the nil pointing issue
Browse files Browse the repository at this point in the history
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
  • Loading branch information
eshulman2 committed Nov 11, 2024
1 parent 06ff0ea commit ec466fd
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions pkg/ansibletest/volumes.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ func GetVolumes(
volumes = append(volumes, extraVol)
}

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

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

extraConfigmapsMounts := corev1.VolumeMount{
Expand All @@ -217,5 +217,6 @@ func GetVolumeMounts(mountCerts bool, instance *testv1beta1.AnsibleTest, externa
volumeMounts = append(volumeMounts, extraConfigmapsMounts)
}
}

return volumeMounts
}

0 comments on commit ec466fd

Please sign in to comment.