88 "strings"
99 "time"
1010
11+ "github.com/samber/lo"
1112 corev1 "k8s.io/api/core/v1"
1213 metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
1314 "k8s.io/apimachinery/pkg/fields"
@@ -78,6 +79,8 @@ type Tracker struct {
7879 TrackedContainers []string
7980 LogsFromTime time.Time
8081
82+ ignoreLogs bool
83+
8184 readinessProbes map [string ]* ReadinessProbe
8285 ignoreReadinessProbeFailsByContainerName map [string ]time.Duration
8386
@@ -95,6 +98,7 @@ type Tracker struct {
9598
9699type Options struct {
97100 IgnoreReadinessProbeFailsByContainerName map [string ]time.Duration
101+ IgnoreLogs bool
98102}
99103
100104func NewTracker (name , namespace string , kube kubernetes.Interface , opts Options ) * Tracker {
@@ -122,6 +126,8 @@ func NewTracker(name, namespace string, kube kubernetes.Interface, opts Options)
122126 ContainerTrackerStateChanges : make (map [string ]chan tracker.TrackerState ),
123127 LogsFromTime : time.Time {},
124128
129+ ignoreLogs : opts .IgnoreLogs ,
130+
125131 readinessProbes : make (map [string ]* ReadinessProbe ),
126132 ignoreReadinessProbeFailsByContainerName : opts .IgnoreReadinessProbeFailsByContainerName ,
127133
@@ -392,7 +398,7 @@ func (pod *Tracker) handleContainersState(object *corev1.Pod) error {
392398 for _ , cs := range allContainerStatuses {
393399 if cs .State .Running != nil || cs .State .Terminated != nil {
394400 oldState := pod .ContainerTrackerStates [cs .Name ]
395- newState := tracker .FollowingContainerLogs
401+ newState := lo . Ternary ( pod . ignoreLogs , tracker .ContainerTrackerDone , tracker . FollowingContainerLogs )
396402
397403 if oldState != newState {
398404 pod .ContainerTrackerStates [cs .Name ] = newState
@@ -409,6 +415,10 @@ func (pod *Tracker) handleContainersState(object *corev1.Pod) error {
409415}
410416
411417func (pod * Tracker ) followContainerLogs (ctx context.Context , containerName string ) error {
418+ if pod .ignoreLogs {
419+ return nil
420+ }
421+
412422 logOpts := & corev1.PodLogOptions {
413423 Container : containerName ,
414424 Timestamps : true ,
0 commit comments