Skip to content
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

dependency update #230

Merged
merged 4 commits into from
Dec 14, 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
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
77 changes: 65 additions & 12 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,70 @@ module github.com/kubernetes-csi/csi-driver-host-path
go 1.12

require (
github.com/container-storage-interface/spec v1.2.0
github.com/container-storage-interface/spec v1.3.0
github.com/go-logr/logr v0.3.0 // indirect
github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b
github.com/golang/protobuf v1.3.2
github.com/google/uuid v1.0.0 // indirect
github.com/kubernetes-csi/csi-lib-utils v0.3.0
github.com/pborman/uuid v0.0.0-20180906182336-adf5a7427709
github.com/spf13/afero v1.2.2 // indirect
github.com/stretchr/testify v1.4.0 // indirect
golang.org/x/net v0.0.0-20190311183353-d8887717615a
google.golang.org/grpc v1.26.0
k8s.io/apimachinery v0.0.0-20181110190943-2a7c93004028 // indirect
k8s.io/kubernetes v1.12.2
k8s.io/utils v0.0.0-20181102055113-1bd4f387aa67
github.com/golang/protobuf v1.4.3
github.com/kubernetes-csi/csi-lib-utils v0.9.0
github.com/pborman/uuid v1.2.1
golang.org/x/net v0.0.0-20201209123823-ac852fbbde11
golang.org/x/sys v0.0.0-20201207223542-d4d67f95c62d // indirect
google.golang.org/genproto v0.0.0-20201209185603-f92720507ed4 // indirect
google.golang.org/grpc v1.34.0
k8s.io/apimachinery v0.21.0-alpha.0 // indirect
k8s.io/kubernetes v1.20.0
k8s.io/mount-utils v0.20.0 // indirect
k8s.io/utils v0.0.0-20201110183641-67b214c5f920
)

replace k8s.io/api => k8s.io/api v0.20.0

replace k8s.io/apiextensions-apiserver => k8s.io/apiextensions-apiserver v0.20.0

replace k8s.io/apimachinery => k8s.io/apimachinery v0.21.0-alpha.0

replace k8s.io/apiserver => k8s.io/apiserver v0.20.0

replace k8s.io/cli-runtime => k8s.io/cli-runtime v0.20.0

replace k8s.io/client-go => k8s.io/client-go v0.20.0

replace k8s.io/cloud-provider => k8s.io/cloud-provider v0.20.0

replace k8s.io/cluster-bootstrap => k8s.io/cluster-bootstrap v0.20.0

replace k8s.io/code-generator => k8s.io/code-generator v0.20.1-rc.0

replace k8s.io/component-base => k8s.io/component-base v0.20.0

replace k8s.io/component-helpers => k8s.io/component-helpers v0.20.0

replace k8s.io/controller-manager => k8s.io/controller-manager v0.20.0

replace k8s.io/cri-api => k8s.io/cri-api v0.20.1-rc.0

replace k8s.io/csi-translation-lib => k8s.io/csi-translation-lib v0.20.0

replace k8s.io/kube-aggregator => k8s.io/kube-aggregator v0.20.0

replace k8s.io/kube-controller-manager => k8s.io/kube-controller-manager v0.20.0

replace k8s.io/kube-proxy => k8s.io/kube-proxy v0.20.0

replace k8s.io/kube-scheduler => k8s.io/kube-scheduler v0.20.0

replace k8s.io/kubectl => k8s.io/kubectl v0.20.0

replace k8s.io/kubelet => k8s.io/kubelet v0.20.0

replace k8s.io/legacy-cloud-providers => k8s.io/legacy-cloud-providers v0.20.0

replace k8s.io/metrics => k8s.io/metrics v0.20.0

replace k8s.io/mount-utils => k8s.io/mount-utils v0.20.1-rc.0

replace k8s.io/sample-apiserver => k8s.io/sample-apiserver v0.20.0

replace k8s.io/sample-cli-plugin => k8s.io/sample-cli-plugin v0.20.0

replace k8s.io/sample-controller => k8s.io/sample-controller v0.20.0
872 changes: 859 additions & 13 deletions go.sum

Large diffs are not rendered by default.

14 changes: 9 additions & 5 deletions pkg/hostpath/controllerserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@ func (cs *controllerServer) CreateSnapshot(ctx context.Context, req *csi.CreateS
Snapshot: &csi.Snapshot{
SnapshotId: exSnap.Id,
SourceVolumeId: exSnap.VolID,
CreationTime: &exSnap.CreationTime,
CreationTime: exSnap.CreationTime,
SizeBytes: exSnap.SizeBytes,
ReadyToUse: exSnap.ReadyToUse,
},
Expand Down Expand Up @@ -352,7 +352,7 @@ func (cs *controllerServer) CreateSnapshot(ctx context.Context, req *csi.CreateS
snapshot.Id = snapshotID
snapshot.VolID = volumeID
snapshot.Path = file
snapshot.CreationTime = *creationTime
snapshot.CreationTime = creationTime
snapshot.SizeBytes = hostPathVolume.VolSize
snapshot.ReadyToUse = true

Expand All @@ -362,7 +362,7 @@ func (cs *controllerServer) CreateSnapshot(ctx context.Context, req *csi.CreateS
Snapshot: &csi.Snapshot{
SnapshotId: snapshot.Id,
SourceVolumeId: snapshot.VolID,
CreationTime: &snapshot.CreationTime,
CreationTime: snapshot.CreationTime,
SizeBytes: snapshot.SizeBytes,
ReadyToUse: snapshot.ReadyToUse,
},
Expand Down Expand Up @@ -423,7 +423,7 @@ func (cs *controllerServer) ListSnapshots(ctx context.Context, req *csi.ListSnap
snapshot := csi.Snapshot{
SnapshotId: snap.Id,
SourceVolumeId: snap.VolID,
CreationTime: &snap.CreationTime,
CreationTime: snap.CreationTime,
SizeBytes: snap.SizeBytes,
ReadyToUse: snap.ReadyToUse,
}
Expand Down Expand Up @@ -525,13 +525,17 @@ func (cs *controllerServer) ControllerExpandVolume(ctx context.Context, req *csi
}, nil
}

func (cs *controllerServer) ControllerGetVolume(context.Context, *csi.ControllerGetVolumeRequest) (*csi.ControllerGetVolumeResponse, error) {
return nil, status.Error(codes.Unimplemented, "")
}

func convertSnapshot(snap hostPathSnapshot) *csi.ListSnapshotsResponse {
entries := []*csi.ListSnapshotsResponse_Entry{
{
Snapshot: &csi.Snapshot{
SnapshotId: snap.Id,
SourceVolumeId: snap.VolID,
CreationTime: &snap.CreationTime,
CreationTime: snap.CreationTime,
SizeBytes: snap.SizeBytes,
ReadyToUse: snap.ReadyToUse,
},
Expand Down
30 changes: 11 additions & 19 deletions pkg/hostpath/hostpath.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,13 +68,13 @@ type hostPathVolume struct {
}

type hostPathSnapshot struct {
Name string `json:"name"`
Id string `json:"id"`
VolID string `json:"volID"`
Path string `json:"path"`
CreationTime timestamp.Timestamp `json:"creationTime"`
SizeBytes int64 `json:"sizeBytes"`
ReadyToUse bool `json:"readyToUse"`
Name string `json:"name"`
Id string `json:"id"`
VolID string `json:"volID"`
Path string `json:"path"`
CreationTime *timestamp.Timestamp `json:"creationTime"`
SizeBytes int64 `json:"sizeBytes"`
ReadyToUse bool `json:"readyToUse"`
}

var (
Expand Down Expand Up @@ -280,18 +280,10 @@ func deleteHostpathVolume(volID string) error {

if vol.VolAccessType == blockAccess {
volPathHandler := volumepathhandler.VolumePathHandler{}
// Get the associated loop device.
device, err := volPathHandler.GetLoopDevice(getVolumePath(volID))
if err != nil {
return fmt.Errorf("failed to get the loop device: %v", err)
}

if device != "" {
// Remove any associated loop device.
glog.V(4).Infof("deleting loop device %s", device)
if err := volPathHandler.RemoveLoopDevice(device); err != nil {
return fmt.Errorf("failed to remove loop device %v: %v", device, err)
}
path := getVolumePath(volID)
glog.V(4).Infof("deleting loop device for file %s if it exists", path)
if err := volPathHandler.DetachFileDevice(path); err != nil {
return fmt.Errorf("failed to remove loop device for file %s: %v", path, err)
}
}

Expand Down
21 changes: 17 additions & 4 deletions pkg/hostpath/nodeserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ import (
"github.com/container-storage-interface/spec/lib/go/csi"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"
"k8s.io/kubernetes/pkg/util/mount"
"k8s.io/kubernetes/pkg/volume/util/volumepathhandler"
"k8s.io/utils/mount"
)

const TopologyKeyNode = "topology.hostpath.csi/node"
Expand Down Expand Up @@ -104,7 +104,7 @@ func (ns *nodeServer) NodePublishVolume(ctx context.Context, req *csi.NodePublis
// Check if the target path exists. Create if not present.
_, err = os.Lstat(targetPath)
if os.IsNotExist(err) {
if err = mounter.MakeFile(targetPath); err != nil {
if err = makeFile(targetPath); err != nil {
return nil, status.Error(codes.Internal, fmt.Sprintf("failed to create target path: %s: %v", targetPath, err))
}
}
Expand All @@ -113,7 +113,7 @@ func (ns *nodeServer) NodePublishVolume(ctx context.Context, req *csi.NodePublis
}

// Check if the target path is already mounted. Prevent remounting.
notMount, err := mounter.IsNotMountPoint(targetPath)
notMount, err := mount.IsNotMountPoint(mounter, targetPath)
if err != nil {
if !os.IsNotExist(err) {
return nil, status.Errorf(codes.Internal, "error checking path %s for mount: %s", targetPath, err)
Expand All @@ -135,7 +135,7 @@ func (ns *nodeServer) NodePublishVolume(ctx context.Context, req *csi.NodePublis
return nil, status.Error(codes.InvalidArgument, "cannot publish a non-mount volume as mount volume")
}

notMnt, err := mount.New("").IsNotMountPoint(targetPath)
notMnt, err := mount.IsNotMountPoint(mount.New(""), targetPath)
if err != nil {
if os.IsNotExist(err) {
if err = os.MkdirAll(targetPath, 0750); err != nil {
Expand Down Expand Up @@ -341,3 +341,16 @@ func (ns *nodeServer) NodeExpandVolume(ctx context.Context, req *csi.NodeExpandV

return &csi.NodeExpandVolumeResponse{}, nil
}

// makeFile ensures that the file exists, creating it if necessary.
// The parent directory must exist.
func makeFile(pathname string) error {
f, err := os.OpenFile(pathname, os.O_CREATE, os.FileMode(0644))
defer f.Close()
if err != nil {
if !os.IsExist(err) {
return err
}
}
return nil
}
Loading