Skip to content

Commit cee93c2

Browse files
authored
Merge pull request #454 from davidz627/fix/newMounter
Break k/k dependency by migrating util/mount and copying resizefs. Re-enable sanity testing. Fix deps.
2 parents b288d0a + 5b61a25 commit cee93c2

File tree

14 files changed

+563
-318
lines changed

14 files changed

+563
-318
lines changed

go.mod

+18-34
Original file line numberDiff line numberDiff line change
@@ -3,52 +3,36 @@ module sigs.k8s.io/gcp-compute-persistent-disk-csi-driver
33
go 1.13
44

55
require (
6-
cloud.google.com/go v0.40.0
6+
cloud.google.com/go v0.45.1
77
github.com/GoogleCloudPlatform/k8s-cloud-provider v0.0.0-20190612171043-2e19bb35a278
8+
github.com/apache/thrift v0.12.0 // indirect
9+
github.com/bazelbuild/bazel-gazelle v0.0.0-20190402225339-e530fae7ce5c // indirect
810
github.com/container-storage-interface/spec v1.2.0
11+
github.com/deckarep/golang-set v0.0.0-20171013212420-1d4478f51bed // indirect
12+
github.com/go-logfmt/logfmt v0.4.0 // indirect
13+
github.com/gobuffalo/envy v1.6.15 // indirect
914
github.com/golang/protobuf v1.3.2
1015
github.com/google/uuid v1.1.1
1116
github.com/hashicorp/go-multierror v1.0.0 // indirect
17+
github.com/knative/build v0.3.1-0.20190330033454-38ace00371c7 // indirect
18+
github.com/knative/pkg v0.0.0-20190330034653-916205998db9 // indirect
1219
github.com/kubernetes-csi/csi-test/v3 v3.0.0
20+
github.com/markbates/inflect v1.0.4 // indirect
1321
github.com/onsi/ginkgo v1.10.3
1422
github.com/onsi/gomega v1.7.1
15-
go.opencensus.io v0.22.0 // indirect
23+
github.com/openzipkin/zipkin-go v0.1.6 // indirect
24+
github.com/prometheus/tsdb v0.7.1 // indirect
1625
golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45
1726
golang.org/x/sys v0.0.0-20191113165036-4c7a9d0fe056
18-
golang.org/x/time v0.0.0-20190308202827-9d24e82272b4 // indirect
19-
google.golang.org/api v0.6.1-0.20190620001050-890e5eb51fe2
20-
google.golang.org/appengine v1.6.1 // indirect
27+
google.golang.org/api v0.10.0
2128
google.golang.org/genproto v0.0.0-20191114150713-6bbd007550de
2229
google.golang.org/grpc v1.25.1
2330
gopkg.in/gcfg.v1 v1.2.3
2431
gopkg.in/warnings.v0 v0.1.2 // indirect
25-
k8s.io/apimachinery v0.0.0
26-
k8s.io/client-go v11.0.0+incompatible
27-
k8s.io/klog v0.3.3
28-
k8s.io/kubernetes v1.15.0
29-
k8s.io/test-infra v0.0.0-20190620191450-c9d7409d4a1e
30-
k8s.io/utils v0.0.0-20190607212802-c55fbcfc754a
31-
)
32-
33-
replace (
34-
k8s.io/api => k8s.io/api v0.0.0-20190620084959-7cf5895f2711
35-
k8s.io/apiextensions-apiserver => k8s.io/apiextensions-apiserver v0.0.0-20190620085554-14e95df34f1f
36-
k8s.io/apimachinery => k8s.io/apimachinery v0.0.0-20190612205821-1799e75a0719
37-
k8s.io/apiserver => k8s.io/apiserver v0.0.0-20190620085212-47dc9a115b18
38-
k8s.io/cli-runtime => k8s.io/cli-runtime v0.0.0-20190620085706-2090e6d8f84c
39-
k8s.io/client-go => k8s.io/client-go v0.0.0-20190620085101-78d2af792bab
40-
k8s.io/cloud-provider => k8s.io/cloud-provider v0.0.0-20190620090043-8301c0bda1f0
41-
k8s.io/cluster-bootstrap => k8s.io/cluster-bootstrap v0.0.0-20190620090013-c9a0fc045dc1
42-
k8s.io/code-generator => k8s.io/code-generator v0.0.0-20190612205613-18da4a14b22b
43-
k8s.io/component-base => k8s.io/component-base v0.0.0-20190620085130-185d68e6e6ea
44-
k8s.io/cri-api => k8s.io/cri-api v0.0.0-20190531030430-6117653b35f1
45-
k8s.io/csi-translation-lib => k8s.io/csi-translation-lib v0.0.0-20190620090116-299a7b270edc
46-
k8s.io/kube-aggregator => k8s.io/kube-aggregator v0.0.0-20190620085325-f29e2b4a4f84
47-
k8s.io/kube-controller-manager => k8s.io/kube-controller-manager v0.0.0-20190620085942-b7f18460b210
48-
k8s.io/kube-proxy => k8s.io/kube-proxy v0.0.0-20190620085809-589f994ddf7f
49-
k8s.io/kube-scheduler => k8s.io/kube-scheduler v0.0.0-20190620085912-4acac5405ec6
50-
k8s.io/kubelet => k8s.io/kubelet v0.0.0-20190620085838-f1cb295a73c9
51-
k8s.io/legacy-cloud-providers => k8s.io/legacy-cloud-providers v0.0.0-20190620090156-2138f2c9de18
52-
k8s.io/metrics => k8s.io/metrics v0.0.0-20190620085625-3b22d835f165
53-
k8s.io/sample-apiserver => k8s.io/sample-apiserver v0.0.0-20190620085408-1aef9010884e
32+
k8s.io/apimachinery v0.17.1
33+
k8s.io/client-go v11.0.1-0.20190805182717-6502b5e7b1b5+incompatible
34+
k8s.io/klog v1.0.0
35+
k8s.io/repo-infra v0.0.0-20190329054012-df02ded38f95 // indirect
36+
k8s.io/test-infra v0.0.0-20200115230622-70a5174aa78d
37+
k8s.io/utils v0.0.0-20200109141947-94aeca20bf09
5438
)

go.sum

+190-155
Large diffs are not rendered by default.

pkg/gce-pd-csi-driver/controller.go

-1
Original file line numberDiff line numberDiff line change
@@ -1054,7 +1054,6 @@ func createSingleZoneDisk(ctx context.Context, cloudProvider gce.GCECompute, nam
10541054
if err != nil {
10551055
return nil, err
10561056
}
1057-
klog.Warningf("GCE PD %s already exists after wait, reusing", name)
10581057
return disk, nil
10591058
}
10601059

pkg/gce-pd-csi-driver/gce-pd-driver.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import (
2121
"google.golang.org/grpc/codes"
2222
"google.golang.org/grpc/status"
2323
"k8s.io/klog"
24-
"k8s.io/kubernetes/pkg/util/mount"
24+
"k8s.io/utils/mount"
2525
common "sigs.k8s.io/gcp-compute-persistent-disk-csi-driver/pkg/common"
2626
gce "sigs.k8s.io/gcp-compute-persistent-disk-csi-driver/pkg/gce-cloud-provider/compute"
2727
metadataservice "sigs.k8s.io/gcp-compute-persistent-disk-csi-driver/pkg/gce-cloud-provider/metadata"

pkg/gce-pd-csi-driver/node.go

+23-11
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,12 @@ import (
2828
csi "github.com/container-storage-interface/spec/lib/go/csi"
2929

3030
"k8s.io/klog"
31-
"k8s.io/kubernetes/pkg/util/mount"
32-
"k8s.io/kubernetes/pkg/util/resizefs"
31+
"k8s.io/utils/mount"
3332

3433
"sigs.k8s.io/gcp-compute-persistent-disk-csi-driver/pkg/common"
3534
metadataservice "sigs.k8s.io/gcp-compute-persistent-disk-csi-driver/pkg/gce-cloud-provider/metadata"
3635
mountmanager "sigs.k8s.io/gcp-compute-persistent-disk-csi-driver/pkg/mount-manager"
36+
"sigs.k8s.io/gcp-compute-persistent-disk-csi-driver/pkg/resizefs"
3737
)
3838

3939
type GCENodeServer struct {
@@ -130,7 +130,7 @@ func (ns *GCENodeServer) NodePublishVolume(ctx context.Context, req *csi.NodePub
130130

131131
sourcePath = stagingTargetPath
132132

133-
if err := ns.Mounter.Interface.MakeDir(targetPath); err != nil {
133+
if err := os.MkdirAll(targetPath, 0750); err != nil {
134134
return nil, status.Error(codes.Internal, fmt.Sprintf("mkdir failed on disk %s (%v)", targetPath, err))
135135
}
136136
} else if blk := volumeCapability.GetBlock(); blk != nil {
@@ -147,7 +147,7 @@ func (ns *GCENodeServer) NodePublishVolume(ctx context.Context, req *csi.NodePub
147147
}
148148

149149
// Expose block volume as file at target path
150-
err = ns.Mounter.MakeFile(targetPath)
150+
err = makeFile(targetPath)
151151
if err != nil {
152152
if removeErr := os.Remove(targetPath); removeErr != nil {
153153
return nil, status.Error(codes.Internal, fmt.Sprintf("Error removing block file at target path %v: %v, mounti error: %v", targetPath, removeErr, err))
@@ -190,6 +190,18 @@ func (ns *GCENodeServer) NodePublishVolume(ctx context.Context, req *csi.NodePub
190190
return &csi.NodePublishVolumeResponse{}, nil
191191
}
192192

193+
func makeFile(path string) error {
194+
// Create file
195+
newFile, err := os.OpenFile(path, os.O_CREATE|os.O_RDWR, 0750)
196+
if err != nil {
197+
return fmt.Errorf("failed to open file %s: %v", path, err)
198+
}
199+
if err := newFile.Close(); err != nil {
200+
return fmt.Errorf("failed to close file %s: %v", path, err)
201+
}
202+
return nil
203+
}
204+
193205
func (ns *GCENodeServer) NodeUnpublishVolume(ctx context.Context, req *csi.NodeUnpublishVolumeRequest) (*csi.NodeUnpublishVolumeResponse, error) {
194206
// Validate Arguments
195207
targetPath := req.GetTargetPath()
@@ -264,7 +276,7 @@ func (ns *GCENodeServer) NodeStageVolume(ctx context.Context, req *csi.NodeStage
264276
notMnt, err := ns.Mounter.Interface.IsLikelyNotMountPoint(stagingTargetPath)
265277
if err != nil {
266278
if os.IsNotExist(err) {
267-
if err := ns.Mounter.Interface.MakeDir(stagingTargetPath); err != nil {
279+
if err := os.MkdirAll(stagingTargetPath, 0750); err != nil {
268280
return nil, status.Error(codes.Internal, fmt.Sprintf("Failed to create directory (%q): %v", stagingTargetPath, err))
269281
}
270282
notMnt = true
@@ -371,13 +383,13 @@ func (ns *GCENodeServer) NodeGetVolumeStats(ctx context.Context, req *csi.NodeGe
371383
return nil, status.Error(codes.InvalidArgument, "NodeGetVolumeStats volume path was empty")
372384
}
373385

374-
exists, err := ns.Mounter.Interface.ExistsPath(req.VolumePath)
386+
_, err := os.Stat(req.VolumePath)
375387
if err != nil {
388+
if os.IsNotExist(err) {
389+
return nil, status.Errorf(codes.NotFound, "path %s does not exist", req.VolumePath)
390+
}
376391
return nil, status.Errorf(codes.Internal, "unknown error when stat on %s: %v", req.VolumePath, err)
377392
}
378-
if !exists {
379-
return nil, status.Errorf(codes.NotFound, "path %s does not exist", req.VolumePath)
380-
}
381393

382394
isBlock, err := ns.VolumeStatter.IsBlockDevice(req.VolumePath)
383395
if err != nil {
@@ -528,14 +540,14 @@ func (ns *GCENodeServer) getDevicePath(volumeID string, partition string) (strin
528540
}
529541

530542
func (ns *GCENodeServer) getBlockSizeBytes(devicePath string) (int64, error) {
531-
output, err := ns.Mounter.Exec.Run("blockdev", "--getsize64", devicePath)
543+
output, err := ns.Mounter.Exec.Command("blockdev", "--getsize64", devicePath).CombinedOutput()
532544
if err != nil {
533545
return -1, fmt.Errorf("error when getting size of block volume at path %s: output: %s, err: %v", devicePath, string(output), err)
534546
}
535547
strOut := strings.TrimSpace(string(output))
536548
gotSizeBytes, err := strconv.ParseInt(strOut, 10, 64)
537549
if err != nil {
538-
return -1, fmt.Errorf("failed to parse size %s into int a size", strOut)
550+
return -1, fmt.Errorf("failed to parse %s into an int size", strOut)
539551
}
540552
return gotSizeBytes, nil
541553
}

0 commit comments

Comments
 (0)