Fission MQT integration with keda (#1657)

Fission MQT integration based on Keda with Kafka connector
This commit is contained in:
Rahul Bhati
2020-07-14 21:35:48 +05:30
committed by GitHub
parent d6fc9f71d0
commit 8e0571c7c9
25 changed files with 2203 additions and 28 deletions
+6 -2
View File
@@ -33,7 +33,9 @@ func Commands() *cobra.Command {
Required: []flag.Flag{flag.MqtFnName, flag.MqtTopic},
Optional: []flag.Flag{flag.MqtName, flag.MqtMQType, flag.MqtRespTopic,
flag.MqtErrorTopic, flag.MqtMaxRetries, flag.MqtMsgContentType,
flag.NamespaceFunction, flag.SpecSave, flag.SpecDry},
flag.NamespaceFunction, flag.SpecSave, flag.SpecDry, flag.MqtPollingInterval,
flag.MqtCooldownPeriod, flag.MqtMinReplicaCount, flag.MqtMaxReplicaCount, flag.MqtSecret,
flag.MqtMetadata, flag.MqtKind},
})
updateCmd := &cobra.Command{
@@ -45,7 +47,9 @@ func Commands() *cobra.Command {
wrapper.SetFlags(updateCmd, flag.FlagSet{
Required: []flag.Flag{flag.MqtName},
Optional: []flag.Flag{flag.MqtFnName, flag.MqtTopic, flag.MqtRespTopic, flag.MqtErrorTopic,
flag.MqtMaxRetries, flag.MqtMsgContentType, flag.NamespaceTrigger},
flag.MqtMaxRetries, flag.MqtMsgContentType, flag.NamespaceTrigger, flag.MqtPollingInterval,
flag.MqtCooldownPeriod, flag.MqtMinReplicaCount, flag.MqtMaxReplicaCount, flag.MqtMetadata,
flag.MqtSecret, flag.MqtKind},
})
deleteCmd := &cobra.Command{
+35
View File
@@ -93,6 +93,34 @@ func (opts *CreateSubCommand) complete(input cli.Input) error {
return err
}
pollingInterval := int32(input.Int(flagkey.MqtPollingInterval))
if pollingInterval < 0 {
return errors.New("Polling interval must be greater than or equal to 0")
}
cooldownPeriod := int32(input.Int(flagkey.MqtCooldownPeriod))
if cooldownPeriod < 0 {
return errors.New("CooldownPeriod interval is the period to wait after the last trigger reported active before scaling the deployment back to 0, it must be greater than or equal to 0")
}
minReplicaCount := int32(input.Int(flagkey.MqtMinReplicaCount))
if minReplicaCount < 0 {
return errors.New("MinReplicaCount must be greater than or equal to 0")
}
maxReplicaCount := int32(input.Int(flagkey.MqtMaxReplicaCount))
if maxReplicaCount < 0 {
return errors.New("MaxReplicaCount must be greater than or equal to 0")
}
metadata := make(map[string]string)
metadataParams := input.StringSlice(flagkey.MqtMetadata)
_ = util.UpdateMapFromStringSlice(&metadata, metadataParams)
secret := input.String(flagkey.MqtSecret)
mqtKind := input.String(flagkey.MqtKind)
if input.Bool(flagkey.SpecSave) {
specDir := util.GetSpecDir(input)
fr, err := spec.ReadSpecs(specDir)
@@ -131,6 +159,13 @@ func (opts *CreateSubCommand) complete(input cli.Input) error {
ErrorTopic: errorTopic,
MaxRetries: maxRetries,
ContentType: contentType,
PollingInterval: &pollingInterval,
CooldownPeriod: &cooldownPeriod,
MinReplicaCount: &minReplicaCount,
MaxReplicaCount: &maxReplicaCount,
Metadata: metadata,
Secret: secret,
MqtKind: mqtKind,
},
}
+39 -3
View File
@@ -26,6 +26,7 @@ import (
"github.com/fission/fission/pkg/fission-cli/cliwrapper/cli"
"github.com/fission/fission/pkg/fission-cli/cmd"
flagkey "github.com/fission/fission/pkg/fission-cli/flag/key"
"github.com/fission/fission/pkg/fission-cli/util"
)
type UpdateSubCommand struct {
@@ -60,7 +61,13 @@ func (opts *UpdateSubCommand) complete(input cli.Input) error {
maxRetries := input.Int(flagkey.MqtMaxRetries)
fnName := input.String(flagkey.MqtFnName)
contentType := input.String(flagkey.MqtMsgContentType)
pollingInterval := int32(input.Int(flagkey.MqtPollingInterval))
cooldownPeriod := int32(input.Int(flagkey.MqtCooldownPeriod))
minReplicaCount := int32(input.Int(flagkey.MqtMinReplicaCount))
maxReplicaCount := int32(input.Int(flagkey.MqtMaxReplicaCount))
metadataParams := input.StringSlice(flagkey.MqtMetadata)
secret := input.String(flagkey.MqtSecret)
mqtKind := input.String(flagkey.MqtKind)
// TODO : Find out if we can make a call to checkIfFunctionExists, in the same ns more importantly.
err = checkMQTopicAvailability(mqt.Spec.MessageQueueType, topic, respTopic)
@@ -81,7 +88,7 @@ func (opts *UpdateSubCommand) complete(input cli.Input) error {
mqt.Spec.ErrorTopic = errorTopic
updated = true
}
if maxRetries > -1 {
if input.IsSet(flagkey.MqtMaxRetries) {
mqt.Spec.MaxRetries = maxRetries
updated = true
}
@@ -89,10 +96,39 @@ func (opts *UpdateSubCommand) complete(input cli.Input) error {
mqt.Spec.FunctionReference.Name = fnName
updated = true
}
if len(contentType) > 0 {
if input.IsSet(flagkey.MqtMsgContentType) {
mqt.Spec.ContentType = contentType
updated = true
}
if input.IsSet(flagkey.MqtPollingInterval) {
mqt.Spec.PollingInterval = &pollingInterval
updated = true
}
if input.IsSet(flagkey.MqtCooldownPeriod) {
mqt.Spec.CooldownPeriod = &cooldownPeriod
updated = true
}
if input.IsSet(flagkey.MqtMinReplicaCount) {
mqt.Spec.MinReplicaCount = &minReplicaCount
updated = true
}
if input.IsSet(flagkey.MqtMaxReplicaCount) {
mqt.Spec.MaxReplicaCount = &maxReplicaCount
updated = true
}
if input.IsSet(flagkey.MqtMetadata) {
updated = updated || util.UpdateMapFromStringSlice(&mqt.Spec.Metadata, metadataParams)
}
if input.IsSet(flagkey.MqtSecret) {
mqt.Spec.Secret = secret
updated = true
}
if input.IsSet(flagkey.MqtKind) {
mqt.Spec.MqtKind = mqtKind
updated = true
}
if !updated {
return errors.New("Nothing changed, see 'help' for more details")