|
4 | 4 | "context" |
5 | 5 | "github.com/loft-sh/devspace/pkg/util/scanner" |
6 | 6 | "github.com/loft-sh/devspace/pkg/util/stringutil" |
| 7 | + "github.com/sirupsen/logrus" |
7 | 8 | metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" |
8 | 9 | "sort" |
9 | 10 | "strings" |
@@ -94,22 +95,24 @@ func (u *PodInfoPrinter) PrintPodInfo(client kubectl.Client, pod *v1.Pod, log lo |
94 | 95 |
|
95 | 96 | if time.Since(u.lastWarning) > time.Second*10 { |
96 | 97 | // show init container logs if init container is running |
97 | | - for _, initContainer := range pod.Status.InitContainerStatuses { |
98 | | - if !stringutil.Contains(u.printedInitContainers, initContainer.Name) && initContainer.State.Running != nil { |
99 | | - // show logs of this currently running init container |
100 | | - log.Infof("Printing init container logs of pod %s", pod.Name) |
101 | | - reader, err := client.Logs(context.TODO(), pod.Namespace, pod.Name, initContainer.Name, false, nil, true) |
102 | | - if err != nil { |
103 | | - log.Warnf("Error reading init container logs: %v", err) |
104 | | - } else { |
105 | | - scanner := scanner.NewScanner(reader) |
106 | | - for scanner.Scan() { |
107 | | - log.Info(scanner.Text()) |
| 98 | + if log.GetLevel() == logrus.DebugLevel { |
| 99 | + for _, initContainer := range pod.Status.InitContainerStatuses { |
| 100 | + if !stringutil.Contains(u.printedInitContainers, initContainer.Name) && initContainer.State.Running != nil { |
| 101 | + // show logs of this currently running init container |
| 102 | + log.Infof("Printing init container logs of pod %s", pod.Name) |
| 103 | + reader, err := client.Logs(context.TODO(), pod.Namespace, pod.Name, initContainer.Name, false, nil, true) |
| 104 | + if err != nil { |
| 105 | + log.Warnf("Error reading init container logs: %v", err) |
| 106 | + } else { |
| 107 | + scanner := scanner.NewScanner(reader) |
| 108 | + for scanner.Scan() { |
| 109 | + log.Info(scanner.Text()) |
| 110 | + } |
108 | 111 | } |
109 | | - } |
110 | 112 |
|
111 | | - u.printedInitContainers = append(u.printedInitContainers, initContainer.Name) |
112 | | - return |
| 113 | + u.printedInitContainers = append(u.printedInitContainers, initContainer.Name) |
| 114 | + return |
| 115 | + } |
113 | 116 | } |
114 | 117 | } |
115 | 118 |
|
|
0 commit comments