Skip to content

Refactor redis scaler config#5997

Merged
zroubalik merged 8 commits into
kedacore:mainfrom
SpiritZhou:spiritzhou/redisrefactor
Sep 26, 2024
Merged

Refactor redis scaler config#5997
zroubalik merged 8 commits into
kedacore:mainfrom
SpiritZhou:spiritzhou/redisrefactor

Conversation

@SpiritZhou

@SpiritZhou SpiritZhou commented Jul 30, 2024

Copy link
Copy Markdown
Contributor
  1. Add multi name support in config type
  2. Refactor redis scaler config

Provide a description of what has been changed

Checklist

Relates to # #5797

Signed-off-by: SpiritZhou <[email protected]>
@SpiritZhou

SpiritZhou commented Jul 30, 2024

Copy link
Copy Markdown
Contributor Author

/run-e2e redis
Update: You can check the progress here

Signed-off-by: SpiritZhou <[email protected]>
@SpiritZhou SpiritZhou marked this pull request as ready for review July 30, 2024 07:33
@SpiritZhou SpiritZhou requested a review from a team as a code owner July 30, 2024 07:33
@tomkerkhove

Copy link
Copy Markdown
Member

@wozniakjan @dttung2905 mind reviewing?

@dttung2905 dttung2905 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the PR. I just have a few minor comments, mostly on the support of multiple key name in our util function

Comment thread pkg/scalers/redis_scaler.go Outdated
Comment thread pkg/scalers/redis_scaler.go Outdated
Ports []string `keda:"name=port;ports, order=triggerMetadata;resolvedEnv;authParams"`
EnableTLS bool `keda:"name=enableTLS;tls, order=triggerMetadata;authParams, optional, default=false"`
UnsafeSsl bool `keda:"name=unsafeSsl, order=triggerMetadata, optional, default=false"`
Cert string `keda:"name=Cert;cert, order=authParams"`

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similar question there ? Are you trying to cover all cases where user can mistakenly input a value into the manifest or such cases have been supported in the current code ? 🤔

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think multi-name keys is a good feature, although I wasn't able to find Cert (with capital C) anywhere in the original code. Maybe this is a typo?

Comment thread pkg/scalers/redis_scaler.go Outdated

@wozniakjan wozniakjan left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm, hopefully multi-named keys won't complicate the API spec generator but we will cross that bridge once we have some tooling foundation.

Comment thread pkg/scalers/redis_streams_scaler.go Outdated
Signed-off-by: SpiritZhou <[email protected]>
Signed-off-by: SpiritZhou <[email protected]>
@rickbrouwer

rickbrouwer commented Aug 20, 2024

Copy link
Copy Markdown
Member

@wozniakjan what about the usernameFromEnv and passwordFromEnv? These are mentioned in the documentation as being usable, but are no longer supported via this PR. I also have this problem with the IBM scaler and wanted to see here how it was solved. This issue will also appear by the MySQL scaler. What do you think how to solve this?

@wozniakjan

Copy link
Copy Markdown
Member

what about the usernameFromEnv and passwordFromEnv? These are mentioned in the documentation as being usable, but are no longer supported via this PR.

in this specific PR it should continue to work with usernameFromEnv, unless I'm missing something.

Username string `keda:"name=username, order=triggerMetadata;resolvedEnv;authParams"`

this contains order field tag key with value resolvedEnv (among other), and the way it's implemented internally is it appends FromEnv to the name of the parameter and then fetches key from TriggerMetadata map. It works this way because that was the convention in KEDA before #5676 and we didn't want to introduce any breaking changes with this refactor, goal is just to standardize the parsing implementations and reduce code duplication.

case ResolvedEnv:
m = sc.ResolvedEnv
key = sc.TriggerMetadata[fmt.Sprintf("%sFromEnv", key)]

It might be a bit more understandable in this unit test

func TestBasicTypedConfig(t *testing.T) {
RegisterTestingT(t)
sc := &ScalerConfig{
TriggerMetadata: map[string]string{
"stringVal": "value1",
"intVal": "1",
"boolValFromEnv": "boolVal",
"floatValFromEnv": "floatVal",
},
ResolvedEnv: map[string]string{
"boolVal": "true",
"floatVal": "1.1",
},
AuthParams: map[string]string{
"auth": "authValue",
},
}
type testStruct struct {
StringVal string `keda:"name=stringVal, order=triggerMetadata"`
IntVal int `keda:"name=intVal, order=triggerMetadata"`
BoolVal bool `keda:"name=boolVal, order=resolvedEnv"`
FloatVal float64 `keda:"name=floatVal, order=resolvedEnv"`
AuthVal string `keda:"name=auth, order=authParams"`
}
ts := testStruct{}
err := sc.TypedConfig(&ts)
Expect(err).To(BeNil())
Expect(ts.StringVal).To(Equal("value1"))
Expect(ts.IntVal).To(Equal(1))
Expect(ts.BoolVal).To(BeTrue())
Expect(ts.FloatVal).To(Equal(1.1))
Expect(ts.AuthVal).To(Equal("authValue"))
}

@rickbrouwer

Copy link
Copy Markdown
Member

@wozniakjan Thanks for the explanation! Then it should work fine for the rest :)

@zroubalik

zroubalik commented Aug 20, 2024

Copy link
Copy Markdown
Member

/run-e2e redis
Update: You can check the progress here

@SpiritZhou

SpiritZhou commented Sep 24, 2024

Copy link
Copy Markdown
Contributor Author

/run-e2e redis
Update: You can check the progress here

Signed-off-by: SpiritZhou <[email protected]>
@SpiritZhou

Copy link
Copy Markdown
Contributor Author

@zroubalik Could you help to review it again?

@SpiritZhou

SpiritZhou commented Sep 24, 2024

Copy link
Copy Markdown
Contributor Author

/run-e2e redis
Update: You can check the progress here

@zroubalik zroubalik merged commit 0b470a6 into kedacore:main Sep 26, 2024
rickbrouwer pushed a commit to rickbrouwer/keda that referenced this pull request Oct 2, 2024
rickbrouwer pushed a commit to rickbrouwer/keda that referenced this pull request Oct 2, 2024
JorTurFer pushed a commit to JorTurFer/keda that referenced this pull request Oct 7, 2024
Signed-off-by: SpiritZhou <[email protected]>
Signed-off-by: Jorge Turrado <[email protected]>
rickbrouwer pushed a commit to rickbrouwer/keda that referenced this pull request Oct 21, 2024
mpechner-akasa pushed a commit to nrichardson-akasa/keda that referenced this pull request Nov 29, 2024
Signed-off-by: SpiritZhou <[email protected]>
Signed-off-by: michael pechner <[email protected]>
chiragbhatia8 pushed a commit to chiragbhatia8/keda that referenced this pull request Jan 9, 2025
Signed-off-by: SpiritZhou <[email protected]>
Signed-off-by: Chirag Bhatia <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants