From 4371d896ba88033f379ee9e47291a4ffeb2e5f81 Mon Sep 17 00:00:00 2001 From: Rewant Soni Date: Tue, 1 Oct 2024 14:37:20 +0530 Subject: [PATCH 1/2] sanitize pod name for connection pool key The csi-addons sidecar sanitizes the holder identity. The connection pool stores the mapping with key as the unsanitized name for csiaddonsnode, which leads to the failed to find the namespace where driver issue. To address this, we should sanitize the csiaddonsnode name before entering it into connection pool. Signed-off-by: Rewant Soni --- internal/controller/csiaddons/csiaddonsnode_controller.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/controller/csiaddons/csiaddonsnode_controller.go b/internal/controller/csiaddons/csiaddonsnode_controller.go index 13a8b062e..9f141f359 100644 --- a/internal/controller/csiaddons/csiaddonsnode_controller.go +++ b/internal/controller/csiaddons/csiaddonsnode_controller.go @@ -95,7 +95,7 @@ func (r *CSIAddonsNodeReconciler) Reconcile(ctx context.Context, req ctrl.Reques nodeID := csiAddonsNode.Spec.Driver.NodeID driverName := csiAddonsNode.Spec.Driver.Name - key := csiAddonsNode.Namespace + "/" + csiAddonsNode.Name + key := csiAddonsNode.Namespace + "/" + util.NormalizeLeaseName(csiAddonsNode.Name) logger = logger.WithValues("NodeID", nodeID, "DriverName", driverName) if !csiAddonsNode.DeletionTimestamp.IsZero() { From 7b4049db0de828894e709f8768395d81ee1f284f Mon Sep 17 00:00:00 2001 From: Rewant Soni Date: Tue, 1 Oct 2024 19:51:33 +0530 Subject: [PATCH 2/2] improve logging Signed-off-by: Rewant Soni --- internal/controller/csiaddons/csiaddonsnode_controller.go | 4 ++-- .../replication.storage/volumereplication_controller.go | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/internal/controller/csiaddons/csiaddonsnode_controller.go b/internal/controller/csiaddons/csiaddonsnode_controller.go index 9f141f359..d5f0f763e 100644 --- a/internal/controller/csiaddons/csiaddonsnode_controller.go +++ b/internal/controller/csiaddons/csiaddonsnode_controller.go @@ -101,7 +101,7 @@ func (r *CSIAddonsNodeReconciler) Reconcile(ctx context.Context, req ctrl.Reques if !csiAddonsNode.DeletionTimestamp.IsZero() { // if deletion timestamp is set, the CSIAddonsNode is getting deleted, // delete connections and remove finalizer. - logger.Info("Deleting connection") + logger.Info("Deleting connection", "Key", key) r.ConnPool.Delete(key) err = r.removeFinalizer(ctx, &logger, csiAddonsNode) return ctrl.Result{}, err @@ -139,7 +139,7 @@ func (r *CSIAddonsNodeReconciler) Reconcile(ctx context.Context, req ctrl.Reques logger.Info("Successfully connected to sidecar") r.ConnPool.Put(key, newConn) - logger.Info("Added connection to connection pool") + logger.Info("Added connection to connection pool", "Key", key) csiAddonsNode.Status.State = csiaddonsv1alpha1.CSIAddonsNodeStateConnected csiAddonsNode.Status.Message = "Successfully established connection with sidecar" diff --git a/internal/controller/replication.storage/volumereplication_controller.go b/internal/controller/replication.storage/volumereplication_controller.go index 288d0c8ac..c69fd8e40 100644 --- a/internal/controller/replication.storage/volumereplication_controller.go +++ b/internal/controller/replication.storage/volumereplication_controller.go @@ -510,7 +510,7 @@ func getInfoReconcileInterval(parameters map[string]string, logger logr.Logger) func (r *VolumeReplicationReconciler) getReplicationClient(ctx context.Context, driverName, dataSource string) (grpcClient.VolumeReplication, error) { conn, err := r.Connpool.GetLeaderByDriver(ctx, r.Client, driverName) if err != nil { - return nil, fmt.Errorf("no leader for the ControllerService of driver %q", driverName) + return nil, fmt.Errorf("no leader for the ControllerService of driver %q: %w", driverName, err) } for _, cap := range conn.Capabilities {