-
Notifications
You must be signed in to change notification settings - Fork 617
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[csi-plugins] add support for PVC annotations #2687
Conversation
Skipping CI for Draft Pull Request. |
0688187
to
e325a5e
Compare
5b89207
to
41d0b46
Compare
694a897
to
daf4c35
Compare
I just discovered that
According to go, the passed So I had to push this: diff --git a/pkg/csi/cinder/controllerserver.go b/pkg/csi/cinder/controllerserver.go
index a96b817a..dd630ba8 100644
--- a/pkg/csi/cinder/controllerserver.go
+++ b/pkg/csi/cinder/controllerserver.go
@@ -198,7 +198,7 @@ func (cs *controllerServer) CreateVolume(ctx context.Context, req *csi.CreateVol
}
// Set scheduler hints if affinity or anti-affinity is set in PVC annotations
- var schedulerHints *volumes.SchedulerHintOpts
+ var schedulerHints volumes.SchedulerHintOptsBuilder
var volCtx map[string]string
affinity := util.SplitTrimJoin(pvcAnnotations[affinityKey], ',')
antiAffinity := util.SplitTrimJoin(pvcAnnotations[antiAffinityKey], ',')
diff --git a/pkg/csi/cinder/openstack/openstack.go b/pkg/csi/cinder/openstack/openstack.go
index cc733690..46116ecb 100644
--- a/pkg/csi/cinder/openstack/openstack.go
+++ b/pkg/csi/cinder/openstack/openstack.go
@@ -45,7 +45,7 @@ func AddExtraFlags(fs *pflag.FlagSet) {
}
type IOpenStack interface {
- CreateVolume(*volumes.CreateOpts, *volumes.SchedulerHintOpts) (*volumes.Volume, error)
+ CreateVolume(*volumes.CreateOpts, volumes.SchedulerHintOptsBuilder) (*volumes.Volume, error)
DeleteVolume(volumeID string) error
AttachVolume(instanceID, volumeID string) (string, error)
ListVolumes(limit int, startingToken string) ([]volumes.Volume, string, error)
diff --git a/pkg/csi/cinder/openstack/openstack_mock.go b/pkg/csi/cinder/openstack/openstack_mock.go
index b35d923c..89f0d3dc 100644
--- a/pkg/csi/cinder/openstack/openstack_mock.go
+++ b/pkg/csi/cinder/openstack/openstack_mock.go
@@ -85,7 +85,7 @@ func (_m *OpenStackMock) AttachVolume(instanceID string, volumeID string) (strin
}
// CreateVolume provides a mock function with given fields: name, size, vtype, availability, tags
-func (_m *OpenStackMock) CreateVolume(opts *volumes.CreateOpts, _ *volumes.SchedulerHintOpts) (*volumes.Volume, error) {
+func (_m *OpenStackMock) CreateVolume(opts *volumes.CreateOpts, _ volumes.SchedulerHintOptsBuilder) (*volumes.Volume, error) {
name := opts.Name
size := opts.Size
vtype := opts.VolumeType
diff --git a/pkg/csi/cinder/openstack/openstack_volumes.go b/pkg/csi/cinder/openstack/openstack_volumes.go
index f7f6be95..b3d90230 100644
--- a/pkg/csi/cinder/openstack/openstack_volumes.go
+++ b/pkg/csi/cinder/openstack/openstack_volumes.go
@@ -51,7 +51,7 @@ const (
var volumeErrorStates = [...]string{"error", "error_extending", "error_deleting"}
// CreateVolume creates a volume of given size
-func (os *OpenStack) CreateVolume(opts *volumes.CreateOpts, schedulerHints *volumes.SchedulerHintOpts) (*volumes.Volume, error) {
+func (os *OpenStack) CreateVolume(opts *volumes.CreateOpts, schedulerHints volumes.SchedulerHintOptsBuilder) (*volumes.Volume, error) {
blockstorageClient, err := openstack.NewBlockStorageV3(os.blockstorage.ProviderClient, os.epOpts)
if err != nil {
return nil, err
diff --git a/tests/sanity/cinder/fakecloud.go b/tests/sanity/cinder/fakecloud.go
index a02a8e77..56ee04ad 100644
--- a/tests/sanity/cinder/fakecloud.go
+++ b/tests/sanity/cinder/fakecloud.go
@@ -34,7 +34,7 @@ func getfakecloud() *cloud {
var _ openstack.IOpenStack = &cloud{}
// Fake Cloud
-func (cloud *cloud) CreateVolume(opts *volumes.CreateOpts, _ *volumes.SchedulerHintOpts) (*volumes.Volume, error) {
+func (cloud *cloud) CreateVolume(opts *volumes.CreateOpts, _ volumes.SchedulerHintOptsBuilder) (*volumes.Volume, error) {
vol := &volumes.Volume{
ID: randString(10),
Name: opts.Name, to fix the:
|
b175db6
to
8a1c265
Compare
8a1c265
to
4600776
Compare
@freeformz @gnufied @ncdc @dulek @jichenjc |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do I correctly understand that this requires knowing the volume or share ID upfront before creating a PVC? This is totally not a K8s pattern, as to e.g. deploy three volumes with anti-affinity you need to create one, wait for ID to be populated, create second, wait for its ID and only then create the third, right?
I can see that for Manila you can specify share names too? When looking at the filters code I don't exactly see that support, but nevertheless:
With scheduler hints, you can optionally specify the affinity and anti-affinity rules in relation to other shares. The scheduler will enforce these rules when determining where to create the share. Possible keys are same_host and different_host, and the value must be the share name or id.
Source: https://docs.openstack.org/manila/latest/user/create-and-manage-shares.html#create-a-share
Does this work? Name's easier to use, so I think it would be great to implement and document support for that (by implement I mean - do we need to do some names manipulations to map K8s objects to Manila shares? If so users should specify annotations using K8s names).
<dt>--pvc-annotations <disabled></dt> | ||
<dd> | ||
If set to true then the CSI driver will use PVC annotations to provide volume | ||
sceduler hints. See [Supported PVC Annotations](#supported-pvc-annotations) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
scheduler
Right. Unfortunately I don't see any other way to distribute shares across multiple backends. There will be a feature, based on the share group id, but I suppose it will be implemented mid next year, that's why I introduced a group ID support in advance.
Interesting finding, but it doesn't work with API. I tested this locally and got: |
Alright, so we get what we can here. /lgtm |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: dulek The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
4600776
to
9185d4e
Compare
@dulek I decided to add name resolving. |
ddb1c1a
to
cc55d15
Compare
@dulek waiting for a second lgtm |
/lgtm |
/unhold |
cc55d15
to
f9b5c9b
Compare
/lgtm |
/test openstack-cloud-csi-cinder-e2e-test |
/test openstack-cloud-csi-manila-e2e-test |
What this PR does / why we need it:
This PR adds an ability to use PVC annotations to create persistent volumes with extra options.
For manila-csi-plugin a new
groupID
option is added allowing the share to be created in a specific group.Which issue this PR fixes(if applicable):
fixes #2685
Special notes for reviewers:
This is a fraft, since it's depends on:
Release note: