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
Update to v2beta2 API for HPA #2968
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am pretty sure this looks right, but I found that I was going a little cross-eyed trying to keep everything straight in my head.
# For detail, https://github.com/kubernetes-client/python/issues/553 | ||
# This hack should be removed when the issue got fixed. | ||
# This is no better way to work around rn. | ||
class MonkeyPatchAutoScalingConditions(V2beta1HorizontalPodAutoscalerStatus): | ||
@property | ||
def conditions(self) -> Sequence[V2beta1HorizontalPodAutoscalerCondition]: | ||
return super().conditions() | ||
|
||
@conditions.setter | ||
def conditions( | ||
self, conditions: Optional[Sequence[V2beta1HorizontalPodAutoscalerCondition]] | ||
) -> None: | ||
self._conditions = list() if conditions is None else conditions | ||
|
||
|
||
models.V2beta1HorizontalPodAutoscalerStatus = MonkeyPatchAutoScalingConditions |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That issue looks like it's still open, but it sounds like you actually created HPAs on kubestage so I am assuming this is ok.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, the issue is only in the v2beta1 client spec I think. I am also assuming creating HPAs on kubestage proves that this issue is no longer relevant with the new API.
The
behavior
field for HPA, which allows you to specify limits on scaling down, is in the v2beta2 API. This PR just updates the current code to use that API. I'll follow up with a separate PR to add the limits.Here are the API docs I used: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.19/#horizontalpodautoscaler-v2beta2-autoscaling
I think I've tested this for all the possible HPA branches with setup_kubernetes_job on kubestage, which means the objects are valid, but it would still be good to check that the new API requests seem equivalent to the old ones. Here are the autoscaling sections I tested:
Also note this will cause a big bounce. Here's the config diff: