Skip to content

Commit

Permalink
fix(sinker): fix active sink not updating (#2220)
Browse files Browse the repository at this point in the history
Signed-off-by: Luiz Pegoraro <luiz.pegoraro@encora.com>
  • Loading branch information
lpegoraro authored Feb 15, 2023
1 parent cf0df09 commit 3b72413
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions sinker/otel/bridgeservice/bridge.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,7 @@ func (bs *SinkerOtelBridgeService) NotifyActiveSink(ctx context.Context, mfOwner
bs.logger.Error("unable to retrieve the sink config", zap.Error(err))
return err
}
// only updates sink state if status Idle or Unknown
if cfgRepo.State == config.Idle || cfgRepo.State == config.Unknown {
if cfgRepo.State == config.Idle || cfgRepo.State == config.Unknown || cfgRepo.State == config.Active {
err = cfgRepo.State.SetFromString(newState)
if err != nil {
bs.logger.Error("unable to set state", zap.String("new_state", newState), zap.Error(err))
Expand All @@ -54,17 +53,18 @@ func (bs *SinkerOtelBridgeService) NotifyActiveSink(ctx context.Context, mfOwner
bs.logger.Error("error during update sink cache", zap.String("sinkId", sinkId), zap.Error(err))
return err
}
if cfgRepo.State == config.Active {
cfgRepo.LastRemoteWrite = time.Now()
bs.logger.Info("sink is already active, skipping")
err = bs.sinkerCache.AddActivity(mfOwnerId, sinkId)
if err != nil {
bs.logger.Error("error during update last remote write", zap.String("sinkId", sinkId), zap.Error(err))
return err
}
}
bs.logger.Info("notified active sink", zap.String("sinkID", sinkId), zap.String("newState", newState))
} else if cfgRepo.State == config.Error {
cfgRepo.Msg = message
} else if cfgRepo.State == config.Active {
cfgRepo.LastRemoteWrite = time.Now()
bs.logger.Info("sink is already active, skipping")
err = bs.sinkerCache.AddActivity(mfOwnerId, sinkId)
if err != nil {
bs.logger.Error("error during update last remote write", zap.String("sinkId", sinkId), zap.Error(err))
return err
}
}

return nil
Expand Down

0 comments on commit 3b72413

Please sign in to comment.