From fe349d7bb2ba27bd64b7bf94e170d050189b5e99 Mon Sep 17 00:00:00 2001 From: Ralf Grubenmann Date: Wed, 3 Jan 2024 11:54:58 +0100 Subject: [PATCH] fix tests --- pkg/rclone/controllerserver.go | 4 ++-- pkg/rclone/rclone.go | 13 +++++++++++-- test/sanity_test.go | 3 +++ 3 files changed, 16 insertions(+), 4 deletions(-) diff --git a/pkg/rclone/controllerserver.go b/pkg/rclone/controllerserver.go index b374add..b213bc3 100644 --- a/pkg/rclone/controllerserver.go +++ b/pkg/rclone/controllerserver.go @@ -25,10 +25,10 @@ type controllerServer struct { func (cs *controllerServer) ValidateVolumeCapabilities(ctx context.Context, req *csi.ValidateVolumeCapabilitiesRequest) (*csi.ValidateVolumeCapabilitiesResponse, error) { volId := req.GetVolumeId() if len(volId) == 0 { - return nil, status.Error(codes.InvalidArgument, "DeteleVolume must be provided volume id") + return nil, status.Error(codes.InvalidArgument, "ValidateVolumeCapabilities must be provided volume id") } if len(req.GetVolumeCapabilities()) == 0 { - return nil, status.Error(codes.InvalidArgument, "CreateVolume without capabilities") + return nil, status.Error(codes.InvalidArgument, "ValidateVolumeCapabilities without capabilities") } cs.mutex.Lock() diff --git a/pkg/rclone/rclone.go b/pkg/rclone/rclone.go index d852eb8..567db53 100644 --- a/pkg/rclone/rclone.go +++ b/pkg/rclone/rclone.go @@ -1,6 +1,7 @@ package rclone import ( + "bufio" "bytes" "encoding/json" "errors" @@ -383,16 +384,24 @@ func (r *Rclone) run_daemon() error { env := os.Environ() cmd := os_exec.Command(rclone_cmd, rclone_args...) + stderr, err := cmd.StderrPipe() + if err != nil { + panic("couldn't get stderr of rclone process") + } + scanner := bufio.NewScanner(stderr) cmd.Env = env if err := cmd.Start(); err != nil { return err } r.process = cmd.Process.Pid go func() { + output := "" + for scanner.Scan() { + output = scanner.Text() + } err := cmd.Wait() if err != nil { - klog.Errorf("background process failed with: %s", err) - panic(fmt.Sprintf("background exited")) + klog.Errorf("background process failed with: %s,%s", output, err) } }() return nil diff --git a/test/sanity_test.go b/test/sanity_test.go index 84d3c35..e508aed 100644 --- a/test/sanity_test.go +++ b/test/sanity_test.go @@ -80,5 +80,8 @@ provider=AWS`}, } sanity.Test(t, cfg) + // sanity just completely kills the driver, leaking the rclone daemon, so we cleanup manually + driver.RcloneOps.Cleanup() + kubeClient.CoreV1().Secrets("csi-rclone").Delete(context.Background(), "test-pvc", metav1.DeleteOptions{}) }