Merge pull request #99441 from CKchen0726/csi-client

migrate volume/csi/csi-client.go logs to structured logging
This commit is contained in:
Kubernetes Prow Robot 2022-01-12 11:52:13 -08:00 committed by GitHub
commit e22ec17057
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -176,12 +176,12 @@ func (c *csiDriverClient) NodeGetInfo(ctx context.Context) (
maxVolumePerNode int64, maxVolumePerNode int64,
accessibleTopology map[string]string, accessibleTopology map[string]string,
err error) { err error) {
klog.V(4).Info(log("calling NodeGetInfo rpc")) klog.V(4).InfoS(log("calling NodeGetInfo rpc"))
var getNodeInfoError error var getNodeInfoError error
nodeID, maxVolumePerNode, accessibleTopology, getNodeInfoError = c.nodeGetInfoV1(ctx) nodeID, maxVolumePerNode, accessibleTopology, getNodeInfoError = c.nodeGetInfoV1(ctx)
if getNodeInfoError != nil { if getNodeInfoError != nil {
klog.Warningf("Error calling CSI NodeGetInfo(): %v", getNodeInfoError.Error()) klog.InfoS("Error calling CSI NodeGetInfo()", "err", getNodeInfoError.Error())
} }
return nodeID, maxVolumePerNode, accessibleTopology, getNodeInfoError return nodeID, maxVolumePerNode, accessibleTopology, getNodeInfoError
} }
@ -224,7 +224,7 @@ func (c *csiDriverClient) NodePublishVolume(
mountOptions []string, mountOptions []string,
fsGroup *int64, fsGroup *int64,
) error { ) error {
klog.V(4).Info(log("calling NodePublishVolume rpc [volid=%s,target_path=%s]", volID, targetPath)) klog.V(4).InfoS(log("calling NodePublishVolume rpc"), "volID", volID, "targetPath", targetPath)
if volID == "" { if volID == "" {
return errors.New("missing volume id") return errors.New("missing volume id")
} }
@ -358,7 +358,7 @@ func (c *csiDriverClient) NodeExpandVolume(ctx context.Context, opts csiResizeOp
} }
func (c *csiDriverClient) NodeUnpublishVolume(ctx context.Context, volID string, targetPath string) error { func (c *csiDriverClient) NodeUnpublishVolume(ctx context.Context, volID string, targetPath string) error {
klog.V(4).Info(log("calling NodeUnpublishVolume rpc: [volid=%s, target_path=%s", volID, targetPath)) klog.V(4).InfoS(log("calling NodeUnpublishVolume rpc"), "volID", volID, "targetPath", targetPath)
if volID == "" { if volID == "" {
return errors.New("missing volume id") return errors.New("missing volume id")
} }
@ -395,7 +395,7 @@ func (c *csiDriverClient) NodeStageVolume(ctx context.Context,
mountOptions []string, mountOptions []string,
fsGroup *int64, fsGroup *int64,
) error { ) error {
klog.V(4).Info(log("calling NodeStageVolume rpc [volid=%s,staging_target_path=%s]", volID, stagingTargetPath)) klog.V(4).InfoS(log("calling NodeStageVolume rpc"), "volID", volID, "stagingTargetPath", stagingTargetPath)
if volID == "" { if volID == "" {
return errors.New("missing volume id") return errors.New("missing volume id")
} }
@ -455,7 +455,7 @@ func (c *csiDriverClient) NodeStageVolume(ctx context.Context,
} }
func (c *csiDriverClient) NodeUnstageVolume(ctx context.Context, volID, stagingTargetPath string) error { func (c *csiDriverClient) NodeUnstageVolume(ctx context.Context, volID, stagingTargetPath string) error {
klog.V(4).Info(log("calling NodeUnstageVolume rpc [volid=%s,staging_target_path=%s]", volID, stagingTargetPath)) klog.V(4).InfoS(log("calling NodeUnstageVolume rpc"), "volID", volID, "stagingTargetPath", stagingTargetPath)
if volID == "" { if volID == "" {
return errors.New("missing volume id") return errors.New("missing volume id")
} }
@ -532,7 +532,7 @@ func asSingleNodeMultiWriterCapableCSIAccessModeV1(am api.PersistentVolumeAccess
func newGrpcConn(addr csiAddr, metricsManager *MetricsManager) (*grpc.ClientConn, error) { func newGrpcConn(addr csiAddr, metricsManager *MetricsManager) (*grpc.ClientConn, error) {
network := "unix" network := "unix"
klog.V(4).Infof(log("creating new gRPC connection for [%s://%s]", network, addr)) klog.V(4).InfoS(log("creating new gRPC connection"), "protocol", network, "endpoint", addr)
return grpc.Dial( return grpc.Dial(
string(addr), string(addr),
@ -586,7 +586,7 @@ func (c *csiDriverClient) NodeSupportsSingleNodeMultiWriterAccessMode(ctx contex
} }
func (c *csiDriverClient) NodeGetVolumeStats(ctx context.Context, volID string, targetPath string) (*volume.Metrics, error) { func (c *csiDriverClient) NodeGetVolumeStats(ctx context.Context, volID string, targetPath string) (*volume.Metrics, error) {
klog.V(4).Info(log("calling NodeGetVolumeStats rpc: [volid=%s, target_path=%s", volID, targetPath)) klog.V(4).InfoS(log("calling NodeGetVolumeStats rpc"), "volID", volID, "targetPath", targetPath)
if volID == "" { if volID == "" {
return nil, errors.New("missing volume id") return nil, errors.New("missing volume id")
} }
@ -652,7 +652,7 @@ func (c *csiDriverClient) NodeGetVolumeStats(ctx context.Context, volID string,
metrics.Inodes = resource.NewQuantity(usage.GetTotal(), resource.BinarySI) metrics.Inodes = resource.NewQuantity(usage.GetTotal(), resource.BinarySI)
metrics.InodesUsed = resource.NewQuantity(usage.GetUsed(), resource.BinarySI) metrics.InodesUsed = resource.NewQuantity(usage.GetUsed(), resource.BinarySI)
default: default:
klog.Errorf("unknown key %s in usage", unit.String()) klog.ErrorS(nil, "unknown unit in VolumeUsage", "unit", unit.String())
} }
} }