terraform-provider-kubernetes icon indicating copy to clipboard operation
terraform-provider-kubernetes copied to clipboard

Timezone specs (CRON_TZ) rejected by kubernetes_cron_job validation

Open sarneaud opened this issue 4 years ago • 5 comments

Terraform Version, Provider Version and Kubernetes Version

Terraform version: v0.15.0
Kubernetes provider version: v2.5.0
Kubernetes version: 1.20.10-gke.301 

Affected Resource(s)

kubernetes_cron_job

Terraform Configuration Files

resource "kubernetes_cron_job" "demo" {
  metadata {
    name = "demo"
  }
  spec {
    concurrency_policy            = "Replace"
    failed_jobs_history_limit     = 5
    schedule                      = "CRON_TZ=UTC 1 0 * * *"
    starting_deadline_seconds     = 10
    successful_jobs_history_limit = 10
    job_template {
      metadata {}
      spec {
        backoff_limit              = 2
        ttl_seconds_after_finished = 10
        template {
          metadata {}
          spec {
            container {
              name    = "hello"
              image   = "busybox"
              command = ["/bin/sh", "-c", "date; echo Hello from the Kubernetes cluster"]
            }
          }
        }
      }
    }
  }
}

Debug Output

N/A. The provider works great normally, but the validation step in terraform plan rejects cronspecs with CRON_TZ

Steps to Reproduce

  1. terraform plan

Expected Behavior

K8s cron jobs allow the timezone to be specified with an optional CRON_TZ= prefix (https://kubernetes.io/docs/concepts/workloads/controllers/cron-jobs/#cron-schedule-syntax)

The provider should plan to configure/create the cron job with the provided cronspec.

Actual Behavior

The cronspec is rejected at the validation stage here: https://github.com/hashicorp/terraform-provider-kubernetes/blob/8a2911f07b773e6208b0d8a090d520ee7cdd5b88/kubernetes/schema_cron_job_spec.go#L84

Terraform plan errors out with this: Error: 'spec.0.schedule' should be an valid Cron expression

Deleting the CRON_TZ= bit makes the provider accept the cronspec.

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

sarneaud avatar Oct 18 '21 02:10 sarneaud

Thanks for opening this @sarneaud – there should be a fix for this merging soon.

jrhouston avatar Oct 18 '21 15:10 jrhouston

Please could we get some movement on that PR.

nitaigao avatar Mar 21 '22 12:03 nitaigao

Can we please get some update on the PR. The CRON_TZ is still not accepted by the provider

Palit-Mukul avatar Jun 03 '22 06:06 Palit-Mukul

From what I read kubernetes will support spec.timeZone on 1.24 version. Cronjob Time Zones.

rafagsiqueira avatar Jun 03 '22 12:06 rafagsiqueira

Will it be supported by the Terraform Kubernetes provider in future versions?

Palit-Mukul avatar Jun 03 '22 12:06 Palit-Mukul

Thank you for opening this issue! After seeing the cronjob documentations from @rafagsiqueira, we'll be looking into adding the new timezone attribute instead of including timezone as part of schedule since it is not planned to be part of schedule in the future.

BBBmau avatar Jan 25 '23 21:01 BBBmau