Skip to content

Commit 615189c

Browse files
authored
Merge pull request #37 from KestrelAI/increase-channel-buffers
increase channel buffer sizes to prevent resource drops during initial sync
2 parents 64b9374 + daad7d3 commit 615189c

1 file changed

Lines changed: 24 additions & 26 deletions

File tree

pkg/client/stream_client.go

Lines changed: 24 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -636,20 +636,22 @@ func (s *StreamClient) StartOperator(ctx context.Context) error {
636636
}
637637

638638
// Set up workload, namespace, network policy, service, and authorization policy ingestion channels
639-
workloadChan := make(chan *v1.Workload, 1000)
640-
namespaceChan := make(chan *v1.Namespace, 100)
641-
networkPolicyChan := make(chan *v1.NetworkPolicy, 100)
642-
serviceChan := make(chan *v1.Service, 100)
643-
authorizationPolicyChan := make(chan *v1.AuthorizationPolicy, 100)
644-
podChan := make(chan *v1.Pod, 2000) // Larger buffer for pods
645-
nodeChan := make(chan *v1.Node, 100)
639+
// Buffers are sized generously to survive the initial-sync burst when all ingesters
640+
// flood simultaneously and the single consumer goroutine can't drain fast enough.
641+
workloadChan := make(chan *v1.Workload, 5000)
642+
namespaceChan := make(chan *v1.Namespace, 500)
643+
networkPolicyChan := make(chan *v1.NetworkPolicy, 500)
644+
serviceChan := make(chan *v1.Service, 2000)
645+
authorizationPolicyChan := make(chan *v1.AuthorizationPolicy, 500)
646+
podChan := make(chan *v1.Pod, 10000)
647+
nodeChan := make(chan *v1.Node, 500)
646648

647649
// Set up incident detection channels
648-
eventChan := make(chan *v1.KubernetesEvent, 500) // Kubernetes events
649-
podStatusChan := make(chan *v1.PodStatusChange, 500) // Pod status changes
650-
nodeConditionChan := make(chan *v1.NodeConditionChange, 100) // Node condition changes
651-
rolloutStatusChan := make(chan *v1.WorkloadRolloutStatus, 200) // Workload rollout status
652-
podLogsChan := make(chan *v1.PodLogs, 1000) // Pod logs (larger buffer for log batches)
650+
eventChan := make(chan *v1.KubernetesEvent, 2000)
651+
podStatusChan := make(chan *v1.PodStatusChange, 2000)
652+
nodeConditionChan := make(chan *v1.NodeConditionChange, 500)
653+
rolloutStatusChan := make(chan *v1.WorkloadRolloutStatus, 1000)
654+
podLogsChan := make(chan *v1.PodLogs, 2000)
653655

654656
// Create a new stream service client
655657
streamClient := v1.NewStreamServiceClient(s.Client)
@@ -751,11 +753,13 @@ func (s *StreamClient) StartOperator(ctx context.Context) error {
751753
return err
752754
}
753755

754-
podLogStreamer, err := ingestion.NewPodLogStreamer(s.Logger, podLogsChan)
755-
if err != nil {
756-
s.Logger.Error("Failed to create pod log streamer", zap.Error(err))
757-
return err
758-
}
756+
// Pod log streaming is disabled — kept for future use.
757+
// podLogStreamer, err := ingestion.NewPodLogStreamer(s.Logger, podLogsChan)
758+
// if err != nil {
759+
// s.Logger.Error("Failed to create pod log streamer", zap.Error(err))
760+
// return err
761+
// }
762+
_ = podLogsChan
759763

760764
s.Logger.Info("All ingesters created successfully for this connection")
761765

@@ -920,15 +924,9 @@ func (s *StreamClient) StartOperator(ctx context.Context) error {
920924
}
921925
}()
922926

923-
// Pod log streamer
924-
podLogsCtx, podLogsCancel := context.WithCancel(ctx)
925-
defer podLogsCancel()
926-
go func() {
927-
if err := podLogStreamer.StartSync(podLogsCtx, podLogsSyncDone); err != nil {
928-
s.Logger.Error("Pod log streamer failed", zap.Error(err))
929-
podLogsSyncDone <- err
930-
}
931-
}()
927+
// Pod log streaming is disabled — skip starting the streamer.
928+
// Signal sync done immediately so the wait below doesn't block.
929+
podLogsSyncDone <- nil
932930

933931
// Wait for all ingesters to complete their initial sync
934932
s.Logger.Info("Waiting for initial inventory sync to complete...")

0 commit comments

Comments
 (0)