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

[TK-1897] Fix behavior attribute of kubernetes_horizontal_pod_autoscaler_v2(beta2) #1853

Merged
merged 2 commits into from Oct 24, 2022

Conversation

arybolovlev
Copy link
Contributor

@arybolovlev arybolovlev commented Oct 4, 2022

Description

When the attributes spec.behavior, spec.behavior.scale_up and spec.behavior.scale_down of the resources kubernetes_horizontal_pod_autoscaler_v2 and kubernetes_horizontal_pod_autoscaler_v2beta2 are not set, the default HPAScalingRules for scale up and scale down are used. This PR makes them computed and thus it won't cause drifts on plan/apply when the attributes are not set.

Additional changes:

  • Move HPAv2 spec to schema_horizontal_pod_autoscaler.go since it is used multiple times in different places
  • Clean up tests and add the ones with the required attributes only to test how computed ones work

Acceptance tests

  • Have you added an acceptance test for the functionality being added?
  • Have you run the acceptance tests on this branch?

Output from acceptance testing:

$ make testacc TESTARGS='-count 1 -run ^TestAccKubernetesHorizontalPodAutoscaler*'

=== RUN   TestAccKubernetesHorizontalPodAutoscalerV2_minimal
--- PASS: TestAccKubernetesHorizontalPodAutoscalerV2_minimal (7.09s)
...
=== RUN   TestAccKubernetesHorizontalPodAutoscalerV2Beta2_minimal
--- PASS: TestAccKubernetesHorizontalPodAutoscalerV2Beta2_minimal (7.19s)

Release Note

Release note for CHANGELOG:

r/kubernetes_horizontal_pod_autoscaler_v2: make attribute `spec.behavior` computed
r/kubernetes_horizontal_pod_autoscaler_v2: make attribute `spec.behavior.scale_up` computed
r/kubernetes_horizontal_pod_autoscaler_v2: make attribute `spec.behavior.scale_down` computed
r/kubernetes_horizontal_pod_autoscaler_v2beta2: make attribute `spec.behavior` computed
r/kubernetes_horizontal_pod_autoscaler_v2beta2: make attribute `spec.behavior.scale_up` computed
r/kubernetes_horizontal_pod_autoscaler_v2beta2: make attribute `spec.behavior.scale_down` computed

References

Fix: #1850

Community Note

  • Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment

Type: schema.TypeList,
Description: "Behavior configures the scaling behavior of the target in both Up and Down directions (`scale_up` and `scale_down` fields respectively).",
Optional: true,
Computed: true,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Made spec.behavior computed. But since I also moved the whole spec into a diff file\function it is not clear what has changed.

Type: schema.TypeList,
Description: "Scaling policy for scaling Up",
Optional: true,
Computed: true,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Made spec.behavior.scale_up computed. But since I also moved the whole spec into a diff file\function it is not clear what has changed.

Type: schema.TypeList,
Description: "Scaling policy for scaling Down",
Optional: true,
Computed: true,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Made spec.behavior.scale_down computed. But since I also moved the whole spec into a diff file\function it is not clear what has changed.

@arybolovlev arybolovlev marked this pull request as ready for review October 4, 2022 20:18
@jrhouston jrhouston merged commit b3998f3 into main Oct 24, 2022
@jrhouston jrhouston deleted the fix-hpav2-behavior-attribute branch October 24, 2022 04:37
@github-actions
Copy link

I'm going to lock this pull request because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.
If you have found a problem that seems related to this change, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 24, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

kubernetes_horizontal_pod_autoscaler_v2 adding behavior block automatically even if not defined in resource
2 participants