MSP-6703 update waitForLeaderTimeout
This commit is contained in:
1 parent
35e15b7ae1
commit
960b87d86d
1 file changed
+22
-2
@@ -27,7 +27,8 @@ import (
|
||||
)
|
||||
|
||||
const (
|
||||
waitForLeaderTimeout = 30 * time.Second
|
||||
waitForLeaderTimeout = 180 * time.Second
|
||||
waitingLogsTimeout = 30 * time.Second
|
||||
)
|
||||
|
||||
type Service struct {
|
||||
@@ -98,8 +99,11 @@ func (s *Service) Run(ctx context.Context) error {
|
||||
}()
|
||||
time.Sleep(1 * time.Second) // optimistically wait for store initialization
|
||||
|
||||
s.logger.Debug(ctx, fmt.Sprintf("waiting for cluster startup for %s...", waitForLeaderTimeout))
|
||||
waitingCtx, stopWaiting := context.WithCancel(ctx)
|
||||
go s.writeWaitingLogs(waitingCtx)
|
||||
|
||||
err := s.rqlite.WaitForLeader(waitForLeaderTimeout)
|
||||
stopWaiting()
|
||||
if err != nil {
|
||||
return errors.WithMessage(err, "wait for leader")
|
||||
}
|
||||
@@ -230,3 +234,19 @@ func internalClientCredentials(cfg conf.Local) (*httpcli.BasicAuth, error) {
|
||||
}
|
||||
return nil, errors.Errorf("internal client credential '%s' not found", cfg.InternalClientCredential)
|
||||
}
|
||||
|
||||
func (s *Service) writeWaitingLogs(ctx context.Context) {
|
||||
s.logger.Debug(ctx, fmt.Sprintf("waiting for cluster startup for %s...", waitForLeaderTimeout))
|
||||
|
||||
t := time.NewTicker(waitingLogsTimeout)
|
||||
defer t.Stop()
|
||||
|
||||
for {
|
||||
select {
|
||||
case <-ctx.Done():
|
||||
return
|
||||
case <-t.C:
|
||||
s.logger.Debug(ctx, fmt.Sprintf("continue waiting for cluster startup for %s...", waitForLeaderTimeout))
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user