Skip to content

Commit 0dc0867

Browse files
mohammedabdulwahhabjain-ria
authored andcommitted
fix: nil pointer deref in dynamo controller (#2333)
1 parent 01f317d commit 0dc0867

File tree

1 file changed

+8
-4
lines changed
  • deploy/cloud/operator/internal/dynamo

1 file changed

+8
-4
lines changed

deploy/cloud/operator/internal/dynamo/graph.go

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -166,12 +166,16 @@ func GenerateDynamoComponentsDeployments(ctx context.Context, parentDynamoGraphD
166166
labels[commonconsts.KubeLabelDynamoComponent] = componentName
167167
labels[commonconsts.KubeLabelDynamoNamespace] = dynamoNamespace
168168
if component.ComponentType == commonconsts.ComponentTypePlanner {
169+
// ensure that the extraPodSpec is not nil
169170
if deployment.Spec.ExtraPodSpec == nil {
170-
deployment.Spec.ExtraPodSpec = &common.ExtraPodSpec{
171-
PodSpec: &corev1.PodSpec{},
172-
}
171+
deployment.Spec.ExtraPodSpec = &common.ExtraPodSpec{}
172+
}
173+
// ensure that the embedded PodSpec struct is not nil
174+
if deployment.Spec.ExtraPodSpec.PodSpec == nil {
175+
deployment.Spec.ExtraPodSpec.PodSpec = &corev1.PodSpec{}
173176
}
174-
deployment.Spec.ExtraPodSpec.ServiceAccountName = commonconsts.PlannerServiceAccountName
177+
// finally set the service account name
178+
deployment.Spec.ExtraPodSpec.PodSpec.ServiceAccountName = commonconsts.PlannerServiceAccountName
175179
}
176180
if deployment.IsMainComponent() && defaultIngressSpec != nil && deployment.Spec.Ingress == nil {
177181
deployment.Spec.Ingress = defaultIngressSpec

0 commit comments

Comments
 (0)