Skip to content

Commit b5f9a02

Browse files
Mrton0121sergelogvinov
authored andcommitted
feat: using shared storage without applying zone labels for the kubernetes nodes
fix-me add body Signed-off-by: Mrton0121 <gombimarci@gmail.com> Signed-off-by: Serge Logvinov <serge.logvinov@sinextra.dev>
1 parent 1f10218 commit b5f9a02

3 files changed

Lines changed: 14 additions & 7 deletions

File tree

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ It is very important to use disk controller `VirtIO SCSI single` with `iothread`
7979
### Kubernetes Topology Labels
8080

8181
Proxmox CSI Plugin uses the well-known node labels/spec to define the disk location
82-
* `topology.kubernetes.io/region` - proxmox cluster name, the name must be the same as in cloud config region name
82+
* `topology.kubernetes.io/region` - the name must be the same as in cloud config region name
8383
* `topology.kubernetes.io/zone` - proxmox node name
8484
* `Spec.ProviderID` - providerID magic string `proxmox://$REGION/$VMID` to help define the virtual machine ID, it cannot be changed after the first update. If it not exists, the plugin will find the VM by the name or UUID.
8585

pkg/csi/controller.go

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -582,8 +582,8 @@ func (d *ControllerService) GetCapacity(_ context.Context, request *csi.GetCapac
582582
zone := topology.GetSegments()[corev1.LabelTopologyZone]
583583
storageID := request.GetParameters()[StorageIDKey]
584584

585-
if region == "" || zone == "" || storageID == "" {
586-
return nil, status.Error(codes.InvalidArgument, "region, zone and storageName must be provided")
585+
if region == "" || storageID == "" {
586+
return nil, status.Error(codes.InvalidArgument, "region and storage must be provided")
587587
}
588588

589589
klog.V(3).InfoS("GetCapacity", "region", region, "zone", zone, "storageID", storageID)
@@ -595,6 +595,13 @@ func (d *ControllerService) GetCapacity(_ context.Context, request *csi.GetCapac
595595
return nil, status.Error(codes.Internal, err.Error())
596596
}
597597

598+
if zone == "" {
599+
zone, err = getNodeWithStorage(cl, storageID)
600+
if err != nil {
601+
return nil, status.Error(codes.Internal, err.Error())
602+
}
603+
}
604+
598605
vmr := pxapi.NewVmRef(vmID)
599606
vmr.SetNode(zone)
600607
vmr.SetVmType("qemu")

pkg/csi/controller_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1111,7 +1111,7 @@ func (ts *configuredTestSuite) TestGetCapacity() {
11111111
request: &proto.GetCapacityRequest{
11121112
AccessibleTopology: &proto.Topology{},
11131113
},
1114-
expectedError: status.Error(codes.InvalidArgument, "region, zone and storageName must be provided"),
1114+
expectedError: status.Error(codes.InvalidArgument, "region and storage must be provided"),
11151115
},
11161116
{
11171117
msg: "TopologyRegion",
@@ -1125,7 +1125,7 @@ func (ts *configuredTestSuite) TestGetCapacity() {
11251125
csi.StorageIDKey: "storage",
11261126
},
11271127
},
1128-
expectedError: status.Error(codes.InvalidArgument, "region, zone and storageName must be provided"),
1128+
expectedError: status.Error(codes.Internal, "proxmox cluster region not found"),
11291129
},
11301130
{
11311131
msg: "TopologyZone",
@@ -1139,7 +1139,7 @@ func (ts *configuredTestSuite) TestGetCapacity() {
11391139
csi.StorageIDKey: "storage",
11401140
},
11411141
},
1142-
expectedError: status.Error(codes.InvalidArgument, "region, zone and storageName must be provided"),
1142+
expectedError: status.Error(codes.InvalidArgument, "region and storage must be provided"),
11431143
},
11441144
{
11451145
msg: "TopologyStorageName",
@@ -1151,7 +1151,7 @@ func (ts *configuredTestSuite) TestGetCapacity() {
11511151
},
11521152
},
11531153
},
1154-
expectedError: status.Error(codes.InvalidArgument, "region, zone and storageName must be provided"),
1154+
expectedError: status.Error(codes.InvalidArgument, "region and storage must be provided"),
11551155
},
11561156
{
11571157
msg: "Topology",

0 commit comments

Comments
 (0)