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

Support ScaledObject taking over existing HPAs with the same name while they are not managed by other ScaledObject #4537

Conversation

pragmaticivan
Copy link
Contributor

@pragmaticivan pragmaticivan commented May 12, 2023

Provide a description of what has been changed

Checklist

Fixes #4457

@pragmaticivan pragmaticivan changed the title chore: add test for transfer-hpa-ownership support Support ScaledObject taking over existing HPAs with the same name while they are not managed by other ScaledObject May 12, 2023
@pragmaticivan pragmaticivan force-pushed the feature/4457-support-transfer-hpa-ownership branch from 0a8460b to b317291 Compare May 13, 2023 20:54
@tomkerkhove
Copy link
Member

@pragmaticivan Are you still working on this or waiting for us to review?

@pragmaticivan
Copy link
Contributor Author

@pragmaticivan Are you still working on this or waiting for us to review?

Hi, sorry still working just used the draft so I can figure out how CI is working on this PR

@tomkerkhove
Copy link
Member

No worries!

@zroubalik
Copy link
Member

Folks, I am still not 100% sure, we should go into this direction - ie. changing ownership of existing resources. I might be wrong of course 🤷‍♂️

@pragmaticivan
Copy link
Contributor Author

@zroubalik All good, no attachment to the PR. Maybe we can figure out another creative way to migrate from traditional HPA to ScaledObject progressively.

@zroubalik
Copy link
Member

@zroubalik All good, no attachment to the PR. Maybe we can figure out another creative way to migrate from traditional HPA to ScaledObject progressively.

Yeah definitely, one of my concerns is, what would happen if the HPA is managed by some other tool? We shouldn't change the ownership, as it could have consequencies.

@pragmaticivan
Copy link
Contributor Author

@zroubalik I get it, but at this point, it becomes intentional. It requires the hardcoded HPA name + a flag requesting that to be done. If the person pushing that code reaches prod, its likely that they already have the permissions to do that manually and are just trying to migrate an HPA to Keda.

Right now, the option is to delete the existing HPA or disable the hook (which is way more dangerous in a multi-tenant cluster). The deletion causes a little bit of downtime because, for some reason, the default HPA behavior for removal is to go down an up to what the workload has set for the number of replicas (which is also dangerous).

@zroubalik
Copy link
Member

@zroubalik I get it, but at this point, it becomes intentional. It requires the hardcoded HPA name + a flag requesting that to be done. If the person pushing that code reaches prod, its likely that they already have the permissions to do that manually and are just trying to migrate an HPA to Keda.

Right now, the option is to delete the existing HPA or disable the hook (which is way more dangerous in a multi-tenant cluster). The deletion causes a little bit of downtime because, for some reason, the default HPA behavior for removal is to go down an up to what the workload has set for the number of replicas (which is also dangerous).

Yeah, these are valid points. I just want to be careful, we might be able to mitigate my concerns.

@tomkerkhove
Copy link
Member

@zroubalik We discussed this in our previous standup; maybe the notes help get an idea as well - https://docs.google.com/document/d/1zdwD6j86GxcCe5S5ay9suCO77WPrEDnKSfuaI24EwM4/edit?usp=sharing

@pragmaticivan pragmaticivan force-pushed the feature/4457-support-transfer-hpa-ownership branch from b317291 to d7c3d44 Compare June 1, 2023 19:37
@ghost
Copy link

ghost commented Jun 8, 2023

Hi, any progress on this PR?
Actually we need this feature so that our users will have Zero downtime during migration!

@pragmaticivan
Copy link
Contributor Author

@bingikarthik I'm getting back to wrapping that up this week, although the code as it is should probably be enough to make the feature work as expected. Just learning my way around the codebase to make sure that's the case but I was able to add some tests.

@ghost
Copy link

ghost commented Jun 12, 2023

Thanks @pragmaticivan for the update!

@pragmaticivan pragmaticivan force-pushed the feature/4457-support-transfer-hpa-ownership branch 2 times, most recently from 9cfc8e5 to eb99828 Compare June 16, 2023 01:00
@rwkarg
Copy link
Contributor

rwkarg commented Jun 16, 2023

From a user perspective this seems relatively safe and un-surprising. If I ignore the new feature (don't add the annotation) then I get the existing behavior. In order to have it do something new, I would be required to explicitly add the annotation and specify the same name as an existing HPA.

One thing I'm not clear on from the PR is where I would specify the HPA name I'm looking to take over (I'm certain this will be covered in the forthcoming documentation).

@pragmaticivan
Copy link
Contributor Author

metadata:
  annotations:
    keda.sh/transfer-hpa-ownership: "true"
spec:
   advanced:
      horizontalPodAutoscalerConfig:
      name: {name-of-hpa-resource}

@rwkarg yes, doc coming up once I gain confidence that the current code is ok.

For instance, it might be the case the label should be autoscaling.keda.sh/transfer-hpa-ownership instead.

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.

This looking really well :)
I have left some comments inline

@JorTurFer
Copy link
Member

JorTurFer commented Jun 21, 2023

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

Copy link
Member

@zroubalik zroubalik left a comment

Choose a reason for hiding this comment

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

We are about to release a new version in a few hours. Would you like to include this into the release? If so, we should hurry up :)

@pragmaticivan ^^

@pragmaticivan pragmaticivan force-pushed the feature/4457-support-transfer-hpa-ownership branch from daaf970 to ae39bb2 Compare June 22, 2023 11:32
…me while they are not managed by other ScaledObject

Signed-off-by: Ivan Santos <[email protected]>
Signed-off-by: Ivan Santos <[email protected]>
@pragmaticivan pragmaticivan force-pushed the feature/4457-support-transfer-hpa-ownership branch from ae39bb2 to e67097d Compare June 22, 2023 11:35
@pragmaticivan pragmaticivan marked this pull request as ready for review June 22, 2023 11:36
@pragmaticivan pragmaticivan requested a review from a team as a code owner June 22, 2023 11:36
Copy link
Member

@zroubalik zroubalik 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!

@zroubalik
Copy link
Member

zroubalik commented Jun 22, 2023

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

@pragmaticivan
Copy link
Contributor Author

PR for the doc: kedacore/keda-docs#1166

@zroubalik zroubalik merged commit 92e7546 into kedacore:main Jun 22, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
5 participants