fix: ignore existing target status when adding new targets (#17250)

This commit is contained in:
jiuker
2023-05-25 13:57:37 +08:00
committed by GitHub
parent 62df731006
commit d749aaab69
5 changed files with 61 additions and 17 deletions

View File

@@ -58,13 +58,24 @@ func TestSubSysNotificationTargets(ctx context.Context, cfg config.Config, subSy
defer target.Close()
}
tgts, ok := ctx.Value(config.ContextKeyForTargetFromConfig).(map[string]bool)
if !ok {
tgts = make(map[string]bool)
}
for _, target := range targetList {
yes, err := target.IsActive()
if err == nil && !yes {
err = ErrTargetsOffline
}
if err != nil {
return fmt.Errorf("error (%s): %w", target.ID(), err)
if tgts[target.ID().ID] {
// When target set should be online
yes, err := target.IsActive()
if err == nil && !yes {
err = ErrTargetsOffline
}
if err != nil {
return fmt.Errorf("error (%s): %w", target.ID(), err)
}
} else {
// Just for call init.
// Ignore target is online or offline
_, _ = target.IsActive()
}
}