@@ -25,6 +25,7 @@ import (
2525 "google.golang.org/grpc/codes"
2626 "k8s.io/component-base/metrics"
2727 "k8s.io/klog/v2"
28+ "k8s.io/mount-utils"
2829 "sigs.k8s.io/gcp-compute-persistent-disk-csi-driver/pkg/common"
2930)
3031
5354 StabilityLevel : metrics .ALPHA ,
5455 },
5556 []string {"driver_name" , "method_name" , "grpc_status_code" , "disk_type" , "enable_confidential_storage" , "enable_storage_pools" })
57+
58+ mountErrorMetric = metrics .NewCounterVec (& metrics.CounterOpts {
59+ Subsystem : "node" ,
60+ Name : "mount_errors" ,
61+ Help : "Node server file system mounting errors" ,
62+ StabilityLevel : metrics .ALPHA ,
63+ },
64+ []string {"driver_name" , "file_system_format" , "error_type" },
65+ )
5666)
5767
5868type MetricsManager struct {
@@ -78,6 +88,10 @@ func (mm *MetricsManager) RegisterPDCSIMetric() {
7888 mm .registry .MustRegister (pdcsiOperationErrorsMetric )
7989}
8090
91+ func (mm * MetricsManager ) RegisterMountMetric () {
92+ mm .registry .MustRegister (mountErrorMetric )
93+ }
94+
8195func (mm * MetricsManager ) recordComponentVersionMetric () error {
8296 v := getEnvVar (envGKEPDCSIVersion )
8397 if v == "" {
@@ -101,6 +115,16 @@ func (mm *MetricsManager) RecordOperationErrorMetrics(
101115 klog .Infof ("Recorded PDCSI operation error code: %q" , errCode )
102116}
103117
118+ func (mm * MetricsManager ) RecordMountErrorMetric (fs_format string , err error ) {
119+ errType := mountErrorType (err )
120+ mountErrorMetric .WithLabelValues (pdcsiDriverName , fs_format , errType ).Inc ()
121+ klog .Infof ("Recorded mount error type: %q" , errType )
122+ }
123+
124+ func (mm * MetricsManager ) EmmitProcessStartTime () error {
125+ return metrics .RegisterProcessStartTime (mm .registry .Register )
126+ }
127+
104128func (mm * MetricsManager ) EmitGKEComponentVersion () error {
105129 mm .registerComponentVersionMetric ()
106130 if err := mm .recordComponentVersionMetric (); err != nil {
@@ -169,3 +193,16 @@ func errorCodeLabelValue(operationErr error) string {
169193 }
170194 return err
171195}
196+
197+ func mountErrorType (err error ) string {
198+ if err == nil {
199+ return "OK"
200+ }
201+
202+ mntErr := & mount.MountError {}
203+ if ! errors .As (err , mntErr ) {
204+ return "UnknownError"
205+ }
206+
207+ return string (mntErr .Type )
208+ }
0 commit comments