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
This commit is contained in:
parent
11cc797922
commit
c27410ea32
@ -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…
Reference in New Issue
Block a user