do not use logreader if it doesn't exist

pull/754/head
iwilltry42 3 years ago
parent 7d4d63f18b
commit 1e9c20e0a9
No known key found for this signature in database
GPG Key ID: 7BA57AD1CFF16110
  1. 12
      pkg/client/cluster.go

@ -994,11 +994,15 @@ func corednsAddHost(ctx context.Context, runtime k3drt.Runtime, cluster *k3d.Clu
break
} else {
msg := fmt.Sprintf("error patching the CoreDNS ConfigMap to include entry '%s': %+v", hostsEntry, err)
readlogs, err := ioutil.ReadAll(logreader)
if err != nil {
l.Log().Debugf("error reading the logs from failed CoreDNS patch exec process in node %s: %v", node.Name, err)
if logreader != nil {
readlogs, err := ioutil.ReadAll(logreader)
if err != nil {
l.Log().Debugf("error reading the logs from failed CoreDNS patch exec process in node %s: %v", node.Name, err)
} else {
msg += fmt.Sprintf("\nLogs: %s", string(readlogs))
}
} else {
msg += fmt.Sprintf("\nLogs: %s", string(readlogs))
l.Log().Debugf("no logreader returned for exec process")
}
l.Log().Debugln(msg)
}

Loading…
Cancel
Save