From ec466fd45eacc7f912b44f0e85e16b753fb4e0da Mon Sep 17 00:00:00 2001 From: eshulman Date: Tue, 5 Nov 2024 08:55:19 +0200 Subject: [PATCH] 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 --- pkg/ansibletest/volumes.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/pkg/ansibletest/volumes.go b/pkg/ansibletest/volumes.go index df9ad32d..5ee03552 100644 --- a/pkg/ansibletest/volumes.go +++ b/pkg/ansibletest/volumes.go @@ -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, @@ -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{ @@ -217,5 +217,6 @@ func GetVolumeMounts(mountCerts bool, instance *testv1beta1.AnsibleTest, externa volumeMounts = append(volumeMounts, extraConfigmapsMounts) } } + return volumeMounts }