Bug 2072357 - oc new-app cannot set environment variables for CronJob batch/v1
Summary: oc new-app cannot set environment variables for CronJob batch/v1
Keywords:
Status: CLOSED DUPLICATE of bug 2072356
Alias: None
Product: OpenShift Container Platform
Classification: Red Hat
Component: oc
Version: 4.8
Hardware: x86_64
OS: Linux
unspecified
unspecified
Target Milestone: ---
: ---
Assignee: Maciej Szulik
QA Contact: zhou ying
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2022-04-06 06:39 UTC by Doug
Modified: 2022-04-06 06:41 UTC (History)
2 users (show)

Fixed In Version:
Doc Type: ---
Doc Text:
Clone Of:
Environment:
Last Closed: 2022-04-06 06:41:32 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)

Description Doug 2022-04-06 06:39:32 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

*** This bug has been marked as a duplicate of bug 2072356 ***


Note You need to log in before you can comment on or make changes to this bug.