Uploaded image for project: 'OpenShift Bugs'
  1. OpenShift Bugs
  2. OCPBUGS-9209

oc new-app cannot set environment variables for CronJob batch/v1

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: Undefined Undefined
    • None
    • 4.8
    • Templates
    • None
    • None
    • x86_64
    • If docs needed, set a value

      Description of problem:
      oc new-app --env-file or -e parameter is not working for CronJob batch/v1

      Version-Release number of selected component (if applicable):
      From 4.8.0

      How reproducible:
      always

      Steps to Reproduce:
      If the apiversion in the template file is batch/v1beta1 for cronjob and use oc new-app --env-file, the generated yaml with dry-run will contain the environment variables.
      oc new-app -f cron-template.yaml -e foo=bar --dry-run -o yaml

      apiVersion: v1
      items:

      • apiVersion: batch/v1beta1
        kind: CronJob
        metadata:
        annotations:
        openshift.io/generated-by: OpenShiftNewApp
        creationTimestamp: null
        labels:
        app: cron-template
        app.kubernetes.io/component: cron-template
        app.kubernetes.io/instance: cron-template
        name: pi
        spec:
        concurrencyPolicy: Replace
        failedJobsHistoryLimit: 1
        jobTemplate:
        metadata:
        creationTimestamp: null
        spec:
        template:
        metadata:
        creationTimestamp: null
        labels:
        parent: cronjobpi
        spec:
        containers:
      • command:
      • perl
      • -Mbignum=bpi
      • -wle
      • print bpi(2000)
        env:
      • name: foo
        value: bar
        image: perl
        name: pi
        resources: {}
        restartPolicy: OnFailure
        schedule: '*/1 * * * *'
        startingDeadlineSeconds: 200
        successfulJobsHistoryLimit: 3
        suspend: true
        status: {}
        kind: List
        metadata: {}

      If I do the same with batch/v1, the generated file won't have environment variables.
      oc new-app -f cron-template.yaml -e foo=bar --dry-run -o yaml

      apiVersion: v1
      items:

      • apiVersion: batch/v1
        kind: CronJob
        metadata:
        annotations:
        openshift.io/generated-by: OpenShiftNewApp
        creationTimestamp: null
        labels:
        app: cron-template
        app.kubernetes.io/component: cron-template
        app.kubernetes.io/instance: cron-template
        name: pi
        spec:
        concurrencyPolicy: Replace
        failedJobsHistoryLimit: 1
        jobTemplate:
        metadata:
        creationTimestamp: null
        spec:
        template:
        metadata:
        creationTimestamp: null
        labels:
        parent: cronjobpi
        spec:
        containers:
      • command:
      • perl
      • -Mbignum=bpi
      • -wle
      • print bpi(2000)
        image: perl
        name: pi
        resources: {}
        restartPolicy: OnFailure
        schedule: '*/1 * * * *'
        startingDeadlineSeconds: 200
        successfulJobsHistoryLimit: 3
        suspend: true
        status: {}
        kind: List
        metadata: {}

      Additional info:
      The server version is 4.8.0 and I tried with clients 4.8.0-4.10.0
      4.7.0 client cannot handle batch/v1 for CronJob so it is ok to not working.

              dperaza@redhat.com David Peraza
              openshift_jira_bot OpenShift Jira Bot
              Sushanta Das Sushanta Das
              Red Hat Employee
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

                Created:
                Updated: