Skip to content

Commit 68e324e

Browse files
k8s-ci-robothungnguyen243
authored andcommitted
Merge pull request kubernetes-sigs#1948 from halimsam/dataloss-change
Return DataLoss error status for any Data Cache related code in NodeStageVolume & NodeUnstageVolume.
2 parents 6bb2719 + ac01e47 commit 68e324e

File tree

8 files changed

+233
-97
lines changed

8 files changed

+233
-97
lines changed

Diff for: cmd/gce-pd-csi-driver/main.go

-3
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,9 @@ import (
2727
"strings"
2828
"time"
2929

30-
"k8s.io/client-go/kubernetes"
31-
"k8s.io/client-go/rest"
3230
"k8s.io/klog/v2"
3331
"k8s.io/utils/strings/slices"
3432

35-
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
3633
"sigs.k8s.io/gcp-compute-persistent-disk-csi-driver/pkg/common"
3734
"sigs.k8s.io/gcp-compute-persistent-disk-csi-driver/pkg/deviceutils"
3835
gce "sigs.k8s.io/gcp-compute-persistent-disk-csi-driver/pkg/gce-cloud-provider/compute"

Diff for: pkg/common/constants.go

+7
Original file line numberDiff line numberDiff line change
@@ -44,4 +44,11 @@ const (
4444
ContexLocalSsdCacheSize = "local-ssd-cache-size"
4545
// Node name for E2E tests
4646
TestNode = "test-node-csi-e2e"
47+
48+
// Default LSSD count for datacache E2E tests
49+
LocalSSDCountForDataCache = 2
50+
51+
// Node label for datacache
52+
NodeLabelPrefix = "cloud.google.com/%s"
53+
DataCacheLssdCountLabel = "gke-data-cache-disk"
4754
)

Diff for: pkg/common/runcmd.go

+8-4
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ const (
1616
// RunCommand wraps a k8s exec to deal with the no child process error. Same as exec.CombinedOutput.
1717
// On error, the output is included so callers don't need to echo it again.
1818

19-
func RunCommand(pipeCmd string, pipeCmdArg string, cmd1 string, execCmdArgs ...string) ([]byte, error) {
19+
func RunCommand(pipeCmd string, pipeCmdArg []string, cmd1 string, execCmdArgs ...string) ([]byte, error) {
2020
execCmd1 := exec.Command(cmd1, execCmdArgs...)
2121

2222
if pipeCmd != "" {
@@ -47,9 +47,9 @@ func checkError(err error, execCmd exec.Cmd) error {
4747
}
4848
return err
4949
}
50-
func execPipeCommand(pipeCmd string, pipeCmdArg string, execCmd1 *exec.Cmd) ([]byte, error) {
50+
func execPipeCommand(pipeCmd string, pipeCmdArg []string, execCmd1 *exec.Cmd) ([]byte, error) {
5151

52-
execPipeCmd := exec.Command(pipeCmd, pipeCmdArg)
52+
execPipeCmd := exec.Command(pipeCmd, pipeCmdArg...)
5353
stdoutPipe, err := execCmd1.StdoutPipe()
5454
if err != nil {
5555
klog.Errorf("failed command %v: got error:%v", execCmd1, err)
@@ -63,8 +63,12 @@ func execPipeCommand(pipeCmd string, pipeCmdArg string, execCmd1 *exec.Cmd) ([]b
6363
execPipeCmd.Stdin = stdoutPipe
6464
output, err := execPipeCmd.CombinedOutput()
6565
if err != nil {
66+
// Some commands (such as grep) will return an error with exit status of 1
67+
if len(output) == 0 && err.(*exec.ExitError).ExitCode() == 1 {
68+
return output, nil
69+
}
6670
err = checkError(err, *execPipeCmd)
67-
return nil, fmt.Errorf("%s failed: %w; output: %s", pipeCmd, err, string(output))
71+
return nil, fmt.Errorf("%s failed: %w; output: %s", execPipeCmd, err, string(output))
6872
}
6973

7074
return output, nil

0 commit comments

Comments
 (0)