Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[release-1.28] feat: add node metrics #1512

Merged
merged 1 commit into from
Oct 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified charts/latest/azurefile-csi-driver-v1.28.5.tgz
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions charts/latest/azurefile-csi-driver/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ node:
cloudConfigSecretNamespace: kube-system
allowEmptyCloudConfig: true
allowInlineVolumeKeyAccessWithIdentity: false
metricsPort: 29615
livenessProbe:
healthPort: 29613
logLevel: 5
Expand Down
1 change: 1 addition & 0 deletions deploy/csi-azurefile-node-windows-hostprocess.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
1 change: 1 addition & 0 deletions deploy/csi-azurefile-node-windows.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions deploy/csi-azurefile-node.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
23 changes: 23 additions & 0 deletions pkg/azurefile/nodeserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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))
Expand Down Expand Up @@ -369,6 +376,8 @@ func (d *Driver) NodeStageVolume(ctx context.Context, req *csi.NodeStageVolumeRe
}
}
}

isOperationSucceeded = true
return &csi.NodeStageVolumeResponse{}, nil
}

Expand All @@ -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)
Expand All @@ -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
}

Expand Down Expand Up @@ -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 {
Expand All @@ -485,6 +507,7 @@ func (d *Driver) NodeGetVolumeStats(ctx context.Context, req *csi.NodeGetVolumeS
d.volStatsCache.Set(newVolID, *resp)
}
}
isOperationSucceeded = true
return resp, err
}

Expand Down