Skip to content

Break k/k dependency by migrating util/mount and copying resizefs. Re-enable sanity testing. Fix deps. #454

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

Merged
merged 1 commit into from
Jan 17, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 18 additions & 34 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,52 +3,36 @@ module sigs.k8s.io/gcp-compute-persistent-disk-csi-driver
go 1.13

require (
cloud.google.com/go v0.40.0
cloud.google.com/go v0.45.1
github.com/GoogleCloudPlatform/k8s-cloud-provider v0.0.0-20190612171043-2e19bb35a278
github.com/apache/thrift v0.12.0 // indirect
github.com/bazelbuild/bazel-gazelle v0.0.0-20190402225339-e530fae7ce5c // indirect
github.com/container-storage-interface/spec v1.2.0
github.com/deckarep/golang-set v0.0.0-20171013212420-1d4478f51bed // indirect
github.com/go-logfmt/logfmt v0.4.0 // indirect
github.com/gobuffalo/envy v1.6.15 // indirect
github.com/golang/protobuf v1.3.2
github.com/google/uuid v1.1.1
github.com/hashicorp/go-multierror v1.0.0 // indirect
github.com/knative/build v0.3.1-0.20190330033454-38ace00371c7 // indirect
github.com/knative/pkg v0.0.0-20190330034653-916205998db9 // indirect
github.com/kubernetes-csi/csi-test/v3 v3.0.0
github.com/markbates/inflect v1.0.4 // indirect
github.com/onsi/ginkgo v1.10.3
github.com/onsi/gomega v1.7.1
go.opencensus.io v0.22.0 // indirect
github.com/openzipkin/zipkin-go v0.1.6 // indirect
github.com/prometheus/tsdb v0.7.1 // indirect
golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45
golang.org/x/sys v0.0.0-20191113165036-4c7a9d0fe056
golang.org/x/time v0.0.0-20190308202827-9d24e82272b4 // indirect
google.golang.org/api v0.6.1-0.20190620001050-890e5eb51fe2
google.golang.org/appengine v1.6.1 // indirect
google.golang.org/api v0.10.0
google.golang.org/genproto v0.0.0-20191114150713-6bbd007550de
google.golang.org/grpc v1.25.1
gopkg.in/gcfg.v1 v1.2.3
gopkg.in/warnings.v0 v0.1.2 // indirect
k8s.io/apimachinery v0.0.0
k8s.io/client-go v11.0.0+incompatible
k8s.io/klog v0.3.3
k8s.io/kubernetes v1.15.0
k8s.io/test-infra v0.0.0-20190620191450-c9d7409d4a1e
k8s.io/utils v0.0.0-20190607212802-c55fbcfc754a
)

replace (
k8s.io/api => k8s.io/api v0.0.0-20190620084959-7cf5895f2711
k8s.io/apiextensions-apiserver => k8s.io/apiextensions-apiserver v0.0.0-20190620085554-14e95df34f1f
k8s.io/apimachinery => k8s.io/apimachinery v0.0.0-20190612205821-1799e75a0719
k8s.io/apiserver => k8s.io/apiserver v0.0.0-20190620085212-47dc9a115b18
k8s.io/cli-runtime => k8s.io/cli-runtime v0.0.0-20190620085706-2090e6d8f84c
k8s.io/client-go => k8s.io/client-go v0.0.0-20190620085101-78d2af792bab
k8s.io/cloud-provider => k8s.io/cloud-provider v0.0.0-20190620090043-8301c0bda1f0
k8s.io/cluster-bootstrap => k8s.io/cluster-bootstrap v0.0.0-20190620090013-c9a0fc045dc1
k8s.io/code-generator => k8s.io/code-generator v0.0.0-20190612205613-18da4a14b22b
k8s.io/component-base => k8s.io/component-base v0.0.0-20190620085130-185d68e6e6ea
k8s.io/cri-api => k8s.io/cri-api v0.0.0-20190531030430-6117653b35f1
k8s.io/csi-translation-lib => k8s.io/csi-translation-lib v0.0.0-20190620090116-299a7b270edc
k8s.io/kube-aggregator => k8s.io/kube-aggregator v0.0.0-20190620085325-f29e2b4a4f84
k8s.io/kube-controller-manager => k8s.io/kube-controller-manager v0.0.0-20190620085942-b7f18460b210
k8s.io/kube-proxy => k8s.io/kube-proxy v0.0.0-20190620085809-589f994ddf7f
k8s.io/kube-scheduler => k8s.io/kube-scheduler v0.0.0-20190620085912-4acac5405ec6
k8s.io/kubelet => k8s.io/kubelet v0.0.0-20190620085838-f1cb295a73c9
k8s.io/legacy-cloud-providers => k8s.io/legacy-cloud-providers v0.0.0-20190620090156-2138f2c9de18
k8s.io/metrics => k8s.io/metrics v0.0.0-20190620085625-3b22d835f165
k8s.io/sample-apiserver => k8s.io/sample-apiserver v0.0.0-20190620085408-1aef9010884e
k8s.io/apimachinery v0.17.1
k8s.io/client-go v11.0.1-0.20190805182717-6502b5e7b1b5+incompatible
k8s.io/klog v1.0.0
k8s.io/repo-infra v0.0.0-20190329054012-df02ded38f95 // indirect
k8s.io/test-infra v0.0.0-20200115230622-70a5174aa78d
k8s.io/utils v0.0.0-20200109141947-94aeca20bf09
)
345 changes: 190 additions & 155 deletions go.sum

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion pkg/gce-pd-csi-driver/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -1054,7 +1054,6 @@ func createSingleZoneDisk(ctx context.Context, cloudProvider gce.GCECompute, nam
if err != nil {
return nil, err
}
klog.Warningf("GCE PD %s already exists after wait, reusing", name)
return disk, nil
}

Expand Down
2 changes: 1 addition & 1 deletion pkg/gce-pd-csi-driver/gce-pd-driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import (
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"
"k8s.io/klog"
"k8s.io/kubernetes/pkg/util/mount"
"k8s.io/utils/mount"
common "sigs.k8s.io/gcp-compute-persistent-disk-csi-driver/pkg/common"
gce "sigs.k8s.io/gcp-compute-persistent-disk-csi-driver/pkg/gce-cloud-provider/compute"
metadataservice "sigs.k8s.io/gcp-compute-persistent-disk-csi-driver/pkg/gce-cloud-provider/metadata"
Expand Down
34 changes: 23 additions & 11 deletions pkg/gce-pd-csi-driver/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,12 @@ import (
csi "github.com/container-storage-interface/spec/lib/go/csi"

"k8s.io/klog"
"k8s.io/kubernetes/pkg/util/mount"
"k8s.io/kubernetes/pkg/util/resizefs"
"k8s.io/utils/mount"

"sigs.k8s.io/gcp-compute-persistent-disk-csi-driver/pkg/common"
metadataservice "sigs.k8s.io/gcp-compute-persistent-disk-csi-driver/pkg/gce-cloud-provider/metadata"
mountmanager "sigs.k8s.io/gcp-compute-persistent-disk-csi-driver/pkg/mount-manager"
"sigs.k8s.io/gcp-compute-persistent-disk-csi-driver/pkg/resizefs"
)

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

sourcePath = stagingTargetPath

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

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

func makeFile(path string) error {
// Create file
newFile, err := os.OpenFile(path, os.O_CREATE|os.O_RDWR, 0750)
if err != nil {
return fmt.Errorf("failed to open file %s: %v", path, err)
}
if err := newFile.Close(); err != nil {
return fmt.Errorf("failed to close file %s: %v", path, err)
}
return nil
}

func (ns *GCENodeServer) NodeUnpublishVolume(ctx context.Context, req *csi.NodeUnpublishVolumeRequest) (*csi.NodeUnpublishVolumeResponse, error) {
// Validate Arguments
targetPath := req.GetTargetPath()
Expand Down Expand Up @@ -264,7 +276,7 @@ func (ns *GCENodeServer) NodeStageVolume(ctx context.Context, req *csi.NodeStage
notMnt, err := ns.Mounter.Interface.IsLikelyNotMountPoint(stagingTargetPath)
if err != nil {
if os.IsNotExist(err) {
if err := ns.Mounter.Interface.MakeDir(stagingTargetPath); err != nil {
if err := os.MkdirAll(stagingTargetPath, 0750); err != nil {
return nil, status.Error(codes.Internal, fmt.Sprintf("Failed to create directory (%q): %v", stagingTargetPath, err))
}
notMnt = true
Expand Down Expand Up @@ -371,13 +383,13 @@ func (ns *GCENodeServer) NodeGetVolumeStats(ctx context.Context, req *csi.NodeGe
return nil, status.Error(codes.InvalidArgument, "NodeGetVolumeStats volume path was empty")
}

exists, err := ns.Mounter.Interface.ExistsPath(req.VolumePath)
_, err := os.Stat(req.VolumePath)
if err != nil {
if os.IsNotExist(err) {
return nil, status.Errorf(codes.NotFound, "path %s does not exist", req.VolumePath)
}
return nil, status.Errorf(codes.Internal, "unknown error when stat on %s: %v", req.VolumePath, err)
}
if !exists {
return nil, status.Errorf(codes.NotFound, "path %s does not exist", req.VolumePath)
}

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

func (ns *GCENodeServer) getBlockSizeBytes(devicePath string) (int64, error) {
output, err := ns.Mounter.Exec.Run("blockdev", "--getsize64", devicePath)
output, err := ns.Mounter.Exec.Command("blockdev", "--getsize64", devicePath).CombinedOutput()
if err != nil {
return -1, fmt.Errorf("error when getting size of block volume at path %s: output: %s, err: %v", devicePath, string(output), err)
}
strOut := strings.TrimSpace(string(output))
gotSizeBytes, err := strconv.ParseInt(strOut, 10, 64)
if err != nil {
return -1, fmt.Errorf("failed to parse size %s into int a size", strOut)
return -1, fmt.Errorf("failed to parse %s into an int size", strOut)
}
return gotSizeBytes, nil
}
Loading