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

2.25.0 should not require namespace in job_template's #2385

Closed
braunsonm opened this issue Jan 4, 2024 · 7 comments
Closed

2.25.0 should not require namespace in job_template's #2385

braunsonm opened this issue Jan 4, 2024 · 7 comments
Labels

Comments

@braunsonm
Copy link

braunsonm commented Jan 4, 2024

Terraform Version, Provider Version and Kubernetes Version

Terraform version: 1.6.6
Kubernetes provider version: 2.25.0
Kubernetes version: 1.26.0

Affected Resource(s)

  • kubernetes_cron_job_v1
  • kubernetes_stateful_set_v1
  • kubernetes_daemon_set_v1

Terraform Configuration Files

Pre 2.25.0:

resource "kubernetes_cron_job_v1" "backup" {
  metadata {
    name      = "vault-snapshot"
    namespace = "vault"
  }

  spec {
    schedule           = "@daily"
    concurrency_policy = "Replace"
    job_template {
      metadata {}
      ...

Post 2.25.0, namespace in the job_template now becomes required. If not set, the namespace gets forced to default which will not work in this context.

resource "kubernetes_cron_job_v1" "backup" {
  metadata {
    name      = "vault-snapshot"
    namespace = "vault"
  }

  spec {
    schedule           = "@daily"
    concurrency_policy = "Replace"
    job_template {
      metadata {
        namespace = "vault"
      }
      ...

Steps to Reproduce

  1. terraform apply the pre 2.25.0 configuration
  2. Notice that the job_template specification is trying to set the namespace to default. This will not work since the job_template is embedded in this resource and will be on the vault namespace as implied by the cron job

Relevant plan output from 2.25.0 (no diff prior to upgrade from 2.24.0)

  # module.vault.kubernetes_cron_job_v1.backup[0] must be replaced
-/+ resource "kubernetes_cron_job_v1" "backup" {
      ~ id = "vault/vault-snapshot" -> (known after apply)
      ~ metadata {
          ~ generation       = 10 -> (known after apply)
            # (1 unchanged attribute hidden)
        }
      ~ spec {
            # (6 unchanged attributes hidden)
          ~ job_template {
              ~ metadata {
                  + namespace        = "default" # forces replacement

Expected Behavior

The job template namespace should be implied from the cron job namespace and should not be defaulting to default when not set. Allowing null on the namespace of job template was the previous behaviour and should remain.

Actual Behavior

Job template's namespace is being defaulted to default

References

  • Bug introduced in this commit: 0d9471d
@braunsonm braunsonm added the bug label Jan 4, 2024
@dpiddock
Copy link

dpiddock commented Jan 4, 2024

This bug also impacts kubernetes_stateful_set_v1 and kubernetes_daemon_set_v1. Terraform wants to recreate all resources when upgrading the provider. kubernetes_deployment_v1 appears to have escaped the breaking change.

@braunsonm braunsonm changed the title 1.25.0 should not require namespace in job_template's 2.25.0 should not require namespace in job_template's Jan 4, 2024
@AnshumanTripathi
Copy link

This change is causing replacement of our resources.

@mjseid
Copy link

mjseid commented Jan 4, 2024

Also experiencing forced replacements due to this bug

@ethankent
Copy link

Downgrading the provider version does not work if any state refresh has been applied.

Error decoding "module.foo.kubernetes_stateful_set.bar" from previous state: unsupported attribute "persistent_volume_claim_retention_policy"

We could really use an emergency hotfix here.

@arybolovlev
Copy link
Contributor

Hi @braunsonm,

Thank you for reporting this issue. We are working on a fix here.

Please, keep an eye on releases.

@arybolovlev
Copy link
Contributor

Hi @braunsonm,

This issue should be fixed in 2.25.2. Could you please validate this?

Thanks.

@braunsonm
Copy link
Author

Confirmed, 2.25.2 is no longer trying to recreate our resources.

Thank you for the quick fix.

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

No branches or pull requests

6 participants