@@ -23,15 +23,17 @@ import (
23
23
"google.golang.org/grpc/codes"
24
24
"google.golang.org/grpc/status"
25
25
"google.golang.org/protobuf/types/known/wrapperspb"
26
- "k8s.io/klog/v2"
27
26
)
28
27
28
+ // IdentityServer implements the CSI Identity service for the Linode Block Storage CSI Driver.
29
29
type IdentityServer struct {
30
30
driver * LinodeDriver
31
31
32
32
csi.UnimplementedIdentityServer
33
33
}
34
34
35
+ // NewIdentityServer creates and initializes a new IdentityServer.
36
+ // It takes a context and a LinodeDriver as input and returns a pointer to IdentityServer and an error.
35
37
func NewIdentityServer (ctx context.Context , linodeDriver * LinodeDriver ) (* IdentityServer , error ) {
36
38
log := logger .GetLogger (ctx )
37
39
@@ -50,9 +52,14 @@ func NewIdentityServer(ctx context.Context, linodeDriver *LinodeDriver) (*Identi
50
52
return identityServer , nil
51
53
}
52
54
53
- // GetPluginInfo(context.Context, *GetPluginInfoRequest) (*GetPluginInfoResponse, error)
55
+ // GetPluginInfo returns information about the CSI plugin.
56
+ // This method is REQUIRED for the Identity service as per the CSI spec.
57
+ // It returns the name and version of the CSI plugin.
54
58
func (linodeIdentity * IdentityServer ) GetPluginInfo (ctx context.Context , req * csi.GetPluginInfoRequest ) (* csi.GetPluginInfoResponse , error ) {
55
- klog .V (5 ).Infof ("Using default GetPluginInfo" )
59
+ log , _ , done := logger .GetLogger (ctx ).WithMethod ("GetPluginInfo" )
60
+ defer done ()
61
+
62
+ log .V (2 ).Info ("Processing request" )
56
63
57
64
if linodeIdentity .driver .name == "" {
58
65
return nil , status .Error (codes .Unavailable , "Driver name not configured" )
@@ -64,8 +71,15 @@ func (linodeIdentity *IdentityServer) GetPluginInfo(ctx context.Context, req *cs
64
71
}, nil
65
72
}
66
73
74
+ // GetPluginCapabilities returns the capabilities of the CSI plugin.
75
+ // This method is REQUIRED for the Identity service as per the CSI spec.
76
+ // It informs the CO of the supported features by this plugin.
67
77
func (linodeIdentity * IdentityServer ) GetPluginCapabilities (ctx context.Context , req * csi.GetPluginCapabilitiesRequest ) (* csi.GetPluginCapabilitiesResponse , error ) {
68
- klog .V (5 ).Infof ("Using default GetPluginCapabilities" )
78
+ log , _ , done := logger .GetLogger (ctx ).WithMethod ("GetPluginCapabilities" )
79
+ defer done ()
80
+
81
+ log .V (2 ).Info ("Processing request" )
82
+
69
83
return & csi.GetPluginCapabilitiesResponse {
70
84
Capabilities : []* csi.PluginCapability {
71
85
{
@@ -98,8 +112,15 @@ func (linodeIdentity *IdentityServer) GetPluginCapabilities(ctx context.Context,
98
112
}, nil
99
113
}
100
114
115
+ // Probe checks if the plugin is ready to serve requests.
116
+ // This method is REQUIRED for the Identity service as per the CSI spec.
117
+ // It allows the CO to check the readiness of the plugin.
101
118
func (linodeIdentity * IdentityServer ) Probe (ctx context.Context , req * csi.ProbeRequest ) (* csi.ProbeResponse , error ) {
102
- klog .V (4 ).Infof ("Probe called with args: %#v" , req )
119
+ log , _ , done := logger .GetLogger (ctx ).WithMethod ("Probe" )
120
+ defer done ()
121
+
122
+ log .V (2 ).Info ("Processing request" )
123
+
103
124
linodeIdentity .driver .readyMu .Lock ()
104
125
defer linodeIdentity .driver .readyMu .Unlock ()
105
126
0 commit comments