Skip to content

Commit 28debf2

Browse files
[release-1.32] [cinder-csi-plugin] Don't report topology capability when --with-topology=False (#2871)
* cinder-csi-plugin, manila-csi-plugin: Correct formatting character %T prints the type. %t prints the word true/false, which is what we want. [1] [1] https://pkg.go.dev/fmt Signed-off-by: Stephen Finucane <[email protected]> * cinder-csi-plugin: Don't report topology capability when --with-topology=False The 'PluginCapability_Service_VOLUME_ACCESSIBILITY_CONSTRAINTS' capability flag determines whether the provisioner attempts to look up topology information from the node or not [1][2]. If we report it but don't return topology information from the node, we end up with failures to provision [3]. Fix the issue by optionally reporting the capability, like Manila already does. [1] https://github.com/kubernetes-csi/external-provisioner/blob/17e2429e9f/pkg/controller/controller.go#L685-L700 [2] https://github.com/kubernetes-csi/external-provisioner/blob/17e2429e9f/pkg/controller/controller.go#L994-L996 [3] https://github.com/kubernetes-csi/external-provisioner/blob/17e2429e9f/pkg/controller/topology.go#L177 Signed-off-by: Stephen Finucane <[email protected]> * manila-csi-plugin: Unify some logging between cinder, manila Signed-off-by: Stephen Finucane <[email protected]> --------- Signed-off-by: Stephen Finucane <[email protected]> Co-authored-by: Stephen Finucane <[email protected]>
1 parent 9d0b275 commit 28debf2

File tree

4 files changed

+37
-26
lines changed

4 files changed

+37
-26
lines changed

pkg/csi/cinder/driver.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ func NewDriver(o *DriverOpts) *Driver {
101101
klog.Info("Driver: ", d.name)
102102
klog.Info("Driver version: ", d.fqVersion)
103103
klog.Info("CSI Spec version: ", specVersion)
104-
klog.Infof("Topology awareness: %T", d.withTopology)
104+
klog.Infof("Topology awareness: %t", d.withTopology)
105105

106106
d.AddControllerServiceCapabilities(
107107
[]csi.ControllerServiceCapability_RPC_Type{

pkg/csi/cinder/identityserver.go

Lines changed: 27 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -53,36 +53,39 @@ func (ids *identityServer) Probe(ctx context.Context, req *csi.ProbeRequest) (*c
5353

5454
func (ids *identityServer) GetPluginCapabilities(ctx context.Context, req *csi.GetPluginCapabilitiesRequest) (*csi.GetPluginCapabilitiesResponse, error) {
5555
klog.V(5).Infof("GetPluginCapabilities called with req %+v", req)
56-
return &csi.GetPluginCapabilitiesResponse{
57-
Capabilities: []*csi.PluginCapability{
58-
{
59-
Type: &csi.PluginCapability_Service_{
60-
Service: &csi.PluginCapability_Service{
61-
Type: csi.PluginCapability_Service_CONTROLLER_SERVICE,
62-
},
56+
caps := []*csi.PluginCapability{
57+
{
58+
Type: &csi.PluginCapability_Service_{
59+
Service: &csi.PluginCapability_Service{
60+
Type: csi.PluginCapability_Service_CONTROLLER_SERVICE,
6361
},
6462
},
65-
{
66-
Type: &csi.PluginCapability_Service_{
67-
Service: &csi.PluginCapability_Service{
68-
Type: csi.PluginCapability_Service_VOLUME_ACCESSIBILITY_CONSTRAINTS,
69-
},
63+
},
64+
{
65+
Type: &csi.PluginCapability_VolumeExpansion_{
66+
VolumeExpansion: &csi.PluginCapability_VolumeExpansion{
67+
Type: csi.PluginCapability_VolumeExpansion_ONLINE,
7068
},
7169
},
72-
{
73-
Type: &csi.PluginCapability_VolumeExpansion_{
74-
VolumeExpansion: &csi.PluginCapability_VolumeExpansion{
75-
Type: csi.PluginCapability_VolumeExpansion_ONLINE,
76-
},
70+
},
71+
{
72+
Type: &csi.PluginCapability_VolumeExpansion_{
73+
VolumeExpansion: &csi.PluginCapability_VolumeExpansion{
74+
Type: csi.PluginCapability_VolumeExpansion_OFFLINE,
7775
},
7876
},
79-
{
80-
Type: &csi.PluginCapability_VolumeExpansion_{
81-
VolumeExpansion: &csi.PluginCapability_VolumeExpansion{
82-
Type: csi.PluginCapability_VolumeExpansion_OFFLINE,
83-
},
77+
},
78+
}
79+
80+
if ids.Driver.withTopology {
81+
caps = append(caps, &csi.PluginCapability{
82+
Type: &csi.PluginCapability_Service_{
83+
Service: &csi.PluginCapability_Service{
84+
Type: csi.PluginCapability_Service_VOLUME_ACCESSIBILITY_CONSTRAINTS,
8485
},
8586
},
86-
},
87-
}, nil
87+
})
88+
}
89+
90+
return &csi.GetPluginCapabilitiesResponse{Capabilities: caps}, nil
8891
}

pkg/csi/manila/driver.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ func NewDriver(o *DriverOpts) (*Driver, error) {
130130
klog.Info("Driver: ", d.name)
131131
klog.Info("Driver version: ", d.fqVersion)
132132
klog.Info("CSI spec version: ", specVersion)
133-
klog.Infof("Topology awareness: %T", d.withTopology)
133+
klog.Infof("Topology awareness: %t", d.withTopology)
134134

135135
getShareAdapter(d.shareProto) // The program will terminate with a non-zero exit code if the share protocol selector is wrong
136136
klog.Infof("Operating on %s shares", d.shareProto)

pkg/csi/manila/identityserver.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import (
2222
"github.com/container-storage-interface/spec/lib/go/csi"
2323
"google.golang.org/grpc/codes"
2424
"google.golang.org/grpc/status"
25+
"k8s.io/klog/v2"
2526
)
2627

2728
type identityServer struct {
@@ -30,10 +31,16 @@ type identityServer struct {
3031
}
3132

3233
func (ids *identityServer) GetPluginInfo(ctx context.Context, req *csi.GetPluginInfoRequest) (*csi.GetPluginInfoResponse, error) {
34+
klog.V(5).Infof("Using default GetPluginInfo")
35+
3336
if ids.d.name == "" {
3437
return nil, status.Error(codes.Unavailable, "Driver name not configured")
3538
}
3639

40+
if ids.d.fqVersion == "" {
41+
return nil, status.Error(codes.Unavailable, "Driver is missing version")
42+
}
43+
3744
return &csi.GetPluginInfoResponse{
3845
Name: ids.d.name,
3946
VendorVersion: ids.d.fqVersion,
@@ -51,6 +58,7 @@ func (ids *identityServer) Probe(ctx context.Context, req *csi.ProbeRequest) (*c
5158
}
5259

5360
func (ids *identityServer) GetPluginCapabilities(ctx context.Context, req *csi.GetPluginCapabilitiesRequest) (*csi.GetPluginCapabilitiesResponse, error) {
61+
klog.V(5).Infof("GetPluginCapabilities called with req %+v", req)
5462
caps := []*csi.PluginCapability{
5563
{
5664
Type: &csi.PluginCapability_Service_{

0 commit comments

Comments
 (0)