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

feat: add scaletargetref exists check in webhook and revise some variable name #6350

Open
wants to merge 10 commits into
base: main
Choose a base branch
from

Conversation

ctccxxd
Copy link

@ctccxxd ctccxxd commented Nov 20, 2024

check scaletargetref exists in webhook and revise some variable name, originally,
1, There is not scaletargetref exists check code in webhook module.
2, Change the inappropriate variable name Gckr to Gvkr.
3, If still want to remain the function to create scaleobj first without real scaletargetRef obj. Think whether this function will be a way can be configged, to confirm the real scaletargetRef obj already exists when we create/update scaleobj. In this way, it can avoid the user misconfigurations about scaletargetRef in yaml file.

Checklist

Fixes #

Relates to #
#6354

@ctccxxd ctccxxd requested a review from a team as a code owner November 20, 2024 03:10
@ctccxxd ctccxxd changed the title check scaletargetref exists in webhook and revise some variable name add scaletargetref exists check in webhook and revise some variable name Nov 20, 2024
@SpiritZhou
Copy link
Contributor

Could you please open an issue for this improvement and relate this pr to the issue? This will make it clear and easy to tracing.

@ctccxxd
Copy link
Author

ctccxxd commented Nov 21, 2024

Could you please open an issue for this improvement and relate this pr to the issue? This will make it clear and easy to tracing.

done. Thank you.

@ctccxxd ctccxxd reopened this Nov 21, 2024
@ctccxxd
Copy link
Author

ctccxxd commented Nov 21, 2024

Friendly ping @zroubalik @wozniakjan @SpiritZhou @psi @wonko @fivesheep @JorTurFer hope you to review and discuss, much thanks.

@ctccxxd ctccxxd changed the title add scaletargetref exists check in webhook and revise some variable name feat: add scaletargetref exists check in webhook and revise some variable name Nov 21, 2024
Comment on lines 273 to 278
if err := kc.Get(ctx, client.ObjectKey{Namespace: so.Namespace, Name: so.Spec.ScaleTargetRef.Name}, unstruct); err != nil {
// resource doesn't exist
scaledobjectlog.Error(err, message.ScaleTargetNotFoundMsg, "resource", gvkString, "name", so.Spec.ScaleTargetRef.Name)
return err
}
return nil
Copy link
Member

Choose a reason for hiding this comment

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

As this can potentially happen before the targetRef is available through the cached client it should check the item using getFromCacheOrDirect to rely on user configuration to try using the direct client

Copy link
Author

Choose a reason for hiding this comment

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

As this can potentially happen before the targetRef is available through the cached client it should check the item using getFromCacheOrDirect to rely on user configuration to try using the direct client

Thank you for your comment. I have follow your idea and change the code already. Hope for your reply soon. MuchThanks.

Copy link
Member

@JorTurFer JorTurFer left a comment

Choose a reason for hiding this comment

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

LGTM! Thanks for the improvement :)

@JorTurFer
Copy link
Member

JorTurFer commented Nov 27, 2024

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

@JorTurFer
Copy link
Member

PTAL @kedacore/keda-contributors

@JorTurFer JorTurFer enabled auto-merge (squash) November 27, 2024 21:46
@JorTurFer
Copy link
Member

@ctccxxd , please open another PR to docs adding the new check to the admission webhooks -> https://github.com/kedacore/keda-docs/blob/main/content/docs/2.17/concepts/admission-webhooks.md

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