Skip to content

Commit

Permalink
csiaddons: allow deleting of the CR
Browse files Browse the repository at this point in the history
The pod is set as the owner of the csiaddons
node object, and when the owner pod is deleted
the csiaddons need to be deleted as well, When
the delete Reconciles happens we cannot get the
pod deletails to resolve the endpoint and we dont
need that as well when we are deleting the CR.

Signed-off-by: Madhu Rajanna <[email protected]>
  • Loading branch information
Madhu-1 committed Dec 4, 2024
1 parent 60f22e1 commit be33795
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions internal/controller/csiaddons/csiaddonsnode_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,8 @@ func (r *CSIAddonsNodeReconciler) Reconcile(ctx context.Context, req ctrl.Reques
logger = logger.WithValues("NodeID", nodeID, "DriverName", driverName)

podName, endPoint, err := r.resolveEndpoint(ctx, csiAddonsNode.Spec.Driver.EndPoint)
if err != nil {
// In case of CR is marked for deletion, we dont need the connection to be established.
if err != nil && podName == "" && csiAddonsNode.DeletionTimestamp.IsZero() {
logger.Error(err, "Failed to resolve endpoint")
return ctrl.Result{}, fmt.Errorf("failed to resolve endpoint %q: %w", csiAddonsNode.Spec.Driver.EndPoint, err)
}
Expand Down Expand Up @@ -340,9 +341,9 @@ func (r *CSIAddonsNodeReconciler) resolveEndpoint(ctx context.Context, rawURL st
Name: podname,
}, pod)
if err != nil {
return "", "", fmt.Errorf("failed to get pod %s/%s: %w", namespace, podname, err)
return podname, "", fmt.Errorf("failed to get pod %s/%s: %w", namespace, podname, err)
} else if pod.Status.PodIP == "" {
return "", "", fmt.Errorf("pod %s/%s does not have an IP-address", namespace, podname)
return podname, "", fmt.Errorf("pod %s/%s does not have an IP-address", namespace, podname)
}

return podname, fmt.Sprintf("%s:%s", pod.Status.PodIP, port), nil
Expand Down

0 comments on commit be33795

Please sign in to comment.