diff --git a/pkg/volume/csi/BUILD b/pkg/volume/csi/BUILD index 770a422dac..597fd6597a 100644 --- a/pkg/volume/csi/BUILD +++ b/pkg/volume/csi/BUILD @@ -30,7 +30,7 @@ go_library( "//staging/src/k8s.io/csi-api/pkg/client/informers/externalversions:go_default_library", "//staging/src/k8s.io/csi-api/pkg/client/informers/externalversions/csi/v1alpha1:go_default_library", "//staging/src/k8s.io/csi-api/pkg/client/listers/csi/v1alpha1:go_default_library", - "//vendor/github.com/container-storage-interface/spec/lib/go/csi/v0:go_default_library", + "//vendor/github.com/container-storage-interface/spec/lib/go/csi:go_default_library", "//vendor/google.golang.org/grpc:go_default_library", "//vendor/k8s.io/klog:go_default_library", ], @@ -69,7 +69,7 @@ go_test( "//staging/src/k8s.io/client-go/util/testing:go_default_library", "//staging/src/k8s.io/csi-api/pkg/apis/csi/v1alpha1:go_default_library", "//staging/src/k8s.io/csi-api/pkg/client/clientset/versioned/fake:go_default_library", - "//vendor/github.com/container-storage-interface/spec/lib/go/csi/v0:go_default_library", + "//vendor/github.com/container-storage-interface/spec/lib/go/csi:go_default_library", "//vendor/k8s.io/klog:go_default_library", ], ) diff --git a/pkg/volume/csi/csi_attacher.go b/pkg/volume/csi/csi_attacher.go index 4bebf1ff72..a5ca331a8c 100644 --- a/pkg/volume/csi/csi_attacher.go +++ b/pkg/volume/csi/csi_attacher.go @@ -29,7 +29,7 @@ import ( "k8s.io/klog" - csipb "github.com/container-storage-interface/spec/lib/go/csi/v0" + csipb "github.com/container-storage-interface/spec/lib/go/csi" "k8s.io/api/core/v1" storage "k8s.io/api/storage/v1beta1" apierrs "k8s.io/apimachinery/pkg/api/errors" diff --git a/pkg/volume/csi/csi_client.go b/pkg/volume/csi/csi_client.go index d8355ae29b..ea6ba190d8 100644 --- a/pkg/volume/csi/csi_client.go +++ b/pkg/volume/csi/csi_client.go @@ -24,7 +24,7 @@ import ( "net" "time" - csipb "github.com/container-storage-interface/spec/lib/go/csi/v0" + csipb "github.com/container-storage-interface/spec/lib/go/csi" "google.golang.org/grpc" api "k8s.io/api/core/v1" utilfeature "k8s.io/apiserver/pkg/util/feature" @@ -46,8 +46,8 @@ type csiClient interface { targetPath string, accessMode api.PersistentVolumeAccessMode, volumeInfo map[string]string, - volumeAttribs map[string]string, - nodePublishSecrets map[string]string, + volumeContext map[string]string, + secrets map[string]string, fsType string, mountOptions []string, ) error @@ -62,8 +62,8 @@ type csiClient interface { stagingTargetPath string, fsType string, accessMode api.PersistentVolumeAccessMode, - nodeStageSecrets map[string]string, - volumeAttribs map[string]string, + secrets map[string]string, + volumeContext map[string]string, ) error NodeUnstageVolume(ctx context.Context, volID, stagingTargetPath string) error NodeGetCapabilities(ctx context.Context) ([]*csipb.NodeServiceCapability, error) @@ -136,8 +136,8 @@ func (c *csiDriverClient) NodePublishVolume( targetPath string, accessMode api.PersistentVolumeAccessMode, volumeInfo map[string]string, - volumeAttribs map[string]string, - nodePublishSecrets map[string]string, + volumeContext map[string]string, + secrets map[string]string, fsType string, mountOptions []string, ) error { @@ -156,12 +156,12 @@ func (c *csiDriverClient) NodePublishVolume( defer closer.Close() req := &csipb.NodePublishVolumeRequest{ - VolumeId: volID, - TargetPath: targetPath, - Readonly: readOnly, - PublishInfo: volumeInfo, - VolumeAttributes: volumeAttribs, - NodePublishSecrets: nodePublishSecrets, + VolumeId: volID, + TargetPath: targetPath, + Readonly: readOnly, + PublishContext: volumeInfo, + VolumeContext: volumeContext, + Secrets: secrets, VolumeCapability: &csipb.VolumeCapability{ AccessMode: &csipb.VolumeCapability_AccessMode{ Mode: asCSIAccessMode(accessMode), @@ -215,12 +215,12 @@ func (c *csiDriverClient) NodeUnpublishVolume(ctx context.Context, volID string, func (c *csiDriverClient) NodeStageVolume(ctx context.Context, volID string, - publishInfo map[string]string, + publishContext map[string]string, stagingTargetPath string, fsType string, accessMode api.PersistentVolumeAccessMode, - nodeStageSecrets map[string]string, - volumeAttribs map[string]string, + secrets map[string]string, + volumeContext map[string]string, ) error { klog.V(4).Info(log("calling NodeStageVolume rpc [volid=%s,staging_target_path=%s]", volID, stagingTargetPath)) if volID == "" { @@ -238,15 +238,15 @@ func (c *csiDriverClient) NodeStageVolume(ctx context.Context, req := &csipb.NodeStageVolumeRequest{ VolumeId: volID, - PublishInfo: publishInfo, + PublishContext: publishContext, StagingTargetPath: stagingTargetPath, VolumeCapability: &csipb.VolumeCapability{ AccessMode: &csipb.VolumeCapability_AccessMode{ Mode: asCSIAccessMode(accessMode), }, }, - NodeStageSecrets: nodeStageSecrets, - VolumeAttributes: volumeAttribs, + Secrets: secrets, + VolumeContext: volumeContext, } if fsType == fsTypeBlockName { diff --git a/pkg/volume/csi/csi_client_test.go b/pkg/volume/csi/csi_client_test.go index 83ae82de99..777be98b2d 100644 --- a/pkg/volume/csi/csi_client_test.go +++ b/pkg/volume/csi/csi_client_test.go @@ -23,7 +23,7 @@ import ( "reflect" "testing" - csipb "github.com/container-storage-interface/spec/lib/go/csi/v0" + csipb "github.com/container-storage-interface/spec/lib/go/csi" api "k8s.io/api/core/v1" "k8s.io/kubernetes/pkg/volume/csi/fake" ) @@ -57,19 +57,19 @@ func (c *fakeCsiDriverClient) NodePublishVolume( targetPath string, accessMode api.PersistentVolumeAccessMode, volumeInfo map[string]string, - volumeAttribs map[string]string, - nodePublishSecrets map[string]string, + volumeContext map[string]string, + secrets map[string]string, fsType string, mountOptions []string, ) error { c.t.Log("calling fake.NodePublishVolume...") req := &csipb.NodePublishVolumeRequest{ - VolumeId: volID, - TargetPath: targetPath, - Readonly: readOnly, - PublishInfo: volumeInfo, - VolumeAttributes: volumeAttribs, - NodePublishSecrets: nodePublishSecrets, + VolumeId: volID, + TargetPath: targetPath, + Readonly: readOnly, + PublishContext: volumeInfo, + VolumeContext: volumeContext, + Secrets: secrets, VolumeCapability: &csipb.VolumeCapability{ AccessMode: &csipb.VolumeCapability_AccessMode{ Mode: asCSIAccessMode(accessMode), @@ -100,17 +100,17 @@ func (c *fakeCsiDriverClient) NodeUnpublishVolume(ctx context.Context, volID str func (c *fakeCsiDriverClient) NodeStageVolume(ctx context.Context, volID string, - publishInfo map[string]string, + publishContext map[string]string, stagingTargetPath string, fsType string, accessMode api.PersistentVolumeAccessMode, - nodeStageSecrets map[string]string, - volumeAttribs map[string]string, + secrets map[string]string, + volumeContext map[string]string, ) error { c.t.Log("calling fake.NodeStageVolume...") req := &csipb.NodeStageVolumeRequest{ VolumeId: volID, - PublishInfo: publishInfo, + PublishContext: publishContext, StagingTargetPath: stagingTargetPath, VolumeCapability: &csipb.VolumeCapability{ AccessMode: &csipb.VolumeCapability_AccessMode{ @@ -122,8 +122,8 @@ func (c *fakeCsiDriverClient) NodeStageVolume(ctx context.Context, }, }, }, - NodeStageSecrets: nodeStageSecrets, - VolumeAttributes: volumeAttribs, + Secrets: secrets, + VolumeContext: volumeContext, } _, err := c.nodeClient.NodeStageVolume(ctx, req) @@ -321,7 +321,7 @@ func TestClientNodeStageVolume(t *testing.T) { volID string stagingTargetPath string fsType string - secret map[string]string + secrets map[string]string mustFail bool err error }{ @@ -351,7 +351,7 @@ func TestClientNodeStageVolume(t *testing.T) { tc.stagingTargetPath, tc.fsType, api.ReadWriteOnce, - tc.secret, + tc.secrets, map[string]string{"attr0": "val0"}, ) checkErr(t, tc.mustFail, err) diff --git a/pkg/volume/csi/csi_mounter_test.go b/pkg/volume/csi/csi_mounter_test.go index 2b56a49332..1e86a21099 100644 --- a/pkg/volume/csi/csi_mounter_test.go +++ b/pkg/volume/csi/csi_mounter_test.go @@ -98,47 +98,46 @@ func TestMounterGetPath(t *testing.T) { func MounterSetUpTests(t *testing.T, podInfoEnabled bool) { defer utilfeaturetesting.SetFeatureGateDuringTest(t, utilfeature.DefaultFeatureGate, features.CSIDriverRegistry, podInfoEnabled)() tests := []struct { - name string - driver string - attributes map[string]string - - expectedAttributes map[string]string + name string + driver string + volumeContext map[string]string + expectedVolumeContext map[string]string }{ { - name: "no pod info", - driver: "no-info", - attributes: nil, - expectedAttributes: nil, + name: "no pod info", + driver: "no-info", + volumeContext: nil, + expectedVolumeContext: nil, }, { - name: "no CSIDriver -> no pod info", - driver: "unknown-driver", - attributes: nil, - expectedAttributes: nil, + name: "no CSIDriver -> no pod info", + driver: "unknown-driver", + volumeContext: nil, + expectedVolumeContext: nil, }, { - name: "CSIDriver with PodInfoRequiredOnMount=nil -> no pod info", - driver: "nil", - attributes: nil, - expectedAttributes: nil, + name: "CSIDriver with PodInfoRequiredOnMount=nil -> no pod info", + driver: "nil", + volumeContext: nil, + expectedVolumeContext: nil, }, { - name: "no pod info -> keep existing attributes", - driver: "no-info", - attributes: map[string]string{"foo": "bar"}, - expectedAttributes: map[string]string{"foo": "bar"}, + name: "no pod info -> keep existing volumeContext", + driver: "no-info", + volumeContext: map[string]string{"foo": "bar"}, + expectedVolumeContext: map[string]string{"foo": "bar"}, }, { - name: "add pod info", - driver: "info", - attributes: nil, - expectedAttributes: map[string]string{"csi.storage.k8s.io/pod.uid": "test-pod", "csi.storage.k8s.io/serviceAccount.name": "test-service-account", "csi.storage.k8s.io/pod.name": "test-pod", "csi.storage.k8s.io/pod.namespace": "test-ns"}, + name: "add pod info", + driver: "info", + volumeContext: nil, + expectedVolumeContext: map[string]string{"csi.storage.k8s.io/pod.uid": "test-pod", "csi.storage.k8s.io/serviceAccount.name": "test-service-account", "csi.storage.k8s.io/pod.name": "test-pod", "csi.storage.k8s.io/pod.namespace": "test-ns"}, }, { - name: "add pod info -> keep existing attributes", - driver: "info", - attributes: map[string]string{"foo": "bar"}, - expectedAttributes: map[string]string{"foo": "bar", "csi.storage.k8s.io/pod.uid": "test-pod", "csi.storage.k8s.io/serviceAccount.name": "test-service-account", "csi.storage.k8s.io/pod.name": "test-pod", "csi.storage.k8s.io/pod.namespace": "test-ns"}, + name: "add pod info -> keep existing volumeContext", + driver: "info", + volumeContext: map[string]string{"foo": "bar"}, + expectedVolumeContext: map[string]string{"foo": "bar", "csi.storage.k8s.io/pod.uid": "test-pod", "csi.storage.k8s.io/serviceAccount.name": "test-service-account", "csi.storage.k8s.io/pod.name": "test-pod", "csi.storage.k8s.io/pod.namespace": "test-ns"}, }, } @@ -163,7 +162,7 @@ func MounterSetUpTests(t *testing.T, podInfoEnabled bool) { } pv := makeTestPV("test-pv", 10, test.driver, testVol) - pv.Spec.CSI.VolumeAttributes = test.attributes + pv.Spec.CSI.VolumeAttributes = test.volumeContext pv.Spec.MountOptions = []string{"foo=bar", "baz=qux"} pvName := pv.GetName() @@ -245,13 +244,13 @@ func MounterSetUpTests(t *testing.T, podInfoEnabled bool) { t.Errorf("csi server expected mount options %v, got %v", pv.Spec.MountOptions, vol.MountFlags) } if podInfoEnabled { - if !reflect.DeepEqual(vol.Attributes, test.expectedAttributes) { - t.Errorf("csi server expected attributes %+v, got %+v", test.expectedAttributes, vol.Attributes) + if !reflect.DeepEqual(vol.VolumeContext, test.expectedVolumeContext) { + t.Errorf("csi server expected volumeContext %+v, got %+v", test.expectedVolumeContext, vol.VolumeContext) } } else { - // CSIPodInfo feature is disabled, we expect no modifications to attributes. - if !reflect.DeepEqual(vol.Attributes, test.attributes) { - t.Errorf("csi server expected attributes %+v, got %+v", test.attributes, vol.Attributes) + // CSIPodInfo feature is disabled, we expect no modifications to volumeContext. + if !reflect.DeepEqual(vol.VolumeContext, test.volumeContext) { + t.Errorf("csi server expected volumeContext %+v, got %+v", test.volumeContext, vol.VolumeContext) } } }) diff --git a/pkg/volume/csi/fake/BUILD b/pkg/volume/csi/fake/BUILD index 679150a5b5..c2c6b44d4f 100644 --- a/pkg/volume/csi/fake/BUILD +++ b/pkg/volume/csi/fake/BUILD @@ -9,7 +9,7 @@ go_library( importpath = "k8s.io/kubernetes/pkg/volume/csi/fake", visibility = ["//visibility:public"], deps = [ - "//vendor/github.com/container-storage-interface/spec/lib/go/csi/v0:go_default_library", + "//vendor/github.com/container-storage-interface/spec/lib/go/csi:go_default_library", "//vendor/google.golang.org/grpc:go_default_library", ], ) diff --git a/pkg/volume/csi/fake/fake_client.go b/pkg/volume/csi/fake/fake_client.go index 775ff7ddfb..c9ed5e6b9a 100644 --- a/pkg/volume/csi/fake/fake_client.go +++ b/pkg/volume/csi/fake/fake_client.go @@ -23,7 +23,7 @@ import ( "google.golang.org/grpc" - csipb "github.com/container-storage-interface/spec/lib/go/csi/v0" + csipb "github.com/container-storage-interface/spec/lib/go/csi" ) // IdentityClient is a CSI identity client used for testing @@ -57,9 +57,9 @@ func (f *IdentityClient) Probe(ctx context.Context, in *csipb.ProbeRequest, opts } type CSIVolume struct { - Attributes map[string]string - Path string - MountFlags []string + VolumeContext map[string]string + Path string + MountFlags []string } // NodeClient returns CSI node client @@ -99,10 +99,10 @@ func (f *NodeClient) GetNodeStagedVolumes() map[string]CSIVolume { return f.nodeStagedVolumes } -func (f *NodeClient) AddNodeStagedVolume(volID, deviceMountPath string, attributes map[string]string) { +func (f *NodeClient) AddNodeStagedVolume(volID, deviceMountPath string, volumeContext map[string]string) { f.nodeStagedVolumes[volID] = CSIVolume{ - Path: deviceMountPath, - Attributes: attributes, + Path: deviceMountPath, + VolumeContext: volumeContext, } } @@ -125,9 +125,9 @@ func (f *NodeClient) NodePublishVolume(ctx context.Context, req *csipb.NodePubli return nil, errors.New("invalid fstype") } f.nodePublishedVolumes[req.GetVolumeId()] = CSIVolume{ - Path: req.GetTargetPath(), - Attributes: req.GetVolumeAttributes(), - MountFlags: req.GetVolumeCapability().GetMount().MountFlags, + Path: req.GetTargetPath(), + VolumeContext: req.GetVolumeContext(), + MountFlags: req.GetVolumeCapability().GetMount().MountFlags, } return &csipb.NodePublishVolumeResponse{}, nil } @@ -172,8 +172,8 @@ func (f *NodeClient) NodeStageVolume(ctx context.Context, req *csipb.NodeStageVo } f.nodeStagedVolumes[req.GetVolumeId()] = CSIVolume{ - Path: req.GetStagingTargetPath(), - Attributes: req.GetVolumeAttributes(), + Path: req.GetStagingTargetPath(), + VolumeContext: req.GetVolumeContext(), } return &csipb.NodeStageVolumeResponse{}, nil } @@ -195,11 +195,6 @@ func (f *NodeClient) NodeUnstageVolume(ctx context.Context, req *csipb.NodeUnsta return &csipb.NodeUnstageVolumeResponse{}, nil } -// NodeGetId implements method -func (f *NodeClient) NodeGetId(ctx context.Context, in *csipb.NodeGetIdRequest, opts ...grpc.CallOption) (*csipb.NodeGetIdResponse, error) { - return nil, nil -} - // NodeGetId implements csi method func (f *NodeClient) NodeGetInfo(ctx context.Context, in *csipb.NodeGetInfoRequest, opts ...grpc.CallOption) (*csipb.NodeGetInfoResponse, error) { if f.nextErr != nil { @@ -227,6 +222,11 @@ func (f *NodeClient) NodeGetCapabilities(ctx context.Context, in *csipb.NodeGetC return nil, nil } +// NodeGetVolumeStats implements csi method +func (f *NodeClient) NodeGetVolumeStats(ctx context.Context, in *csipb.NodeGetVolumeStatsRequest, opts ...grpc.CallOption) (*csipb.NodeGetVolumeStatsResponse, error) { + return nil, nil +} + // ControllerClient represents a CSI Controller client type ControllerClient struct { nextCapabilities []*csipb.ControllerServiceCapability diff --git a/pkg/volume/csi/nodeinfomanager/BUILD b/pkg/volume/csi/nodeinfomanager/BUILD index 74543354b6..2b95c9d474 100644 --- a/pkg/volume/csi/nodeinfomanager/BUILD +++ b/pkg/volume/csi/nodeinfomanager/BUILD @@ -19,7 +19,7 @@ go_library( "//staging/src/k8s.io/apiserver/pkg/util/feature:go_default_library", "//staging/src/k8s.io/client-go/util/retry:go_default_library", "//staging/src/k8s.io/csi-api/pkg/apis/csi/v1alpha1:go_default_library", - "//vendor/github.com/container-storage-interface/spec/lib/go/csi/v0:go_default_library", + "//vendor/github.com/container-storage-interface/spec/lib/go/csi:go_default_library", "//vendor/k8s.io/klog:go_default_library", ], ) @@ -61,7 +61,7 @@ go_test( "//staging/src/k8s.io/client-go/util/testing:go_default_library", "//staging/src/k8s.io/csi-api/pkg/apis/csi/v1alpha1:go_default_library", "//staging/src/k8s.io/csi-api/pkg/client/clientset/versioned/fake:go_default_library", - "//vendor/github.com/container-storage-interface/spec/lib/go/csi/v0:go_default_library", + "//vendor/github.com/container-storage-interface/spec/lib/go/csi:go_default_library", "//vendor/github.com/stretchr/testify/assert:go_default_library", ], ) diff --git a/pkg/volume/csi/nodeinfomanager/nodeinfomanager.go b/pkg/volume/csi/nodeinfomanager/nodeinfomanager.go index 4f783821d2..14b2077815 100644 --- a/pkg/volume/csi/nodeinfomanager/nodeinfomanager.go +++ b/pkg/volume/csi/nodeinfomanager/nodeinfomanager.go @@ -23,7 +23,7 @@ import ( "fmt" "strings" - csipb "github.com/container-storage-interface/spec/lib/go/csi/v0" + csipb "github.com/container-storage-interface/spec/lib/go/csi" "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/api/resource" diff --git a/pkg/volume/csi/nodeinfomanager/nodeinfomanager_test.go b/pkg/volume/csi/nodeinfomanager/nodeinfomanager_test.go index 468fedcc91..39ee2fd0cd 100644 --- a/pkg/volume/csi/nodeinfomanager/nodeinfomanager_test.go +++ b/pkg/volume/csi/nodeinfomanager/nodeinfomanager_test.go @@ -21,7 +21,7 @@ import ( "fmt" "testing" - "github.com/container-storage-interface/spec/lib/go/csi/v0" + "github.com/container-storage-interface/spec/lib/go/csi" "github.com/stretchr/testify/assert" "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/api/resource"