Note: This bug is displayed in read-only format because the product is no longer active in Red Hat Bugzilla.

Bug 2072356

Summary: oc new-app cannot set environment variables for CronJob batch/v1
Product: OpenShift Container Platform Reporter: Doug <douggutaby>
Component: TemplatesAssignee: David Peraza <dperaza>
Status: CLOSED DEFERRED QA Contact: Sushanta Das <susdas>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 4.8CC: jaimelm, mfojtik
Target Milestone: ---   
Target Release: ---   
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2023-03-09 01:16:49 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Doug 2022-04-06 06:39:12 UTC
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.

Comment 1 Doug 2022-04-06 06:41:32 UTC
*** Bug 2072357 has been marked as a duplicate of this bug. ***

Comment 3 Shiftzilla 2023-03-09 01:16:49 UTC
OpenShift has moved to Jira for its defect tracking! This bug can now be found in the OCPBUGS project in Jira.

https://issues.redhat.com/browse/OCPBUGS-9209