Fix multivolume access tests for Windows

Fix issue for multivolume access tests

Change-Id: I7e00d8bfe9682540b60b5998f78f2a48550934af
This commit is contained in:
Jing Xu 2021-05-07 10:53:40 -07:00
parent 545d595674
commit 5e5a3ce85a
2 changed files with 6 additions and 3 deletions

View File

@ -19,7 +19,6 @@ package pod
import (
"context"
"fmt"
"runtime"
"time"
v1 "k8s.io/api/core/v1"
@ -167,11 +166,12 @@ func MakeSecPod(podConfig *Config) (*v1.Pod, error) {
if podConfig.NS == "" {
return nil, fmt.Errorf("Cannot create pod with empty namespace")
}
if len(podConfig.Command) == 0 {
if len(podConfig.Command) == 0 && !NodeOSDistroIs("windows") {
podConfig.Command = "trap exit TERM; while true; do sleep 1; done"
}
podName := "pod-" + string(uuid.NewUUID())
if podConfig.FsGroup == nil && runtime.GOOS != "windows" {
if podConfig.FsGroup == nil && !NodeOSDistroIs("windows") {
podConfig.FsGroup = func(i int64) *int64 {
return &i
}(1000)

View File

@ -40,6 +40,9 @@ func NodeOSDistroIs(distro string) bool {
// Depending on the Node OS is Windows or linux, the command will use powershell or /bin/sh
func GenerateScriptCmd(command string) []string {
var commands []string
if command == "" {
return commands
}
if !NodeOSDistroIs("windows") {
commands = []string{"/bin/sh", "-c", command}
} else {