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

fix(sanity): fixing flaky sanity test case #256

Merged
merged 1 commit into from
Dec 10, 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
2 changes: 1 addition & 1 deletion buildscripts/zfs-driver/zfs-driver.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ COPY . .

RUN make buildx.csi-driver

FROM ubuntu:19.10
FROM ubuntu:18.04

RUN apt-get clean && rm -rf /var/lib/apt/lists/*
RUN apt-get update; exit 0
Expand Down
2 changes: 1 addition & 1 deletion ci/sanity.sh
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ EOT

function startTestSuite() {
echo "================== Start csi-sanity test suite ================="
./csi-sanity --ginkgo.v --csi.controllerendpoint=///tmp/csi.sock --csi.endpoint=/var/lib/kubelet/plugins/zfs-localpv/csi.sock --csi.testvolumeparameters=/tmp/parameters.json
./csi-sanity --ginkgo.v --csi.controllerendpoint=///tmp/csi.sock --csi.endpoint=/var/lib/kubelet/plugins/zfs-localpv/csi.sock --csi.testvolumeparameters=/tmp/parameters.json --csi.testsnapshotparameters=/tmp/parameters.json
if [ $? -ne 0 ];
then
dumpAllLogs
Expand Down
38 changes: 32 additions & 6 deletions pkg/driver/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,23 @@ func waitForVolDestroy(volname string) error {
return nil
}

func waitForReadySnapshot(snapname string) error {
for true {
snap, err := zfs.GetZFSSnapshot(snapname)
if err != nil {
return status.Errorf(codes.Internal,
"zfs: wait failed, not able to get the snapshot %s %s", snapname, err.Error())
}

switch snap.Status.State {
case zfs.ZFSStatusReady:
return nil
}
time.Sleep(time.Second)
}
return nil
}

// CreateZFSVolume create new zfs volume from csi volume request
func CreateZFSVolume(req *csi.CreateVolumeRequest) (string, error) {
volName := strings.ToLower(req.GetName())
Expand Down Expand Up @@ -224,12 +241,6 @@ func CreateZFSVolume(req *csi.CreateVolumeRequest) (string, error) {
"not able to provision the volume %s", err.Error())
}

if _, ok := parameters["wait"]; ok {
if err := waitForReadyVolume(volName); err != nil {
return "", err
}
}

return selected, nil
}

Expand Down Expand Up @@ -370,6 +381,12 @@ func (cs *controller) CreateVolume(
return nil, err
}

if _, ok := parameters["wait"]; ok {
if err := waitForReadyVolume(volName); err != nil {
return nil, err
}
}

sendEventOrIgnore(pvcName, volName, strconv.FormatInt(int64(size), 10), "zfs-localpv", analytics.VolumeProvision)

topology := map[string]string{zfs.ZFSTopologyKey: selected}
Expand Down Expand Up @@ -661,6 +678,15 @@ func (cs *controller) CreateSnapshot(
)
}

originalParams := req.GetParameters()
parameters := helpers.GetCaseInsensitiveMap(&originalParams)

if _, ok := parameters["wait"]; ok {
if err := waitForReadySnapshot(snapName); err != nil {
return nil, err
}
}

state, _ = zfs.GetZFSSnapshotStatus(snapName)

return csipayload.NewCreateSnapshotResponseBuilder().
Expand Down