Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Fix] Sinker state checker for otel #1958

Merged
merged 9 commits into from
Nov 2, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions maestro/config/config_builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
"fmt"
"github.com/ns1labs/orb/pkg/errors"
"gopkg.in/yaml.v2"
"strconv"
"strings"
)

Expand Down Expand Up @@ -180,9 +179,6 @@ func GetDeploymentJson(sinkId, sinkUrl, sinkUsername, sinkPassword string) (stri

// ReturnConfigYamlFromSink this is the main method, which will generate the YAML file from the
func ReturnConfigYamlFromSink(_ context.Context, kafkaUrlConfig, sinkId, sinkUrl, sinkUsername, sinkPassword string) (string, error) {
if _, err := strconv.Atoi(sinkUsername); err != nil {
sinkUsername = "#$#" + sinkUsername
}
config := OtelConfigFile{
Receivers: Receivers{
Kafka: KafkaReceiver{
Expand Down
23 changes: 15 additions & 8 deletions sinker/config_state_check.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,21 @@ func (svc *SinkerService) checkState(_ time.Time) {
if cfg.LastRemoteWrite.Add(DefaultTimeout).Before(time.Now()) {
svc.logger.Info("opentelemetry:", zap.String("otel", cfg.Opentelemetry))
if cfg.State == config.Active {
err := cfg.State.SetFromString("idle")
if err != nil {
svc.logger.Error("error updating sink config cache", zap.Error(err))
return
}
if err := svc.sinkerCache.Edit(cfg); err != nil {
svc.logger.Error("error updating sink config cache", zap.Error(err))
return
if cfg.Opentelemetry == "enabled" {
err := cfg.State.SetFromString("idle")
if err != nil {
svc.logger.Error("error updating sink state otel", zap.Error(err))
return
}
if err := svc.sinkerCache.Edit(cfg); err != nil {
svc.logger.Error("error updating sink config cache otel", zap.Error(err))
return
}
} else {
if err := svc.sinkerCache.Remove(cfg.OwnerID, cfg.SinkID); err != nil {
svc.logger.Error("error updating sink config cache", zap.Error(err))
return
}
}
}
}
Expand Down