Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions pkg/ddc/alluxio/operations/base.go
Original file line number Diff line number Diff line change
Expand Up @@ -479,13 +479,13 @@ func (a AlluxioFileUtils) MasterPodName() (masterPodName string, err error) {

redactedCommand := securityutils.FilterCommand(command)
str := strings.Split(stdout, "\n")
if len(str) < 1 {
if len(str) < 2 {
message := fmt.Sprintf("get wrong result when using command %v", redactedCommand)
return a.podName, errors.New(message)
}

data := strings.Fields(str[1])
if len(data) < 2 {
if len(data) < 3 {
message := fmt.Sprintf("get wrong result when using command %v", redactedCommand)
return a.podName, errors.New(message)
}
Expand Down
16 changes: 16 additions & 0 deletions pkg/ddc/alluxio/operations/base_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -797,6 +797,22 @@ func TestAlluxioFileUtils_MasterPodName(t *testing.T) {
if address != "192.168.0.193" {
t.Errorf("check failure, want: %s, got: %s", "192.168.0.193", address)
}

// Output that does not have the master address on the second line must return an error, not panic.
for _, stdout := range []string{
"",
"Alluxio cluster summary: ",
"Alluxio cluster summary: \n",
"Alluxio cluster summary: \n Master Address:",
} {
ExecUnexpected := func(a AlluxioFileUtils, command []string, verbose bool) (string, string, error) {
return stdout, "", nil
}
patches.ApplyPrivateMethod(reflect.TypeOf(AlluxioFileUtils{}), "exec", ExecUnexpected)
if _, err := a.MasterPodName(); err == nil {
t.Errorf("check failure for stdout %q, want err, got nil", stdout)
}
}
}

func TestAlluxioFileUtils_ExecMountScripts(t *testing.T) {
Expand Down
Loading