Skip to content
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

fix(service_intergration): empty user config to API convertion #526

Merged
merged 1 commit into from
Nov 10, 2023
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
4 changes: 2 additions & 2 deletions controllers/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ func getSecretPrefix(o objWithSecret) string {
// userConfigurationToAPI converts user config into a map
func userConfigurationToAPI(c any, groups ...string) (map[string]any, error) {
if c == nil || (reflect.ValueOf(c).Kind() == reflect.Ptr && reflect.ValueOf(c).IsNil()) {
return nil, nil
return map[string]any{}, nil
}

o := &sheriff.Options{
Expand All @@ -192,7 +192,7 @@ func userConfigurationToAPI(c any, groups ...string) (map[string]any, error) {
if !ok {
// It is an empty pointer
// sheriff just returned the very same object
return nil, nil
return map[string]any{}, nil
}

return m, nil
Expand Down
9 changes: 8 additions & 1 deletion controllers/serviceintegration_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ package controllers
import (
"context"
"fmt"
"slices"
"strconv"
"strings"

Expand Down Expand Up @@ -77,6 +78,12 @@ func (h ServiceIntegrationHandler) createOrUpdate(ctx context.Context, avn *aive

reason = "Created"
} else {
// Not all service integrations have user_config available; skip the update if user_config is unavailable.
withUserConfig := []string{"clickhouse_kafka", "clickhouse_postgresql", "datadog", "kafka_connect", "kafka_logs", "kafka_mirrormaker", "logs", "metrics", "external_aws_cloudwatch_metrics"}
if !slices.Contains(withUserConfig, si.Spec.IntegrationType) {
return nil
}

userConfigMap, err := UpdateUserConfiguration(userConfig)
if err != nil {
return err
Expand All @@ -92,7 +99,7 @@ func (h ServiceIntegrationHandler) createOrUpdate(ctx context.Context, avn *aive
)
reason = "Updated"
if err != nil {
if strings.Contains(err.Error(), "user config not changed") {
if strings.Contains(strings.ToLower(err.Error()), "user config not changed") {
return nil
}
return err
Expand Down
Loading