Skip to content
Snippets Groups Projects
Commit 197851d9 authored by Le Quoc Tuan's avatar Le Quoc Tuan Committed by Derek Su
Browse files

fix: multiple paths is not true random (fix #342)

parent 8219f6cd
No related branches found
No related tags found
No related merge requests found
......@@ -6,6 +6,7 @@ import (
"encoding/json"
"fmt"
"io"
"math/rand/v2"
"os"
"path/filepath"
"reflect"
......@@ -251,11 +252,14 @@ func (p *LocalPathProvisioner) getPathOnNode(node string, requestedPath string,
return requestedPath, nil
}
// if no particular path was requested, choose a random one
path := ""
for path = range paths {
break
i := rand.IntN(len(paths))
for p := range paths {
if i == 0 {
return p, nil
}
i--
}
return path, nil
return "", fmt.Errorf("never happens, but compiler doesn't know that")
}
func (p *LocalPathProvisioner) isSharedFilesystem(c *StorageClassConfig) (bool, error) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment