From 5349fcbbdd29b995f9593a5a95d5242fbc3ac132 Mon Sep 17 00:00:00 2001 From: irappa-pattar Date: Tue, 23 Nov 2021 23:17:11 -0700 Subject: [PATCH 1/2] update aci plugin message bus config --- config/config.go | 31 ++++++++++++++----- config/config.json | 3 ++ config/constants.go | 6 ++++ .../helmcharts/aciplugin-config.yaml | 1 + .../aciplugin/templates/configmaps.yaml | 10 +++++- .../helmcharts/aciplugin/values.yaml | 1 + 6 files changed, 44 insertions(+), 8 deletions(-) diff --git a/config/config.go b/config/config.go index eaefb75..e35a277 100644 --- a/config/config.go +++ b/config/config.go @@ -82,6 +82,9 @@ type EventConf struct { // MessageBusConf will have configuration data of MessageBusConf type MessageBusConf struct { MessageQueueConfigFilePath string `json:"MessageQueueConfigFilePath"` // Message Queue Config File Path + MessageBusAddress string `json:"MessageBusAddress"` + MessageBusPort string `json:"MessageBusPort"` + HASet string `json:"HASet"` EmbType string `json:"MessageBusType"` EmbQueue []string `json:"MessageBusQueue"` } @@ -265,17 +268,31 @@ func checkMessageBusConf() error { if Data.MessageBusConf == nil { return fmt.Errorf("no value found for MessageBusConf") } - if _, err := os.Stat(Data.MessageBusConf.MessageQueueConfigFilePath); err != nil { - return fmt.Errorf("value check failed for MessageQueueConfigFilePath:%s with %v", Data.MessageBusConf.MessageQueueConfigFilePath, err) - } if Data.MessageBusConf.EmbType == "" { - log.Info("no value set for MessageBusType, setting default value") + log.Warn("No value set for MessageBusType, setting default value") Data.MessageBusConf.EmbType = "Kafka" } - if len(Data.MessageBusConf.EmbQueue) <= 0 { - log.Info("no value set for MessageBusQueue, setting default value") - Data.MessageBusConf.EmbQueue = []string{"REDFISH-EVENTS-TOPIC"} + if Data.MessageBusConf.EmbType == "Kafka" { + if _, err := os.Stat(Data.MessageBusConf.MessageQueueConfigFilePath); err != nil { + return fmt.Errorf("Value check failed for MessageQueueConfigFilePath:%s with %v", Data.MessageBusConf.MessageQueueConfigFilePath, err) + } + if len(Data.MessageBusConf.EmbQueue) <= 0 { + log.Warn("No value set for MessageBusQueue, setting default value") + Data.MessageBusConf.EmbQueue = []string{"REDFISH-EVENTS-TOPIC"} + } + } + if Data.MessageBusConf.EmbType == "RedisStream" { + if Data.MessageBusConf.MessageBusAddress == "" { + return fmt.Errorf("error: no value configured for MessageBusAddress") + } + if Data.MessageBusConf.MessageBusPort == "" { + return fmt.Errorf("error: no value configured for MessageBusPort") + } } + if !AllowedMessageBusTypes[Data.MessageBusConf.EmbType] { + return fmt.Errorf("error: invalid value configured for MessageBusType") + } + return nil } diff --git a/config/config.json b/config/config.json index df2f226..7c57fbc 100644 --- a/config/config.json +++ b/config/config.json @@ -48,6 +48,9 @@ }, "MessageBusConf": { "MessageQueueConfigFilePath": "", + "MessageBusAddress": "localhost", + "MessageBusPort": "6379", + "HASet": "redisSentinel", "MessageBusType": "Kafka", "MessageBusQueue": ["REDFISH-EVENTS-TOPIC"] }, diff --git a/config/constants.go b/config/constants.go index 83d72a4..5adfb7e 100644 --- a/config/constants.go +++ b/config/constants.go @@ -22,3 +22,9 @@ const ( // DefaultDBMinIdleConns - default MinIdleConns value DefaultDBMinIdleConns = 10 ) + +// AllowedMessageBusTypes is for checking for message types are allowed +var AllowedMessageBusTypes = map[string]bool{ + "Kafka": true, + "RedisStream": true, +} diff --git a/install/Kubernetes/helmcharts/aciplugin-config.yaml b/install/Kubernetes/helmcharts/aciplugin-config.yaml index 6f18352..a0df425 100755 --- a/install/Kubernetes/helmcharts/aciplugin-config.yaml +++ b/install/Kubernetes/helmcharts/aciplugin-config.yaml @@ -12,3 +12,4 @@ aciplugin: odimURL: odimUserName: odimPassword: + messageBusType: Kafka diff --git a/install/Kubernetes/helmcharts/aciplugin/templates/configmaps.yaml b/install/Kubernetes/helmcharts/aciplugin/templates/configmaps.yaml index 6cd7fa7..e98b47c 100755 --- a/install/Kubernetes/helmcharts/aciplugin/templates/configmaps.yaml +++ b/install/Kubernetes/helmcharts/aciplugin/templates/configmaps.yaml @@ -60,7 +60,15 @@ data: }, "MessageBusConf": { "MessageQueueConfigFilePath": "/etc/aciplugin_config/platformconfig.toml", - "MessageBusType": "Kafka", + {{ if eq .Values.odimra.haDeploymentEnabled false }} + "MessageBusAddress": "redis-inmemory", + "HASet": "", + {{ else }} + "MessageBusAddress": "redis-ha-inmemory", + "HASet": "redisSentinel", + {{ end }} + "MessageBusPort": 6379, + "MessageBusType": {{ .Values.aciplugin.messageBusType | quote }}, "MessageBusQueue": ["ACI-EVENTS-TOPIC"] }, "URLTranslation": { diff --git a/install/Kubernetes/helmcharts/aciplugin/values.yaml b/install/Kubernetes/helmcharts/aciplugin/values.yaml index a7779b8..0144dfe 100755 --- a/install/Kubernetes/helmcharts/aciplugin/values.yaml +++ b/install/Kubernetes/helmcharts/aciplugin/values.yaml @@ -20,3 +20,4 @@ aciplugin: odimURL: odimUserName: odimPassword: + messageBusType: Kafka From 96ec1cfcc5f950b22389e2c279d21fa82961c47c Mon Sep 17 00:00:00 2001 From: irappa-pattar Date: Tue, 23 Nov 2021 23:46:51 -0700 Subject: [PATCH 2/2] update configmap.yaml --- .../aciplugin/templates/configmaps.yaml | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/install/Kubernetes/helmcharts/aciplugin/templates/configmaps.yaml b/install/Kubernetes/helmcharts/aciplugin/templates/configmaps.yaml index e98b47c..386883c 100755 --- a/install/Kubernetes/helmcharts/aciplugin/templates/configmaps.yaml +++ b/install/Kubernetes/helmcharts/aciplugin/templates/configmaps.yaml @@ -60,16 +60,16 @@ data: }, "MessageBusConf": { "MessageQueueConfigFilePath": "/etc/aciplugin_config/platformconfig.toml", - {{ if eq .Values.odimra.haDeploymentEnabled false }} - "MessageBusAddress": "redis-inmemory", - "HASet": "", - {{ else }} - "MessageBusAddress": "redis-ha-inmemory", - "HASet": "redisSentinel", - {{ end }} - "MessageBusPort": 6379, - "MessageBusType": {{ .Values.aciplugin.messageBusType | quote }}, - "MessageBusQueue": ["ACI-EVENTS-TOPIC"] + {{ if eq .Values.odimra.haDeploymentEnabled false }} + "MessageBusAddress": "redis-inmemory", + "HASet": "", + {{ else }} + "MessageBusAddress": "redis-ha-inmemory", + "HASet": "redisSentinel", + {{ end }} + "MessageBusPort": "6379", + "MessageBusType": {{ .Values.aciplugin.messageBusType | quote }}, + "MessageBusQueue": ["ACI-EVENTS-TOPIC"] }, "URLTranslation": { "NorthBoundURL": {