more login debug output in tests

Signed-off-by: Kristoffer Dalby <kristoffer@tailscale.com>
This commit is contained in:
Kristoffer Dalby 2025-01-17 16:59:37 +01:00
parent 609203a9b9
commit 9097d57eea
No known key found for this signature in database
2 changed files with 10 additions and 6 deletions

View file

@ -222,11 +222,12 @@ func (s *AuthWebFlowScenario) CreateHeadscaleEnv(
func (s *AuthWebFlowScenario) runTailscaleUp( func (s *AuthWebFlowScenario) runTailscaleUp(
userStr, loginServer string, userStr, loginServer string,
) error { ) error {
log.Printf("running tailscale up for user %s", userStr) log.Printf("running tailscale up for user %q", userStr)
if user, ok := s.users[userStr]; ok { if user, ok := s.users[userStr]; ok {
for _, client := range user.Clients { for _, client := range user.Clients {
c := client c := client
user.joinWaitGroup.Go(func() error { user.joinWaitGroup.Go(func() error {
log.Printf("logging %q into %q", c.Hostname(), loginServer)
loginURL, err := c.LoginWithURL(loginServer) loginURL, err := c.LoginWithURL(loginServer)
if err != nil { if err != nil {
log.Printf("failed to run tailscale up (%s): %s", c.Hostname(), err) log.Printf("failed to run tailscale up (%s): %s", c.Hostname(), err)

View file

@ -466,7 +466,7 @@ func (t *TailscaleInContainer) Login(
// This login mechanism uses web + command line flow for authentication. // This login mechanism uses web + command line flow for authentication.
func (t *TailscaleInContainer) LoginWithURL( func (t *TailscaleInContainer) LoginWithURL(
loginServer string, loginServer string,
) (*url.URL, error) { ) (loginURL *url.URL, err error) {
command := []string{ command := []string{
"tailscale", "tailscale",
"up", "up",
@ -480,6 +480,12 @@ func (t *TailscaleInContainer) LoginWithURL(
return nil, errTailscaleCannotUpWithoutAuthkey return nil, errTailscaleCannotUpWithoutAuthkey
} }
defer func() {
if err != nil {
log.Printf("join command: %q", strings.Join(command, " "))
}
}()
urlStr := strings.ReplaceAll(stdout+stderr, "\nTo authenticate, visit:\n\n\t", "") urlStr := strings.ReplaceAll(stdout+stderr, "\nTo authenticate, visit:\n\n\t", "")
urlStr = strings.TrimSpace(urlStr) urlStr = strings.TrimSpace(urlStr)
@ -488,11 +494,8 @@ func (t *TailscaleInContainer) LoginWithURL(
} }
// parse URL // parse URL
loginURL, err := url.Parse(urlStr) loginURL, err = url.Parse(urlStr)
if err != nil { if err != nil {
log.Printf("Could not parse login URL: %s", err)
log.Printf("Original join command result: %s", stderr)
return nil, err return nil, err
} }