Skip to content

Commit d18dba1

Browse files
authored
Merge pull request #607 from jingxu97/sep/vendor
Update to use csi proxy beta
2 parents a259069 + 7f54cdd commit d18dba1

File tree

211 files changed

+47986
-21030
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

211 files changed

+47986
-21030
lines changed

deploy/kubernetes/base/node_windows/node.yaml

+4-4
Original file line numberDiff line numberDiff line change
@@ -53,19 +53,19 @@ spec:
5353
- name: plugin-dir
5454
mountPath: C:\csi
5555
- name: csi-proxy-disk-pipe
56-
mountPath: \\.\pipe\csi-proxy-disk-v1alpha1
56+
mountPath: \\.\pipe\csi-proxy-disk-v1beta1
5757
- name: csi-proxy-volume-pipe
58-
mountPath: \\.\pipe\csi-proxy-volume-v1alpha1
58+
mountPath: \\.\pipe\csi-proxy-volume-v1beta1
5959
- name: csi-proxy-filesystem-pipe
6060
mountPath: \\.\pipe\csi-proxy-filesystem-v1alpha1
6161
volumes:
6262
- name: csi-proxy-disk-pipe
6363
hostPath:
64-
path: \\.\pipe\csi-proxy-disk-v1alpha1
64+
path: \\.\pipe\csi-proxy-disk-v1beta1
6565
type: ""
6666
- name: csi-proxy-volume-pipe
6767
hostPath:
68-
path: \\.\pipe\csi-proxy-volume-v1alpha1
68+
path: \\.\pipe\csi-proxy-volume-v1beta1
6969
type: ""
7070
- name: csi-proxy-filesystem-pipe
7171
hostPath:

deploy/kubernetes/base/node_windows/psp.yaml

+2-2
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ spec:
1818
- pathPrefix: \var\lib\kubelet
1919
- pathPrefix: \var\lib\kubelet\plugins_registry
2020
- pathPrefix: \var\lib\kubelet\plugins\pd.csi.storage.gke.io
21-
- pathPrefix: \\.\pipe\csi-proxy-disk-v1alpha1
22-
- pathPrefix: \\.\pipe\csi-proxy-volume-v1alpha1
21+
- pathPrefix: \\.\pipe\csi-proxy-disk-v1beta1
22+
- pathPrefix: \\.\pipe\csi-proxy-volume-v1beta1
2323
- pathPrefix: \\.\pipe\csi-proxy-filesystem-v1alpha1
2424

go.mod

+3-4
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,17 @@ require (
66
cloud.google.com/go v0.45.1
77
github.com/GoogleCloudPlatform/k8s-cloud-provider v0.0.0-20190822182118-27a4ced34534
88
github.com/container-storage-interface/spec v1.2.0
9-
github.com/golang/protobuf v1.3.4
9+
github.com/golang/protobuf v1.4.1
1010
github.com/google/uuid v1.1.1
1111
github.com/hashicorp/go-multierror v1.0.0 // indirect
12-
github.com/kubernetes-csi/csi-proxy/client v0.0.0-20200330215040-9eff16441b2a
12+
github.com/kubernetes-csi/csi-proxy/client v0.2.0
1313
github.com/kubernetes-csi/csi-test/v3 v3.0.0
1414
github.com/onsi/ginkgo v1.11.0
1515
github.com/onsi/gomega v1.7.1
1616
golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45
1717
golang.org/x/sys v0.0.0-20191113165036-4c7a9d0fe056
18-
golang.org/x/tools/gopls v0.3.3 // indirect
1918
google.golang.org/api v0.10.0
20-
google.golang.org/genproto v0.0.0-20191114150713-6bbd007550de
19+
google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013
2120
google.golang.org/grpc v1.27.1
2221
gopkg.in/gcfg.v1 v1.2.3
2322
gopkg.in/warnings.v0 v0.1.2 // indirect

go.sum

+25-152
Large diffs are not rendered by default.

pkg/mount-manager/safe-mounter_windows.go

+44-29
Original file line numberDiff line numberDiff line change
@@ -22,38 +22,40 @@ import (
2222
"fmt"
2323
"os"
2424
"path/filepath"
25+
"strings"
2526

26-
diskv1alpha1 "github.com/kubernetes-csi/csi-proxy/client/api/disk/v1alpha1"
27-
diskclientv1alpha1 "github.com/kubernetes-csi/csi-proxy/client/groups/disk/v1alpha1"
27+
diskapi "github.com/kubernetes-csi/csi-proxy/client/api/disk/v1beta1"
28+
diskclient "github.com/kubernetes-csi/csi-proxy/client/groups/disk/v1beta1"
2829

29-
fsv1alpha1 "github.com/kubernetes-csi/csi-proxy/client/api/filesystem/v1alpha1"
30-
fsclientv1alpha1 "github.com/kubernetes-csi/csi-proxy/client/groups/filesystem/v1alpha1"
30+
fsapi "github.com/kubernetes-csi/csi-proxy/client/api/filesystem/v1alpha1"
31+
fsclient "github.com/kubernetes-csi/csi-proxy/client/groups/filesystem/v1alpha1"
3132

32-
volumev1alpha1 "github.com/kubernetes-csi/csi-proxy/client/api/volume/v1alpha1"
33-
volumeclientv1alpha1 "github.com/kubernetes-csi/csi-proxy/client/groups/volume/v1alpha1"
33+
volumeapi "github.com/kubernetes-csi/csi-proxy/client/api/volume/v1beta1"
34+
volumeclient "github.com/kubernetes-csi/csi-proxy/client/groups/volume/v1beta1"
3435

36+
"k8s.io/klog"
3537
utilexec "k8s.io/utils/exec"
3638
"k8s.io/utils/mount"
3739
)
3840

3941
var _ mount.Interface = &CSIProxyMounter{}
4042

4143
type CSIProxyMounter struct {
42-
FsClient *fsclientv1alpha1.Client
43-
DiskClient *diskclientv1alpha1.Client
44-
VolumeClient *volumeclientv1alpha1.Client
44+
FsClient *fsclient.Client
45+
DiskClient *diskclient.Client
46+
VolumeClient *volumeclient.Client
4547
}
4648

4749
func NewCSIProxyMounter() (*CSIProxyMounter, error) {
48-
fsClient, err := fsclientv1alpha1.NewClient()
50+
fsClient, err := fsclient.NewClient()
4951
if err != nil {
5052
return nil, err
5153
}
52-
diskClient, err := diskclientv1alpha1.NewClient()
54+
diskClient, err := diskclient.NewClient()
5355
if err != nil {
5456
return nil, err
5557
}
56-
volumeClient, err := volumeclientv1alpha1.NewClient()
58+
volumeClient, err := volumeclient.NewClient()
5759
if err != nil {
5860
return nil, err
5961
}
@@ -93,7 +95,7 @@ func (mounter *CSIProxyMounter) MountSensitive(source string, target string, fst
9395
if err := os.MkdirAll(parentDir, 0755); err != nil {
9496
return err
9597
}
96-
linkRequest := &fsv1alpha1.LinkPathRequest{
98+
linkRequest := &fsapi.LinkPathRequest{
9799
SourcePath: mount.NormalizeWindowsPath(source),
98100
TargetPath: mount.NormalizeWindowsPath(target),
99101
}
@@ -110,9 +112,9 @@ func (mounter *CSIProxyMounter) MountSensitive(source string, target string, fst
110112
// Delete the given directory with Pod context. CSI proxy does a check for path prefix
111113
// based on context
112114
func (mounter *CSIProxyMounter) RemovePodDir(target string) error {
113-
rmdirRequest := &fsv1alpha1.RmdirRequest{
115+
rmdirRequest := &fsapi.RmdirRequest{
114116
Path: mount.NormalizeWindowsPath(target),
115-
Context: fsv1alpha1.PathContext_POD,
117+
Context: fsapi.PathContext_POD,
116118
Force: true,
117119
}
118120
_, err := mounter.FsClient.Rmdir(context.Background(), rmdirRequest)
@@ -125,9 +127,9 @@ func (mounter *CSIProxyMounter) RemovePodDir(target string) error {
125127
// Delete the given directory with plugin context. CSI proxy does a check for path prefix
126128
// based on context
127129
func (mounter *CSIProxyMounter) RemovePluginDir(target string) error {
128-
rmdirRequest := &fsv1alpha1.RmdirRequest{
130+
rmdirRequest := &fsapi.RmdirRequest{
129131
Path: mount.NormalizeWindowsPath(target),
130-
Context: fsv1alpha1.PathContext_PLUGIN,
132+
Context: fsapi.PathContext_PLUGIN,
131133
Force: true,
132134
}
133135
_, err := mounter.FsClient.Rmdir(context.Background(), rmdirRequest)
@@ -142,30 +144,43 @@ func (mounter *CSIProxyMounter) Unmount(target string) error {
142144
}
143145

144146
func (mounter *CSIProxyMounter) GetDevicePath(deviceName string, partition string, volumeKey string) (string, error) {
145-
getDiskNumberRequest := &diskv1alpha1.GetDiskNumberByNameRequest{
146-
DiskName: deviceName,
147-
}
148-
getDiskNumberResponse, err := mounter.DiskClient.GetDiskNumberByName(context.Background(), getDiskNumberRequest)
147+
id := "page83"
148+
listRequest := &diskapi.ListDiskIDsRequest{}
149+
diskIDsResponse, err := mounter.DiskClient.ListDiskIDs(context.Background(), listRequest)
149150
if err != nil {
150151
return "", err
151152
}
152-
return getDiskNumberResponse.DiskNumber, nil
153+
diskIDsMap := diskIDsResponse.GetDiskIDs()
154+
for diskNum, diskInfo := range diskIDsMap {
155+
klog.V(4).Infof("found disk number %s, disk info %v", diskNum, diskInfo)
156+
idValue, found := diskInfo.Identifiers[id]
157+
// The page83 id for gce pd has format of "Google pvc-xxxxxxx(the device name passed in here)"
158+
if !found || idValue == "" {
159+
continue
160+
}
161+
names := strings.Fields(idValue)
162+
klog.V(4).Infof("get page83 id %s", idValue)
163+
if names[len(names)-1] == deviceName {
164+
return diskNum, nil
165+
}
166+
}
167+
return "", fmt.Errorf("could not find disk number for device %s", deviceName)
153168

154169
}
155170

156171
// FormatAndMount accepts the source disk number, target path to mount, the fstype to format with and options to be used.
157172
// After formatting, it will mount the disk to target path on the host
158173
func (mounter *CSIProxyMounter) FormatAndMount(source string, target string, fstype string, options []string) error {
159174
// Call PartitionDisk CSI proxy call to partition the disk and return the volume id
160-
partionDiskRequest := &diskv1alpha1.PartitionDiskRequest{
175+
partionDiskRequest := &diskapi.PartitionDiskRequest{
161176
DiskID: source,
162177
}
163178

164179
_, err := mounter.DiskClient.PartitionDisk(context.Background(), partionDiskRequest)
165180
if err != nil {
166181
return err
167182
}
168-
volumeIDsRequest := &volumev1alpha1.ListVolumesOnDiskRequest{
183+
volumeIDsRequest := &volumeapi.ListVolumesOnDiskRequest{
169184
DiskId: source,
170185
}
171186
volumeIdResponse, err := mounter.VolumeClient.ListVolumesOnDisk(context.Background(), volumeIDsRequest)
@@ -174,15 +189,15 @@ func (mounter *CSIProxyMounter) FormatAndMount(source string, target string, fst
174189
}
175190
// TODO: consider partitions and choose the right partition.
176191
volumeID := volumeIdResponse.VolumeIds[0]
177-
isVolumeFormattedRequest := &volumev1alpha1.IsVolumeFormattedRequest{
192+
isVolumeFormattedRequest := &volumeapi.IsVolumeFormattedRequest{
178193
VolumeId: volumeID,
179194
}
180195
isVolumeFormattedResponse, err := mounter.VolumeClient.IsVolumeFormatted(context.Background(), isVolumeFormattedRequest)
181196
if err != nil {
182197
return err
183198
}
184199
if !isVolumeFormattedResponse.Formatted {
185-
formatVolumeRequest := &volumev1alpha1.FormatVolumeRequest{
200+
formatVolumeRequest := &volumeapi.FormatVolumeRequest{
186201
VolumeId: volumeID,
187202
// TODO (jingxu97): Accept the filesystem and other options
188203
}
@@ -192,7 +207,7 @@ func (mounter *CSIProxyMounter) FormatAndMount(source string, target string, fst
192207
}
193208
}
194209
// Mount the volume by calling the CSI proxy call.
195-
mountVolumeRequest := &volumev1alpha1.MountVolumeRequest{
210+
mountVolumeRequest := &volumeapi.MountVolumeRequest{
196211
VolumeId: volumeID,
197212
Path: target,
198213
}
@@ -208,7 +223,7 @@ func (mounter *CSIProxyMounter) GetMountRefs(pathname string) ([]string, error)
208223
}
209224

210225
func (mounter *CSIProxyMounter) IsLikelyNotMountPoint(file string) (bool, error) {
211-
isMountRequest := &fsv1alpha1.IsMountPointRequest{
226+
isMountRequest := &fsapi.IsMountPointRequest{
212227
Path: file,
213228
}
214229

@@ -231,7 +246,7 @@ func (mounter *CSIProxyMounter) IsMountPointMatch(mp mount.MountPoint, dir strin
231246
// ExistsPath - Checks if a path exists. Unlike util ExistsPath, this call does not perform follow link.
232247
func (mounter *CSIProxyMounter) ExistsPath(path string) (bool, error) {
233248
isExistsResponse, err := mounter.FsClient.PathExists(context.Background(),
234-
&fsv1alpha1.PathExistsRequest{
249+
&fsapi.PathExistsRequest{
235250
Path: mount.NormalizeWindowsPath(path),
236251
})
237252
return isExistsResponse.Exists, err

0 commit comments

Comments
 (0)