MCPcopy
hub / github.com/istio/istio / getLog

Function getLog

tools/bug-report/pkg/bugreport/bugreport.go:514–545  ·  view source on GitHub ↗

getLog fetches the logs for the given namespace/pod/container and returns the log text and stats for it.

(runner *kubectlcmd.Runner, resources *cluster2.Resources, config *config.BugReportConfig,
	namespace, pod, container string,
)

Source from the content-addressed store, hash-verified

512
513// getLog fetches the logs for the given namespace/pod/container and returns the log text and stats for it.
514func getLog(runner *kubectlcmd.Runner, resources *cluster2.Resources, config *config.BugReportConfig,
515 namespace, pod, container string,
516) (string, *processlog.Stats, int, error) {
517 defer logRuntime(time.Now(), "Done getting logs only for %v/%v/%v", namespace, pod, container)
518
519 log.Infof("Getting logs for %s/%s/%s...", namespace, pod, container)
520
521 var tailLines *int64
522 if config.TailLines > 0 {
523 tailLines = &config.TailLines
524 }
525 var sinceTime *time.Time
526 if config.TimeFilterApplied && !config.StartTime.IsZero() {
527 sinceTime = &config.StartTime
528 }
529
530 clog, err := runner.LogsWithOptions(namespace, pod, container, false, config.DryRun, tailLines, sinceTime)
531 if err != nil {
532 return "", nil, 0, err
533 }
534 if resources.ContainerRestarts(namespace, pod, container, common.IsCniPod(pod)) > 0 {
535 pclog, err := runner.LogsWithOptions(namespace, pod, container, true, config.DryRun, tailLines, sinceTime)
536 if err != nil {
537 return "", nil, 0, err
538 }
539 clog = "========= Previous log present (appended at the end) =========\n\n" + clog +
540 "\n\n========= Previous log =========\n\n" + pclog
541 }
542 var cstat *processlog.Stats
543 clog, cstat = processlog.Process(config, clog)
544 return clog, cstat, cstat.Importance(), nil
545}
546
547func runAnalyze(config *config.BugReportConfig, params *content.Params, analyzeTimeout time.Duration) {
548 newParam := params.SetNamespace(common.NamespaceAll)

Callers 4

getProxyLogsFunction · 0.85
getIstiodLogsFunction · 0.85
getOperatorLogsFunction · 0.85
getCniLogsFunction · 0.85

Calls 8

ImportanceMethod · 0.95
InfofFunction · 0.92
IsCniPodFunction · 0.92
ProcessFunction · 0.92
logRuntimeFunction · 0.85
NowMethod · 0.80
LogsWithOptionsMethod · 0.80
ContainerRestartsMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…