Skip to content

Commit

Permalink
fix: implement structured logging
Browse files Browse the repository at this point in the history
Fix node structured logs.

Signed-off-by: Serge Logvinov <serge.logvinov@sinextra.dev>
  • Loading branch information
sergelogvinov committed Jun 13, 2024
1 parent c4448e1 commit cb5fb4e
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions pkg/csi/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,8 @@ func (n *NodeService) NodeStageVolume(_ context.Context, request *csi.NodeStageV
}
}

klog.V(3).InfoS("NodeStageVolume: volume mounted", "device", devicePath)

return &csi.NodeStageVolumeResponse{}, nil
}

Expand Down Expand Up @@ -271,6 +273,8 @@ func (n *NodeService) NodeUnstageVolume(_ context.Context, request *csi.NodeUnst
}
}

klog.V(3).InfoS("NodeUnstageVolume: volume unmouned", "device", devicePath)

return &csi.NodeUnstageVolumeResponse{}, nil
}

Expand Down Expand Up @@ -372,6 +376,10 @@ func (n *NodeService) NodePublishVolume(_ context.Context, request *csi.NodePubl
}
}

klog.V(3).InfoS("NodePublishVolume: volume published for pod", "device", devicePath,
"pod", klog.KRef(request.GetVolumeContext()["csi.storage.k8s.io/pod.namespace"], request.GetVolumeContext()["csi.storage.k8s.io/pod.name"]),
)

return &csi.NodePublishVolumeResponse{}, nil
}

Expand All @@ -393,6 +401,8 @@ func (n *NodeService) NodeUnpublishVolume(_ context.Context, request *csi.NodeUn
return nil, status.Errorf(codes.Internal, "Unmount of targetpath %s failed with error %v", targetPath, err)
}

klog.V(3).InfoS("NodePublishVolume: volume unpublished", "path", targetPath)

return &csi.NodeUnpublishVolumeResponse{}, nil
}

Expand Down Expand Up @@ -504,8 +514,8 @@ func (n *NodeService) NodeExpandVolume(_ context.Context, request *csi.NodeExpan
}

// NodeGetCapabilities get the node capabilities
func (n *NodeService) NodeGetCapabilities(_ context.Context, request *csi.NodeGetCapabilitiesRequest) (*csi.NodeGetCapabilitiesResponse, error) {
klog.V(4).InfoS("NodeGetCapabilities: called", "args", stripSecrets(*request))
func (n *NodeService) NodeGetCapabilities(_ context.Context, _ *csi.NodeGetCapabilitiesRequest) (*csi.NodeGetCapabilitiesResponse, error) {
klog.V(4).InfoS("NodeGetCapabilities: called")

caps := []*csi.NodeServiceCapability{}

Expand All @@ -524,8 +534,8 @@ func (n *NodeService) NodeGetCapabilities(_ context.Context, request *csi.NodeGe
}

// NodeGetInfo get the node info
func (n *NodeService) NodeGetInfo(ctx context.Context, request *csi.NodeGetInfoRequest) (*csi.NodeGetInfoResponse, error) {
klog.V(4).InfoS("NodeGetInfo: called", "args", stripSecrets(*request))
func (n *NodeService) NodeGetInfo(ctx context.Context, _ *csi.NodeGetInfoRequest) (*csi.NodeGetInfoResponse, error) {
klog.V(4).InfoS("NodeGetInfo: called")

node, err := n.kclient.CoreV1().Nodes().Get(ctx, n.nodeID, metav1.GetOptions{})
if err != nil {
Expand Down

0 comments on commit cb5fb4e

Please sign in to comment.