Skip to content

Commit

Permalink
fix(Hotfix): Fixed bug when no settings was in exclude directive
Browse files Browse the repository at this point in the history
  • Loading branch information
dfradehubs committed Nov 6, 2024
1 parent acee7bd commit e9eeba0
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 6 deletions.
31 changes: 26 additions & 5 deletions internal/elasticsearch/elasticsearch.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,19 @@ func updateClusterSettings(ctx *v1alpha1.Context, es *elasticsearch.Client, node
}

// Check current exclude IPs

currentExcludes, ok := currentSettings.Persistent["cluster"].(map[string]interface{})["routing"].(map[string]interface{})["allocation"].(map[string]interface{})["exclude"].(map[string]interface{})["_name"].(string)

currentExcludes := ""
ok := true
if cluster, ok := currentSettings.Persistent["cluster"].(map[string]interface{}); ok {
if routing, ok := cluster["routing"].(map[string]interface{}); ok {
if allocation, ok := routing["allocation"].(map[string]interface{}); ok {
if exclude, ok := allocation["exclude"].(map[string]interface{}); ok {
if name, ok := exclude["_name"].(string); ok {
currentExcludes = name
}
}
}
}
}
if ctx.Config.Autoscaler.DebugMode {
log.Printf("Debug mode enabled. Current nodes in exclude settings elasticsearch: %s", string(currentExcludes))
}
Expand Down Expand Up @@ -244,8 +254,19 @@ func ClearElasticsearchClusterSettings(ctx *v1alpha1.Context, nodeName string) e
}

// Get current excluded Names
currentExcludes, ok := currentSettings.Persistent["cluster"].(map[string]interface{})["routing"].(map[string]interface{})["allocation"].(map[string]interface{})["exclude"].(map[string]interface{})["_name"].(string)

currentExcludes := ""
ok := true
if cluster, ok := currentSettings.Persistent["cluster"].(map[string]interface{}); ok {
if routing, ok := cluster["routing"].(map[string]interface{}); ok {
if allocation, ok := routing["allocation"].(map[string]interface{}); ok {
if exclude, ok := allocation["exclude"].(map[string]interface{}); ok {
if name, ok := exclude["_name"].(string); ok {
currentExcludes = name
}
}
}
}
}
if ctx.Config.Autoscaler.DebugMode {
log.Printf("Debug mode enabled. Current nodes in exclude settings elasticsearch: %s", string(currentExcludes))
}
Expand Down
3 changes: 2 additions & 1 deletion internal/google/mig.go
Original file line number Diff line number Diff line change
Expand Up @@ -136,8 +136,9 @@ func RemoveNodeFromMIG(ctx *v1alpha1.Context) (int32, int32, string, error) {
// Wait 90 seconds until instance is fully deleted
// Google Cloud has a deletion timeout of 90 seconds max
if !ctx.Config.Autoscaler.DebugMode {
log.Printf("Debug mode enabled. Skipping 90 seconds timeout until instance deletion")
time.Sleep(90 * time.Second)
} else {
log.Printf("Debug mode enabled. Skipping 90 seconds timeout until instance deletion")
}

// Chech if elasticsearch is defined in the target
Expand Down

0 comments on commit e9eeba0

Please sign in to comment.