Skip to content

Use fallback config only if supplied config is blank #592

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

Merged
merged 1 commit into from
Nov 10, 2017
Merged
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
28 changes: 17 additions & 11 deletions pkg/alertmanager/multitenant.go
Original file line number Diff line number Diff line change
Expand Up @@ -430,19 +430,25 @@ func copyConfig(config *amconfig.Config) (*amconfig.Config, error) {
// creating an alertmanager if it doesn't already exist.
func (am *MultitenantAlertmanager) setConfig(userID string, config configs.Config) error {
_, hasExisting := am.alertmanagers[userID]
amConfig, err := configs_client.AlertmanagerConfigFromConfig(config)
if err != nil && (hasExisting || am.fallbackConfig == nil) {
// XXX: This means that if a user has a working configuration and
// they submit a broken one, we'll keep processing the last known
// working configuration, and they'll never know.
// TODO: Provide a way of communicating this to the user and for removing
// Alertmanager instances.
return fmt.Errorf("invalid Cortex configuration for %v: %v", userID, err)
}
var amConfig *amconfig.Config
var err error

if amConfig == nil && am.fallbackConfig != nil {
log.Infof("invalid Cortex configuration; using fallback for %v", userID)
if config.AlertmanagerConfig == "" {
if am.fallbackConfig == nil {
return fmt.Errorf("blank Alertmanager configuration for %v", userID)
}
log.Infof("blank Alertmanager configuration; using fallback for %v", userID)
amConfig = am.fallbackConfig
} else {
amConfig, err = configs_client.AlertmanagerConfigFromConfig(config)
if err != nil && hasExisting {
// XXX: This means that if a user has a working configuration and
// they submit a broken one, we'll keep processing the last known
// working configuration, and they'll never know.
// TODO: Provide a way of communicating this to the user and for removing
// Alertmanager instances.
return fmt.Errorf("invalid Cortex configuration for %v: %v", userID, err)
}
}

if amConfig, err = am.transformConfig(userID, amConfig); err != nil {
Expand Down