Skip to content

JetStream: add accountID param for when an account's name and id differ #6611

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

Merged
merged 10 commits into from
Mar 23, 2025

Conversation

ohhfishal
Copy link
Contributor

@ohhfishal ohhfishal commented Mar 7, 2025

Running into the same issue mentioned in pull 6415. Handles the case where an account name and id differ in a way that maintains backwards-compatibility since it is a trigger.

Checklist

Fixes #

Relates to #
PR#1551
PR#6415

@rickbrouwer
Copy link
Member

What happens if you specify both, but both with a different value?

The JetStream scaler also needs some refactoring (#5797). Is that something you can and want to do? No problem if you can't or don't want to. One advantage of the refactoring is the support for multinames, which I think you want to achieve here. Here is an example of how multinames is applied.

@ohhfishal
Copy link
Contributor Author

As implemented, it defers to only use the ID in the filtering, since internally NATs uses the ID (From the slack message screenshot in #6415.

We can also see this in NATS source where the name is sometimes the ID since Name can be overridden.

I am not entirely sold that the solution of #6415 is the right approach, since it only modifies how we filter the response from the /jsz endpoint, when the issue is fundamentally that the acc filters accounts
by ID not Name. Which my code currently does not change.

Which a component of this is as a result of NATs docs using their terms incorrect. In the source for /jsz they filter by Name, but they expose it to the user as ID (and sometimes Name).

I would be interested in refactoring, but would want to get this fixed first unless refactoring would help in that (since it sounds like the part being refactored is only how the config is initialized).

Still not entirely sure on what the fix for this should be.

@rickbrouwer
Copy link
Member

What caught my eye was this piece of code:

meta.accountID, err = GetFromAuthOrMeta(config, "accountID")
	if err != nil {
		meta.accountID = meta.account
	}

Which means that if accountID is not specified the value of account will be used. I wonder if the user who might configure both would know which one is being used, regardless of whether the outcome is correct (I don't know how JetStream works).

The point about refactoring would mean that someone could specify account or accountId, but both values ​​would then be parsed to e.g. account, basically as you have created now.

@ohhfishal
Copy link
Contributor Author

That solution from the refactor sounds like it would be a cleaner fix than what I have now. I'll see what I can do. To clarify the refactor is to have the config parsing done using the declarative struct tags akin to d5d0b10? Then in doing that using a multiname for account/accountID similar to the example you provided?

@rickbrouwer
Copy link
Member

Yeah, it is cleaner. But it might cost you a bit more work to implement your use case (because the refactoring is added).
That's right, d5d0b10 is an example. More scalers have already been refactored. These are in #5797, although the status is not fully maintained. But at the bottom you can find all mentions of PRs.
For the multiname you can use my example, or #5997. It was introduced in this PR.

Signed-off-by: ohhfishal <ohhfishal@gmail.com>
Signed-off-by: ohhfishal <ohhfishal@gmail.com>
Signed-off-by: ohhfishal <ohhfishal@gmail.com>
Signed-off-by: ohhfishal <ohhfishal@gmail.com>
Signed-off-by: ohhfishal <ohhfishal@gmail.com>
Signed-off-by: ohhfishal <ohhfishal@gmail.com>
Signed-off-by: ohhfishal <ohhfishal@gmail.com>
@ohhfishal ohhfishal marked this pull request as ready for review March 16, 2025 23:15
@ohhfishal ohhfishal requested a review from a team as a code owner March 16, 2025 23:15
Signed-off-by: ohhfishal <ohhfishal@gmail.com>
@JorTurFer
Copy link
Member

JorTurFer commented Mar 22, 2025

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

Signed-off-by: Jorge Turrado Ferrero <Jorge_turrado@hotmail.es>
@JorTurFer
Copy link
Member

JorTurFer commented Mar 23, 2025

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

@JorTurFer JorTurFer merged commit b4c5bab into kedacore:main Mar 23, 2025
15 of 17 checks passed
rickbrouwer pushed a commit to rickbrouwer/keda that referenced this pull request Mar 29, 2025
…er (kedacore#6611)

* JetStream: add accountID param

Signed-off-by: ohhfishal <ohhfishal@gmail.com>

* docs: initial changelog

Signed-off-by: ohhfishal <ohhfishal@gmail.com>

* fix: initial refactor and add ID

Signed-off-by: ohhfishal <ohhfishal@gmail.com>

* docs: add PR link

Signed-off-by: ohhfishal <ohhfishal@gmail.com>

* chore: go fmt

Signed-off-by: ohhfishal <ohhfishal@gmail.com>

* chore: tidy of pre-commit failure

Signed-off-by: ohhfishal <ohhfishal@gmail.com>

* fix: update tests

Signed-off-by: ohhfishal <ohhfishal@gmail.com>

* fix: make account and accountID individually optional, but one required

Signed-off-by: ohhfishal <ohhfishal@gmail.com>

---------

Signed-off-by: ohhfishal <ohhfishal@gmail.com>
Signed-off-by: Jorge Turrado Ferrero <Jorge_turrado@hotmail.es>
Co-authored-by: Jorge Turrado Ferrero <Jorge_turrado@hotmail.es>
rickbrouwer pushed a commit to rickbrouwer/keda that referenced this pull request Apr 9, 2025
…er (kedacore#6611)

* JetStream: add accountID param

Signed-off-by: ohhfishal <ohhfishal@gmail.com>

* docs: initial changelog

Signed-off-by: ohhfishal <ohhfishal@gmail.com>

* fix: initial refactor and add ID

Signed-off-by: ohhfishal <ohhfishal@gmail.com>

* docs: add PR link

Signed-off-by: ohhfishal <ohhfishal@gmail.com>

* chore: go fmt

Signed-off-by: ohhfishal <ohhfishal@gmail.com>

* chore: tidy of pre-commit failure

Signed-off-by: ohhfishal <ohhfishal@gmail.com>

* fix: update tests

Signed-off-by: ohhfishal <ohhfishal@gmail.com>

* fix: make account and accountID individually optional, but one required

Signed-off-by: ohhfishal <ohhfishal@gmail.com>

---------

Signed-off-by: ohhfishal <ohhfishal@gmail.com>
Signed-off-by: Jorge Turrado Ferrero <Jorge_turrado@hotmail.es>
Co-authored-by: Jorge Turrado Ferrero <Jorge_turrado@hotmail.es>
mittalvaibhav1 pushed a commit to mittalvaibhav1/keda that referenced this pull request Apr 26, 2025
…er (kedacore#6611)

* JetStream: add accountID param

Signed-off-by: ohhfishal <ohhfishal@gmail.com>

* docs: initial changelog

Signed-off-by: ohhfishal <ohhfishal@gmail.com>

* fix: initial refactor and add ID

Signed-off-by: ohhfishal <ohhfishal@gmail.com>

* docs: add PR link

Signed-off-by: ohhfishal <ohhfishal@gmail.com>

* chore: go fmt

Signed-off-by: ohhfishal <ohhfishal@gmail.com>

* chore: tidy of pre-commit failure

Signed-off-by: ohhfishal <ohhfishal@gmail.com>

* fix: update tests

Signed-off-by: ohhfishal <ohhfishal@gmail.com>

* fix: make account and accountID individually optional, but one required

Signed-off-by: ohhfishal <ohhfishal@gmail.com>

---------

Signed-off-by: ohhfishal <ohhfishal@gmail.com>
Signed-off-by: Jorge Turrado Ferrero <Jorge_turrado@hotmail.es>
Co-authored-by: Jorge Turrado Ferrero <Jorge_turrado@hotmail.es>
Signed-off-by: mittalvaibhav1 <mittalvaibhavandroid@gmail.com>
mittalvaibhav1 pushed a commit to mittalvaibhav1/keda that referenced this pull request Apr 26, 2025
…er (kedacore#6611)

* JetStream: add accountID param

Signed-off-by: ohhfishal <ohhfishal@gmail.com>

* docs: initial changelog

Signed-off-by: ohhfishal <ohhfishal@gmail.com>

* fix: initial refactor and add ID

Signed-off-by: ohhfishal <ohhfishal@gmail.com>

* docs: add PR link

Signed-off-by: ohhfishal <ohhfishal@gmail.com>

* chore: go fmt

Signed-off-by: ohhfishal <ohhfishal@gmail.com>

* chore: tidy of pre-commit failure

Signed-off-by: ohhfishal <ohhfishal@gmail.com>

* fix: update tests

Signed-off-by: ohhfishal <ohhfishal@gmail.com>

* fix: make account and accountID individually optional, but one required

Signed-off-by: ohhfishal <ohhfishal@gmail.com>

---------

Signed-off-by: ohhfishal <ohhfishal@gmail.com>
Signed-off-by: Jorge Turrado Ferrero <Jorge_turrado@hotmail.es>
Co-authored-by: Jorge Turrado Ferrero <Jorge_turrado@hotmail.es>
mittalvaibhav1 pushed a commit to mittalvaibhav1/keda that referenced this pull request Apr 26, 2025
…er (kedacore#6611)

* JetStream: add accountID param

Signed-off-by: ohhfishal <ohhfishal@gmail.com>

* docs: initial changelog

Signed-off-by: ohhfishal <ohhfishal@gmail.com>

* fix: initial refactor and add ID

Signed-off-by: ohhfishal <ohhfishal@gmail.com>

* docs: add PR link

Signed-off-by: ohhfishal <ohhfishal@gmail.com>

* chore: go fmt

Signed-off-by: ohhfishal <ohhfishal@gmail.com>

* chore: tidy of pre-commit failure

Signed-off-by: ohhfishal <ohhfishal@gmail.com>

* fix: update tests

Signed-off-by: ohhfishal <ohhfishal@gmail.com>

* fix: make account and accountID individually optional, but one required

Signed-off-by: ohhfishal <ohhfishal@gmail.com>

---------

Signed-off-by: ohhfishal <ohhfishal@gmail.com>
Signed-off-by: Jorge Turrado Ferrero <Jorge_turrado@hotmail.es>
Co-authored-by: Jorge Turrado Ferrero <Jorge_turrado@hotmail.es>
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.

3 participants