Skip to content
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
57 changes: 32 additions & 25 deletions cmd/icingadb/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -169,32 +169,34 @@ func run() int {
sig := make(chan os.Signal, 1)
signal.Notify(sig, os.Interrupt, syscall.SIGTERM, syscall.SIGHUP)

{
var extraStages map[string]history.StageFunc
if cfg := cmd.Config.Notifications; cfg.Url != "" {
logger.Info("Starting Icinga Notifications source")

notificationsSource, err := notifications.NewNotificationsClient(
ctx,
db,
rc,
logs.GetChildLogger("notifications"),
cfg)
if err != nil {
logger.Fatalw("Can't create Icinga Notifications client from config", zap.Error(err))
}

extraStages = notificationsSource.SyncExtraStages()
var notificationsSource *notifications.Client
if cfg := cmd.Config.Notifications; cfg.Url != "" {
logger.Info("Starting Icinga Notifications source")

notificationsSource, err = notifications.NewNotificationsClient(
db,
rc,
logs.GetChildLogger("notifications"),
cfg)
if err != nil {
logger.Fatalw("Can't create Icinga Notifications client from config", zap.Error(err))
}
}

go func() {
logger.Info("Starting history sync")
go func() {
logger.Info("Starting history sync")

if err := hs.Sync(ctx, extraStages); err != nil && !utils.IsContextCanceled(err) {
logger.Fatalf("%+v", err)
}
}()
}
var extraStages map[string]history.StageFunc
//if notificationsSource != nil {
// We don't need to subscribe to the history pipelines anymore, so disabling them temporarily until
// someone works on implementing https://github.com/Icinga/icinga-notifications/issues/409.
//extraStages = notificationsSource.SyncExtraStages(ctx)
//}

if err := hs.Sync(ctx, extraStages); err != nil && !utils.IsContextCanceled(err) {
logger.Fatalf("%+v", err)
}
}()

// Main loop
for {
Expand Down Expand Up @@ -325,7 +327,7 @@ func run() int {

logger.Info("Starting config runtime updates sync")

return rt.Sync(synctx, v1.ConfigFactories, runtimeConfigUpdateStreams, false)
return rt.Sync(synctx, v1.ConfigFactories, runtimeConfigUpdateStreams)
})

g.Go(func() error {
Expand All @@ -337,7 +339,12 @@ func run() int {

logger.Info("Starting state runtime updates sync")

return rt.Sync(synctx, v1.StateFactories, runtimeStateUpdateStreams, true)
runtimeUpdatesOpts := []icingadb.RUOption{icingadb.WithAllowParallel()}
if notificationsSource != nil {
runtimeUpdatesOpts = append(runtimeUpdatesOpts, icingadb.WithRUUpsert(notificationsSource.Submit))
}

return rt.Sync(synctx, v1.StateFactories, runtimeStateUpdateStreams, runtimeUpdatesOpts...)
})

g.Go(func() error {
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ require (
github.com/goccy/go-yaml v1.13.0
github.com/google/go-cmp v0.7.0
github.com/google/uuid v1.6.0
github.com/icinga/icinga-go-library v0.9.1-0.20260623130323-faef23cbd4c9
github.com/icinga/icinga-go-library v0.9.1-0.20260630080726-15d47aff49f8
github.com/jessevdk/go-flags v1.6.1
github.com/jmoiron/sqlx v1.4.0
github.com/mattn/go-sqlite3 v1.14.47
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8=
github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU=
github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/icinga/icinga-go-library v0.9.1-0.20260623130323-faef23cbd4c9 h1:HyeACIYSpROzA9bUghELjzsCwnHzM48M6oD2zgKMlfA=
github.com/icinga/icinga-go-library v0.9.1-0.20260623130323-faef23cbd4c9/go.mod h1:XFsuZEn2hrE3YXQ3NHqnI2UkjdZgJJWb/7D/+VH6MsE=
github.com/icinga/icinga-go-library v0.9.1-0.20260630080726-15d47aff49f8 h1:YZ+N5qKN9tB6JPUno3oVcVE9TAayAIOZAG8hmVkgYBQ=
github.com/icinga/icinga-go-library v0.9.1-0.20260630080726-15d47aff49f8/go.mod h1:XFsuZEn2hrE3YXQ3NHqnI2UkjdZgJJWb/7D/+VH6MsE=
github.com/jessevdk/go-flags v1.6.1 h1:Cvu5U8UGrLay1rZfv/zP7iLpSHGUZ/Ou68T0iX1bBK4=
github.com/jessevdk/go-flags v1.6.1/go.mod h1:Mk8T1hIAWpOiJiHa9rJASDK2UGWji0EuPGBnNLMooyc=
github.com/jmoiron/sqlx v1.4.0 h1:1PLqN7S1UYp5t4SrVVnt4nUVNemrDAtxlulVe+Qgm3o=
Expand Down
Loading
Loading