createCluster: Fix getHostIP edge cases

- sometimes, the exec process returns a non-zero exit code but still has
logs which are helpful for us
- sometimes everything fails and we should gracefully handle this
pull/372/head v3.1.2
iwilltry42 4 years ago
parent 11cc797922
commit c27410ea32
No known key found for this signature in database
GPG Key ID: 7BA57AD1CFF16110
  1. 10
      pkg/cluster/host.go
  2. 2
      pkg/runtimes/docker/node.go

@ -80,6 +80,16 @@ func resolveHostnameFromInside(ctx context.Context, rtime rt.Runtime, node *k3d.
submatches := map[string]string{}
scanner := bufio.NewScanner(logreader)
if scanner == nil {
if execErr != nil {
return nil, execErr
}
return nil, fmt.Errorf("Failed to scan logs for host IP")
}
if scanner != nil && execErr != nil {
log.Debugln("Exec Process Failed, but we still got logs, so we're at least trying to get the IP from there...")
log.Tracef("-> Exec Process Error was: %+v", execErr)
}
for scanner.Scan() {
log.Tracef("Scanning Log Line '%s'", scanner.Text())
match := nsLookupAddressRegexp.FindStringSubmatch(scanner.Text())

@ -308,7 +308,7 @@ func (d Docker) GetNodeLogs(ctx context.Context, node *k3d.Node, since time.Time
func (d Docker) ExecInNodeGetLogs(ctx context.Context, node *k3d.Node, cmd []string) (*bufio.Reader, error) {
resp, err := executeInNode(ctx, node, cmd)
if err != nil {
return nil, err
return resp.Reader, err
}
return resp.Reader, nil
}

Loading…
Cancel
Save