Skip to content

Commit 6e0276f

Browse files
fix: move partition readiness check after service check
This commit moves the partition readiness check after the service and lifecycler readiness checks. It does this because the partition readiness check cannot pass until the consumer is running, and the consumer.Run() goroutine is not started until running() is called. That means it makes sense to check the service state and the lifecycler before checking the partitions.
1 parent 6308773 commit 6e0276f

File tree

1 file changed

+7
-14
lines changed

1 file changed

+7
-14
lines changed

pkg/limits/service.go

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -189,18 +189,12 @@ func (s *Service) ExceedsLimits(
189189
}
190190

191191
func (s *Service) CheckReady(ctx context.Context) error {
192-
serviceReady := func() error {
193-
if s.State() != services.Running {
194-
return fmt.Errorf("service is not running: %v", s.State())
195-
}
196-
197-
if err := s.lifecycler.CheckReady(ctx); err != nil {
198-
return fmt.Errorf("lifecycler not ready: %w", err)
199-
}
200-
201-
return nil
192+
if s.State() != services.Running {
193+
return fmt.Errorf("service is not running: %v", s.State())
194+
}
195+
if err := s.lifecycler.CheckReady(ctx); err != nil {
196+
return fmt.Errorf("lifecycler not ready: %w", err)
202197
}
203-
204198
// Check if the partitions assignment and replay
205199
// are complete on the service startup only.
206200
if !s.initialized.Load() {
@@ -211,7 +205,7 @@ func (s *Service) CheckReady(ctx context.Context) error {
211205
s.initialized.Store(true)
212206

213207
level.Warn(s.logger).Log("msg", "no partitions assigned after max retries, going ready")
214-
return serviceReady()
208+
return nil
215209
}
216210

217211
s.assigmentRetries.Inc()
@@ -229,8 +223,7 @@ func (s *Service) CheckReady(ctx context.Context) error {
229223
// declare the service initialized.
230224
s.initialized.Store(true)
231225
}
232-
233-
return serviceReady()
226+
return nil
234227
}
235228

236229
// starting implements the Service interface's starting method.

0 commit comments

Comments
 (0)