returnfmt.Errorf("failed to patch CoreDNS with network members: %w",err)
// add records for other containers in the cluster network to the CoreDNS configmap (e.g. useful for using registries from within Pods inside the cluster)
// try 3 (or K3D_DEBUG_COREDNS_RETRIES value) times, as e.g. on cluster startup it may take some time for the Configmap to be available and the server to be responsive
fori:=0;i<retries;i++{
l.Log().Debugf("Running CoreDNS patch in node %s to add %s (try %d/%d)...",node.Name,hostsEntry,i,retries)
msg:=fmt.Sprintf("error patching the CoreDNS ConfigMap to include entry '%s': %+v",hostsEntry,err)
msg:=fmt.Sprintf("(try %d/%d) error patching the CoreDNS ConfigMap to include entry '%s': %+v",i,retries,hostsEntry,err)
iflogreader!=nil{
readlogs,err:=ioutil.ReadAll(logreader)
iferr!=nil{
l.Log().Debugf("error reading the logs from failed CoreDNS patch exec process in node %s: %v",node.Name,err)
l.Log().Debugf("(try %d/%d) error reading the logs from failed CoreDNS patch exec process in node %s: %v",i,retries,node.Name,err)
}else{
msg+=fmt.Sprintf("\nLogs: %s",string(readlogs))
}
}else{
l.Log().Debugf("no logreader returned for exec process")
l.Log().Debugf("(try %d/%d) error reading the logs from failed CoreDNS patch exec process in node %s: no logreader returned for exec process",i,retries,node.Name)
}
l.Log().Debugln(msg)
}
time.Sleep(1*time.Second)
}
}
if!successInjectCoreDNSEntry{
returnfmt.Errorf("Failed to patch CoreDNS ConfigMap to include entry '%s' (see debug logs)",hostsEntry)
returnfmt.Errorf("failed to patch CoreDNS ConfigMap to include entry '%s' (%d tries, see debug logs)",hostsEntry,retries)
}
l.Log().Debugf("Successfully patched CoreDNS Configmap with record '%s'",hostsEntry)