Skip to content

Commit

Permalink
fix(sanity): fixing flaky sanity test case
Browse files Browse the repository at this point in the history
Also moving to bionic docker image for github action also.

Signed-off-by: Pawan <pawan@mayadata.io>
  • Loading branch information
pawanpraka1 authored and kmova committed Dec 10, 2020
1 parent 2ae14f5 commit 0409fca
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 8 deletions.
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

0 comments on commit 0409fca

Please sign in to comment.