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

🐛 Fix Pod spec toleration when the spec is a template #2380

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

Conversation

arybolovlev
Copy link
Contributor

@arybolovlev arybolovlev commented Jan 2, 2024

Description

This PR updates the logic of resources that use the Pod specification template and now the provider will keep all tolerations(spec.toleration) returned by Kubernetes. The same is applicable for the data sources kubernetes_pod_v1 and kubernetes_pod. The behavior of resources kubernetes_pod_v1 and kubernetes_pod remains unchanged, i.e. the provider will keep removing tolerations with well-known taints since they might be attached to the object by Kubernetes controller and could lead to a perpetual diff.

Affected resources and data sources:

  • resource/kubernetes_replication_controller
  • resource/kubernetes_replication_controller_v1
  • resource/kubernetes_stateful_set
  • resource/kubernetes_stateful_set_v1
  • resource/kubernetes_deployment
  • resource/kubernetes_deployment_v1
  • resource/kubernetes_daemonset
  • resource/kubernetes_daemon_set_v1
  • resource/kubernetes_cron_job
  • resource/kubernetes_cron_job_v1
  • resource/kubernetes_job
  • resource/kubernetes_job_v1
  • data_source/kubernetes_pod
  • data_source/kubernetes_pod_v1

Acceptance tests

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

Release Note

Release note for CHANGELOG:

We have updated the logic of resources that use the Pod specification template, such as `kubernetes_deployment_v1`, `kubernetes_stateful_set_v1`, etc, and now the provider will keep all tolerations(`spec.toleration`) returned by Kubernetes. The same is applicable for the data sources `kubernetes_pod_v1` and `kubernetes_pod`. The behavior of resources `kubernetes_pod_v1` and `kubernetes_pod` remains unchanged, i.e. the provider will keep removing tolerations with well-known [taints](https://kubernetes.io/docs/reference/labels-annotations-taints/) since they might be attached to the object by Kubernetes controller and could lead to a perpetual diff.

Fix an issue when the provider cuts out toleration under pod spec template(`*.template.spec.toleration`) if it uses a well-known [taint](https://kubernetes.io/docs/reference/labels-annotations-taints/). That could lead to a perpetual diff behavior.

References

Fix: #2376

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

@github-actions github-actions bot added the size/M label Jan 2, 2024
@arybolovlev arybolovlev changed the title Add a new argument to function flattenPodSpec 🐛 Fix Pod spec toleration when the spec is a template Jan 2, 2024
@github-actions github-actions bot added size/L and removed size/M labels Jan 3, 2024
@arybolovlev arybolovlev marked this pull request as ready for review January 3, 2024 08:30
@arybolovlev arybolovlev requested a review from a team as a code owner January 3, 2024 08:31
@Restless-ET
Copy link

Hello @arybolovlev

Any expected date for when this will be merged?
Will it be for v2.26 only or as a patch to v2.25?

Best regards

@@ -38,7 +38,7 @@ func flattenOS(in v1.PodOS) []interface{} {
return []interface{}{att}
}

func flattenPodSpec(in v1.PodSpec) ([]interface{}, error) {
func flattenPodSpec(in v1.PodSpec, isTeamplate bool) ([]interface{}, error) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks for the changes @arybolovlev, should this be isTeamplate bool or isTemplate bool ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Deployment tolerations using keys matching k8s node taints are being ignored for the tfstate
3 participants