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

ACI-5407 update aci plugin message bus config #1

Merged
merged 2 commits into from
Nov 24, 2021
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
31 changes: 24 additions & 7 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
}
Expand Down Expand Up @@ -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
}

Expand Down
3 changes: 3 additions & 0 deletions config/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@
},
"MessageBusConf": {
"MessageQueueConfigFilePath": "",
"MessageBusAddress": "localhost",
"MessageBusPort": "6379",
"HASet": "redisSentinel",
"MessageBusType": "Kafka",
"MessageBusQueue": ["REDFISH-EVENTS-TOPIC"]
},
Expand Down
6 changes: 6 additions & 0 deletions config/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}
1 change: 1 addition & 0 deletions install/Kubernetes/helmcharts/aciplugin-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,4 @@ aciplugin:
odimURL:
odimUserName:
odimPassword:
messageBusType: Kafka
12 changes: 10 additions & 2 deletions install/Kubernetes/helmcharts/aciplugin/templates/configmaps.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,16 @@ data:
},
"MessageBusConf": {
"MessageQueueConfigFilePath": "/etc/aciplugin_config/platformconfig.toml",
"MessageBusType": "Kafka",
"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": {
Expand Down
1 change: 1 addition & 0 deletions install/Kubernetes/helmcharts/aciplugin/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,4 @@ aciplugin:
odimURL:
odimUserName:
odimPassword:
messageBusType: Kafka