Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Ralf Grubenmann committed Jan 3, 2024
1 parent c894b04 commit fe349d7
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 4 deletions.
4 changes: 2 additions & 2 deletions pkg/rclone/controllerserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
13 changes: 11 additions & 2 deletions pkg/rclone/rclone.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package rclone

import (
"bufio"
"bytes"
"encoding/json"
"errors"
Expand Down Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions test/sanity_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{})
}

0 comments on commit fe349d7

Please sign in to comment.