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

Upstream merge #210

Closed
wants to merge 28 commits into from
Closed
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
f634098
Change owners
Fedosin Mar 2, 2020
4b1f10b
Merge pull request #24 from Fedosin/change_owners
Fedosin Mar 2, 2020
d14ea3b
Change owners
Fedosin Mar 2, 2020
6ae07ee
Merge pull request #25 from Fedosin/sync_upstream
openshift-merge-robot Mar 3, 2020
df723b9
Add Dockerfiles for openshift ci
Fedosin Mar 4, 2020
58dd7d8
Merge pull request #26 from Fedosin/add_dockerfiles
openshift-merge-robot Mar 4, 2020
daa84bb
Add Bugzilla component information
Fedosin Apr 14, 2020
e29df88
Merge pull request #27 from Fedosin/owners_bugzilla
openshift-merge-robot Apr 14, 2020
4fdff31
Merge branch 'upstream-master' into sync_upstream2
Fedosin Jun 18, 2020
2f48abf
Merge pull request #28 from Fedosin/sync_upstream2
Fedosin Jun 19, 2020
59fe400
<carry>: Umount volumes with force
jsafrane Aug 19, 2020
4aab5ed
Updating images/Dockerfile baseimages to mach ocp-build-data config
openshift-bot Aug 24, 2020
ddd02f8
Merge pull request #32 from openshift-bot/updating-images/dockerfile-…
openshift-merge-robot Aug 26, 2020
95f76aa
Merge pull request #31 from jsafrane/fix-umount-force
openshift-merge-robot Sep 9, 2020
5081a5b
Updating images/Dockerfile baseimages to mach ocp-build-data config
openshift-bot Sep 17, 2020
0ec6eb3
Update shiftstack-team membership
mandre Sep 17, 2020
a2fbb38
Merge pull request #34 from openshift-bot/updating-images/dockerfile-…
openshift-merge-robot Sep 17, 2020
c9c4b8f
Merge pull request #35 from mandre/update-owners
openshift-merge-robot Oct 2, 2020
bf4c087
Updating csi-driver-nfs builder & base images to be consistent with ART
Nov 12, 2020
6938446
Merge pull request #37 from openshift-bot/art-consistency-openshift-4…
openshift-merge-robot Dec 5, 2020
7d95d8d
Updating csi-driver-nfs builder & base images to be consistent with ART
Jan 13, 2021
9404d34
Merge pull request #39 from openshift-bot/art-consistency-openshift-4…
openshift-merge-robot Jan 14, 2021
d32503a
Merge remote-tracking branch 'upstream/master' into upstream-merge
mdbooth Apr 28, 2021
84be104
Merge pull request #41 from mdbooth/upstream-merge
openshift-merge-robot Jun 14, 2021
3b2eb71
Updating .ci-operator.yaml `build_root_image` from openshift/release
openshift-ci-robot Jun 14, 2021
dd35c5e
Merge pull request #43 from openshift-ci-robot/updating-.ci-operator.…
openshift-merge-robot Jun 14, 2021
a7f5765
Merge remote-tracking branch 'upstream/master' into upstream-merge
mdbooth Jun 17, 2021
69a6678
<carry>: Disable unit tests due to carry patch
mdbooth Jun 17, 2021
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
4 changes: 4 additions & 0 deletions .ci-operator.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
build_root_image:
name: release
namespace: openshift
tag: golang-1.16
10 changes: 4 additions & 6 deletions OWNERS
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
# See the OWNERS docs: https://git.k8s.io/community/contributors/guide/owners.md

approvers:
- kubernetes-csi-approvers
- andyzhangx
reviewers:
- kubernetes-csi-reviewers
- shiftstack-team

component: "Installer"
subcomponent: "OpenShift on OpenStack"
1 change: 0 additions & 1 deletion OWNERS_ALIASES

This file was deleted.

7 changes: 7 additions & 0 deletions OWNERS_ALIASES
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
aliases:
shiftstack-team:
- Fedosin
- adduarte
- iamemilio
- mandre
- pierreprinetti
12 changes: 12 additions & 0 deletions images/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
FROM registry.ci.openshift.org/ocp/builder:rhel-8-golang-1.15-openshift-4.7
COPY . /go/src/github.com/openshift/csi-driver-nfs
RUN cd /go/src/github.com/openshift/csi-driver-nfs && \
go build -o /go/src/github.com/openshift/csi-driver-nfs/nfsplugin cmd/nfsplugin/main.go

FROM registry.ci.openshift.org/ocp/4.7:base

COPY --from=0 /go/src/github.com/openshift/csi-driver-nfs/nfsplugin /usr/bin/

RUN yum -y install nfs-utils && yum -y install jq && yum clean all

ENTRYPOINT ["/usr/bin/nfsplugin"]
12 changes: 12 additions & 0 deletions images/Dockerfile.openshift.ci
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
FROM openshift/origin-release:golang-1.13
COPY . /go/src/github.com/openshift/csi-driver-nfs
RUN cd /go/src/github.com/openshift/csi-driver-nfs && \
go build -o /go/src/github.com/openshift/csi-driver-nfs/nfsplugin cmd/nfsplugin/main.go

FROM registry.svc.ci.openshift.org/origin/4.2:base

COPY --from=0 /go/src/github.com/openshift/csi-driver-nfs/nfsplugin /usr/bin/

RUN yum -y install nfs-utils && yum -y install jq && yum clean all

ENTRYPOINT ["/usr/bin/nfsplugin"]
86 changes: 76 additions & 10 deletions pkg/nfs/nodeserver.go
Original file line number Diff line number Diff line change
@@ -19,7 +19,9 @@ package nfs
import (
"fmt"
"os"
"os/exec"
"strings"
"time"

"github.com/container-storage-interface/spec/lib/go/csi"
"golang.org/x/net/context"
@@ -36,6 +38,11 @@ type NodeServer struct {
mounter mount.Interface
}

const (
// Deadline for unmount. After this time, umount -f is performed.
unmountTimeout = time.Minute
)

// NodePublishVolume mount the volume
func (ns *NodeServer) NodePublishVolume(ctx context.Context, req *csi.NodePublishVolumeRequest) (*csi.NodePublishVolumeResponse, error) {
if req.GetVolumeCapability() == nil {
@@ -95,6 +102,23 @@ func (ns *NodeServer) NodePublishVolume(ctx context.Context, req *csi.NodePublis
return &csi.NodePublishVolumeResponse{}, nil
}

func (ns *NodeServer) IsNotMountPoint(path string) (bool, error) {
mtab, err := ns.mounter.List()
if err != nil {
return false, err
}

for _, mnt := range mtab {
// This is how a directory deleted on the NFS server looks like
deletedDir := fmt.Sprintf("%s\\040(deleted)", mnt.Path)

if mnt.Path == path || mnt.Path == deletedDir {
return false, nil
}
}
return true, nil
}

// NodeUnpublishVolume unmount the volume
func (ns *NodeServer) NodeUnpublishVolume(ctx context.Context, req *csi.NodeUnpublishVolumeRequest) (*csi.NodeUnpublishVolumeResponse, error) {
volumeID := req.GetVolumeId()
@@ -105,27 +129,69 @@ func (ns *NodeServer) NodeUnpublishVolume(ctx context.Context, req *csi.NodeUnpu
if len(targetPath) == 0 {
return nil, status.Error(codes.InvalidArgument, "Target path missing in request")
}
notMnt, err := ns.mounter.IsLikelyNotMountPoint(targetPath)
klog.V(6).Infof("NodeUnpublishVolume started for %s", targetPath)

notMnt, err := ns.IsNotMountPoint(targetPath)
if err != nil {
if os.IsNotExist(err) {
return nil, status.Error(codes.NotFound, "Targetpath not found")
}
return nil, status.Error(codes.Internal, err.Error())
}
if notMnt {
return nil, status.Error(codes.NotFound, "Volume not mounted")

klog.V(4).Infof("NodeUnpublishVolume: path %s is *not* a mount point: %t", targetPath, notMnt)
if !notMnt {

err := ns.tryUnmount(targetPath)
if err != nil {
if err == context.DeadlineExceeded {
klog.V(2).Infof("Timed out waiting for unmount of %s, trying with -f", targetPath)
err = ns.forceUnmount(targetPath)
}
}
if err != nil {
return nil, status.Error(codes.Internal, err.Error())
}
klog.V(2).Infof("Unmounted %s", targetPath)
}

klog.V(2).Infof("NodeUnpublishVolume: CleanupMountPoint %s on volumeID(%s)", targetPath, volumeID)
err = mount.CleanupMountPoint(targetPath, ns.mounter, false)
if err != nil {
return nil, status.Error(codes.Internal, err.Error())
klog.V(2).Infof("NodeUnpublishVolume: Remove %s on volumeID(%s)", targetPath, volumeID)
if err := os.Remove(targetPath); err != nil {
if !os.IsNotExist(err) {
return nil, status.Error(codes.Internal, err.Error())
}
}
klog.V(4).Infof("Cleaned %s", targetPath)

return &csi.NodeUnpublishVolumeResponse{}, nil
}

// tryUnmount calls plain "umount" and waits for unmountTimeout for it to finish.
func (ns *NodeServer) tryUnmount(path string) error {
ctx, cancel := context.WithTimeout(context.Background(), unmountTimeout)
defer cancel()

cmd := exec.CommandContext(ctx, "umount", path)
out, cmderr := cmd.CombinedOutput()

// CombinedOutput() does not return DeadlineExceeded, make sure it's
// propagated on timeout.
if ctx.Err() != nil {
return ctx.Err()
}

if cmderr != nil {
return fmt.Errorf("failed to unmount volume: %s: %s", cmderr, string(out))
}
return nil
}

func (ns *NodeServer) forceUnmount(path string) error {
cmd := exec.Command("umount", "-f", path)
out, err := cmd.CombinedOutput()
if err != nil {
return fmt.Errorf("failed to force-unmount volume: %s: %s", err, string(out))
}
return nil
}

// NodeGetInfo return info of the node on which this plugin is running
func (ns *NodeServer) NodeGetInfo(ctx context.Context, req *csi.NodeGetInfoRequest) (*csi.NodeGetInfoResponse, error) {
return &csi.NodeGetInfoResponse{
6 changes: 5 additions & 1 deletion pkg/nfs/nodeserver_test.go
Original file line number Diff line number Diff line change
@@ -133,7 +133,7 @@ func TestNodeUnpublishVolume(t *testing.T) {

errorTarget := testutil.GetWorkDirPath("error_is_likely_target", t)
targetTest := testutil.GetWorkDirPath("target_test", t)
targetFile := testutil.GetWorkDirPath("abc.go", t)
//targetFile := testutil.GetWorkDirPath("abc.go", t)

tests := []struct {
desc string
@@ -152,16 +152,20 @@ func TestNodeUnpublishVolume(t *testing.T) {
req: csi.NodeUnpublishVolumeRequest{VolumeId: "vol_1"},
expectedErr: status.Error(codes.InvalidArgument, "Target path missing in request"),
},
/* Not relevant due to carry patch https://github.com/openshift/csi-driver-nfs/commit/59fe400d433137c48de81650026922a88e167177
// Downstream doesn't call IsLikelyNotMountPoint, and doesn't raise any error if the target is not mounted
{
desc: "[Error] Unmount error mocked by IsLikelyNotMountPoint",
req: csi.NodeUnpublishVolumeRequest{TargetPath: errorTarget, VolumeId: "vol_1"},
expectedErr: status.Error(codes.Internal, "fake IsLikelyNotMountPoint: fake error"),
},
// Downstream doesn't raise any error if the target is not mounted
{
desc: "[Error] Volume not mounted",
req: csi.NodeUnpublishVolumeRequest{TargetPath: targetFile, VolumeId: "vol_1"},
expectedErr: status.Error(codes.NotFound, "Volume not mounted"),
},
*/
}

// Setup