Skip to content

Commit 209f30f

Browse files
authored
[release-1.31] [cinder-csi-plugin] Don't report topology capability when --with-topology=False (#2872)
* 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 Conflicts: pkg/csi/manila/driver.go NOTE(stephenfin): Merge conflicts are due to the absence of PR #2734, which we don't want to backport. 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]>
1 parent a61afc8 commit 209f30f

File tree

4 files changed

+37
-25
lines changed

4 files changed

+37
-25
lines changed

pkg/csi/cinder/driver.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ func NewDriver(o *DriverOpts) *Driver {
8888
klog.Info("Driver: ", d.name)
8989
klog.Info("Driver version: ", d.fqVersion)
9090
klog.Info("CSI Spec version: ", specVersion)
91-
klog.Infof("Topology awareness: %T", d.withTopology)
91+
klog.Infof("Topology awareness: %t", d.withTopology)
9292

9393
d.AddControllerServiceCapabilities(
9494
[]csi.ControllerServiceCapability_RPC_Type{

pkg/csi/cinder/identityserver.go

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

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

pkg/csi/manila/driver.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,7 @@ func NewDriver(o *DriverOpts) (*Driver, error) {
127127
klog.Info("Driver: ", d.name)
128128
klog.Info("Driver version: ", d.fqVersion)
129129
klog.Info("CSI spec version: ", specVersion)
130+
klog.Infof("Topology awareness: %t", d.withTopology)
130131

131132
getShareAdapter(d.shareProto) // The program will terminate with a non-zero exit code if the share protocol selector is wrong
132133
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,17 +22,24 @@ 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 {
2829
d *Driver
2930
}
3031

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

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

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

0 commit comments

Comments
 (0)