diff --git a/charts/latest/azurefile-csi-driver-v1.29.0.tgz b/charts/latest/azurefile-csi-driver-v1.29.0.tgz index f8a9ece262..7ee7a8fd29 100644 Binary files a/charts/latest/azurefile-csi-driver-v1.29.0.tgz and b/charts/latest/azurefile-csi-driver-v1.29.0.tgz differ diff --git a/charts/latest/azurefile-csi-driver/templates/csi-azurefile-node-windows-hostprocess.yaml b/charts/latest/azurefile-csi-driver/templates/csi-azurefile-node-windows-hostprocess.yaml index 0e2e6b9639..644eef5cec 100644 --- a/charts/latest/azurefile-csi-driver/templates/csi-azurefile-node-windows-hostprocess.yaml +++ b/charts/latest/azurefile-csi-driver/templates/csi-azurefile-node-windows-hostprocess.yaml @@ -124,6 +124,7 @@ spec: - "--allow-empty-cloud-config={{ .Values.node.allowEmptyCloudConfig }}" - "--enable-get-volume-stats={{ .Values.feature.enableGetVolumeStats }}" - "--enable-windows-host-process=true" + - "--metrics-address=0.0.0.0:{{ .Values.node.metricsPort }}" env: - name: AZURE_CREDENTIAL_FILE valueFrom: diff --git a/charts/latest/azurefile-csi-driver/templates/csi-azurefile-node-windows.yaml b/charts/latest/azurefile-csi-driver/templates/csi-azurefile-node-windows.yaml index d7cf19b25e..f171603d73 100644 --- a/charts/latest/azurefile-csi-driver/templates/csi-azurefile-node-windows.yaml +++ b/charts/latest/azurefile-csi-driver/templates/csi-azurefile-node-windows.yaml @@ -137,6 +137,7 @@ spec: - "--allow-empty-cloud-config={{ .Values.node.allowEmptyCloudConfig }}" - "--enable-get-volume-stats={{ .Values.feature.enableGetVolumeStats }}" - "--allow-inline-volume-key-access-with-identity={{ .Values.node.allowInlineVolumeKeyAccessWithIdentity }}" + - "--metrics-address=0.0.0.0:{{ .Values.node.metricsPort }}" ports: - containerPort: {{ .Values.node.livenessProbe.healthPort }} name: healthz diff --git a/charts/latest/azurefile-csi-driver/templates/csi-azurefile-node.yaml b/charts/latest/azurefile-csi-driver/templates/csi-azurefile-node.yaml index 1998b824cb..57b04d149c 100644 --- a/charts/latest/azurefile-csi-driver/templates/csi-azurefile-node.yaml +++ b/charts/latest/azurefile-csi-driver/templates/csi-azurefile-node.yaml @@ -135,6 +135,7 @@ spec: - "--enable-get-volume-stats={{ .Values.feature.enableGetVolumeStats }}" - "--mount-permissions={{ .Values.linux.mountPermissions }}" - "--allow-inline-volume-key-access-with-identity={{ .Values.node.allowInlineVolumeKeyAccessWithIdentity }}" + - "--metrics-address=0.0.0.0:{{ .Values.node.metricsPort }}" ports: - containerPort: {{ .Values.node.livenessProbe.healthPort }} name: healthz diff --git a/charts/latest/azurefile-csi-driver/values.yaml b/charts/latest/azurefile-csi-driver/values.yaml index cbe58a2a83..b8bd4cb990 100644 --- a/charts/latest/azurefile-csi-driver/values.yaml +++ b/charts/latest/azurefile-csi-driver/values.yaml @@ -124,6 +124,7 @@ node: cloudConfigSecretNamespace: kube-system allowEmptyCloudConfig: true allowInlineVolumeKeyAccessWithIdentity: false + metricsPort: 29615 livenessProbe: healthPort: 29613 logLevel: 5 diff --git a/deploy/csi-azurefile-node-windows-hostprocess.yaml b/deploy/csi-azurefile-node-windows-hostprocess.yaml index 08fe04b94b..3ee7e5e381 100644 --- a/deploy/csi-azurefile-node-windows-hostprocess.yaml +++ b/deploy/csi-azurefile-node-windows-hostprocess.yaml @@ -87,6 +87,7 @@ spec: - --endpoint=$(CSI_ENDPOINT) - --nodeid=$(KUBE_NODE_NAME) - --enable-windows-host-process=true + - --metrics-address="0.0.0.0:29615" env: - name: AZURE_CREDENTIAL_FILE valueFrom: diff --git a/deploy/csi-azurefile-node-windows.yaml b/deploy/csi-azurefile-node-windows.yaml index 8db3f612f0..e09a03c66f 100644 --- a/deploy/csi-azurefile-node-windows.yaml +++ b/deploy/csi-azurefile-node-windows.yaml @@ -100,6 +100,7 @@ spec: - --v=5 - --endpoint=$(CSI_ENDPOINT) - --nodeid=$(KUBE_NODE_NAME) + - --metrics-address="0.0.0.0:29615" ports: - containerPort: 29613 name: healthz diff --git a/deploy/csi-azurefile-node.yaml b/deploy/csi-azurefile-node.yaml index bd6bf671b3..749d39f95e 100644 --- a/deploy/csi-azurefile-node.yaml +++ b/deploy/csi-azurefile-node.yaml @@ -91,6 +91,7 @@ spec: - "--v=5" - "--endpoint=$(CSI_ENDPOINT)" - "--nodeid=$(KUBE_NODE_NAME)" + - "--metrics-address=0.0.0.0:29615" ports: - containerPort: 29613 name: healthz diff --git a/pkg/azurefile/nodeserver.go b/pkg/azurefile/nodeserver.go index 17404fe0ae..38a175aad5 100644 --- a/pkg/azurefile/nodeserver.go +++ b/pkg/azurefile/nodeserver.go @@ -37,6 +37,7 @@ import ( "golang.org/x/net/context" azcache "sigs.k8s.io/cloud-provider-azure/pkg/cache" + "sigs.k8s.io/cloud-provider-azure/pkg/metrics" ) // NodePublishVolume mount the volume from staging to target path @@ -158,6 +159,12 @@ func (d *Driver) NodeStageVolume(ctx context.Context, req *csi.NodeStageVolumeRe volumeMountGroup := req.GetVolumeCapability().GetMount().GetVolumeMountGroup() gidPresent := checkGidPresentInMountFlags(mountFlags) + mc := metrics.NewMetricContext(azureFileCSIDriverName, "node_stage_volume", d.cloud.ResourceGroup, "", d.Name) + isOperationSucceeded := false + defer func() { + mc.ObserveOperationWithResult(isOperationSucceeded, VolumeID, volumeID) + }() + _, accountName, accountKey, fileShareName, diskName, _, err := d.GetAccountInfo(ctx, volumeID, req.GetSecrets(), context) if err != nil { return nil, status.Error(codes.InvalidArgument, fmt.Sprintf("GetAccountInfo(%s) failed with error: %v", volumeID, err)) @@ -369,6 +376,8 @@ func (d *Driver) NodeStageVolume(ctx context.Context, req *csi.NodeStageVolumeRe } } } + + isOperationSucceeded = true return &csi.NodeStageVolumeResponse{}, nil } @@ -388,6 +397,12 @@ func (d *Driver) NodeUnstageVolume(ctx context.Context, req *csi.NodeUnstageVolu } defer d.volumeLocks.Release(volumeID) + mc := metrics.NewMetricContext(azureFileCSIDriverName, "node_unstage_volume", d.cloud.ResourceGroup, "", d.Name) + isOperationSucceeded := false + defer func() { + mc.ObserveOperationWithResult(isOperationSucceeded, VolumeID, volumeID) + }() + klog.V(2).Infof("NodeUnstageVolume: CleanupMountPoint volume %s on %s", volumeID, stagingTargetPath) if err := CleanupMountPoint(d.mounter, stagingTargetPath, true /*extensiveMountPointCheck*/); err != nil { return nil, status.Errorf(codes.Internal, "failed to unmount staging target %s: %v", stagingTargetPath, err) @@ -400,6 +415,7 @@ func (d *Driver) NodeUnstageVolume(ctx context.Context, req *csi.NodeUnstageVolu } klog.V(2).Infof("NodeUnstageVolume: unmount volume %s on %s successfully", volumeID, stagingTargetPath) + isOperationSucceeded = true return &csi.NodeUnstageVolumeResponse{}, nil } @@ -472,6 +488,12 @@ func (d *Driver) NodeGetVolumeStats(ctx context.Context, req *csi.NodeGetVolumeS klog.V(6).Infof("NodeGetVolumeStats: begin to get VolumeStats on volume %s path %s", req.VolumeId, req.VolumePath) } + mc := metrics.NewMetricContext(azureFileCSIDriverName, "node_get_volume_stats", d.cloud.ResourceGroup, "", d.Name) + isOperationSucceeded := false + defer func() { + mc.ObserveOperationWithResult(isOperationSucceeded, VolumeID, req.VolumeId) + }() + resp, err := GetVolumeStats(req.VolumePath, d.enableWindowsHostProcess) if err == nil && resp != nil { if d.printVolumeStatsCallLogs { @@ -485,6 +507,7 @@ func (d *Driver) NodeGetVolumeStats(ctx context.Context, req *csi.NodeGetVolumeS d.volStatsCache.Set(newVolID, *resp) } } + isOperationSucceeded = true return resp, err }