Skip to content

Commit

Permalink
Merge pull request #5022 from twz123/inttest-user-creation-errors
Browse files Browse the repository at this point in the history
Capture errors when creating new users in inttests
  • Loading branch information
twz123 authored Sep 25, 2024
2 parents 5fe4434 + 7f9bc3d commit 0028231
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions inttest/common/bootloosesuite.go
Original file line number Diff line number Diff line change
Expand Up @@ -653,16 +653,13 @@ func (s *BootlooseSuite) GetJoinToken(role string, extraArgs ...string) (string,
}
defer ssh.Disconnect()

tokenCmd := fmt.Sprintf("%s token create --role=%s %s 2>/dev/null", s.K0sFullPath, role, strings.Join(extraArgs, " "))
token, err := ssh.ExecWithOutput(s.Context(), tokenCmd)
if err != nil {
tokenCmd := fmt.Sprintf("%s token create --role=%s %s", s.K0sFullPath, role, strings.Join(extraArgs, " "))
var tokenBuf bytes.Buffer
if err := ssh.Exec(s.Context(), tokenCmd, SSHStreams{Out: &tokenBuf}); err != nil {
return "", fmt.Errorf("can't get join token: %w", err)
}
outputParts := strings.Split(token, "\n")
// in case of no k0s.conf given, there might be warnings on the first few lines

token = outputParts[len(outputParts)-1]
return token, nil
return string(bytes.TrimSpace(tokenBuf.Bytes())), nil
}

// ImportK0smotrtonImages imports
Expand Down

0 comments on commit 0028231

Please sign in to comment.