in internal/agentdiag.go [87:111]
func diagnosticForAgentPod(nsn types.NamespacedName, k *Kubectl, outputFile string, zipFile *archive.ZipFile, verbose bool) bool {
logger.Printf("Extracting agent diagnostics for %s", nsn)
if err := k.Exec(nsn, agentContainerName, "elastic-agent", "diagnostics", "collect", "-f", outputFile); err != nil {
zipFile.AddError(fmt.Errorf("while extracting agent diagnostics: %w", err))
return false
}
reader, err := k.Copy(nsn, agentContainerName, outputFile, zipFile.AddError)
if err != nil {
zipFile.AddError(err)
return true
}
source := extraction.RemoteSource{
Namespace: nsn.Namespace,
PodName: nsn.Name, // no separate diagnostic Pod in this case
Typ: "agent",
ResourceName: nsn.Name,
PodOutputDir: "/",
}
if err := extraction.UntarIntoZip(reader, source, zipFile, verbose); err != nil {
zipFile.AddError(fmt.Errorf("while copying diagnostic data from Pod %s into diagnostic archive: %w", nsn, err))
}
return true
}