Skip to content

Commit

Permalink
Fix potential nil pointer dereference in reconcile loop
Browse files Browse the repository at this point in the history
Fix potential for a panic due to nil pointer dereference if the
workspace ServiceAccount does not exist.

Signed-off-by: Angel Misevski <amisevsk@redhat.com>
  • Loading branch information
amisevsk committed Jun 30, 2023
1 parent b4fc4ea commit 559bb39
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
6 changes: 4 additions & 2 deletions controllers/workspace/devworkspace_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -443,8 +443,10 @@ func (r *DevWorkspaceReconciler) Reconcile(ctx context.Context, req ctrl.Request
return reconcileResult, reconcileErr
}

allPodAdditions = append(allPodAdditions, *pullSecretPodAdditions)
reconcileStatus.setConditionTrue(conditions.PullSecretsReady, "DevWorkspace secrets ready")
if pullSecretPodAdditions != nil && pullSecretPodAdditions.PullSecrets != nil {
allPodAdditions = append(allPodAdditions, *pullSecretPodAdditions)
reconcileStatus.setConditionTrue(conditions.PullSecretsReady, "DevWorkspace secrets ready")
}

if kubesync.HasKubelikeComponent(workspace) {
err := kubesync.HandleKubernetesComponents(workspace, clusterAPI)
Expand Down
2 changes: 1 addition & 1 deletion pkg/provision/workspace/pull_secret.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ func PullSecrets(clusterAPI sync.ClusterAPI, serviceAccountName, namespace strin
if err != nil {
if k8sErrors.IsNotFound(err) {
// ServiceAccount does not exist, no pull secrets to extract
return nil, nil
return &v1alpha1.PodAdditions{}, nil
}
return nil, err
}
Expand Down

0 comments on commit 559bb39

Please sign in to comment.