Skip to content

Commit

Permalink
Fail agent when no mongodb can be reached in Kerberos Factory deployment
Browse files Browse the repository at this point in the history
  • Loading branch information
cedricve committed Jul 12, 2023
1 parent 470f8f1 commit 4c03132
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions machinery/src/components/Config.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,20 +84,29 @@ func OpenConfig(configDirectory string, configuration *models.Configuration) {
collection := db.Collection("configuration")

var globalConfig models.Config
err := collection.FindOne(context.Background(), bson.M{
res := collection.FindOne(context.Background(), bson.M{
"type": "global",
}).Decode(&globalConfig)
})

if res.Err() != nil {
log.Log.Error("Could not find global configuration, using default configuration.")
}
err := res.Decode(&globalConfig)
if err != nil {
log.Log.Error("Could not find global configuration, using default configuration.")
}
configuration.GlobalConfig = globalConfig

var customConfig models.Config
deploymentName := os.Getenv("DEPLOYMENT_NAME")
err = collection.FindOne(context.Background(), bson.M{
res = collection.FindOne(context.Background(), bson.M{
"type": "config",
"name": deploymentName,
}).Decode(&customConfig)
})
if res.Err() != nil {
log.Log.Error("Could not find configuration for " + deploymentName + ", using global configuration.")
}
err = res.Decode(&customConfig)
if err != nil {
log.Log.Error("Could not find configuration for " + deploymentName + ", using global configuration.")
}
Expand Down

0 comments on commit 4c03132

Please sign in to comment.