0

I made a cronjob in OpenShift 3.11 with a restartPolicy of Always. However, when I deleted this cronjob, and the associated jobs, the jobs were (and currently are, as of writing this) still running. I cannot figure out how to stop the job though, and would like to stop the job from running.

I have tried scaling down the deployment to zero pods, deleting the deployment and recreating it (redeploying), deleting the build config and then redoing the build config, deleting the entire project in Open Shift, then recreating the project, running: oc delete all -l app=app, oc delete jobs --all, and oc delete pods --all, none of which has worked so far.

Any suggestions regarding how to delete the cronjob are helpful!

EDIT:

cronjob.yaml:

kind: CronJob
apiVersion: batch/v1beta1
metadata:
  name: --redacted--
  namespace: --redacted--
  selfLink: --redacted--
  uid: 5d5cde7d-e8f6-11ea-8ec0-00505682ee91
  resourceVersion: '178216471'
  creationTimestamp: '2020-08-28T06:19:01Z'
spec:
  schedule: 0 8 * * *
  concurrencyPolicy: Allow
  suspend: false
  jobTemplate:
    metadata:
      creationTimestamp: null
    spec:
      template:
        metadata:
          creationTimestamp: null
        spec:
          containers:
            - name: --redacted--
              image: byrnedo/alpine-curl
              args:
                - '--insecure'
                - '--location'
                - >-
                  -H 'Authorization: Bearer --redacted--'
                - http://--redacted--
                - '-XPOST'
              resources: {}
              terminationMessagePath: /dev/termination-log
              terminationMessagePolicy: File
              imagePullPolicy: Always
          restartPolicy: Always
          terminationGracePeriodSeconds: 30
          dnsPolicy: ClusterFirst
          securityContext: {}
          schedulerName: default-scheduler
  successfulJobsHistoryLimit: 3
  failedJobsHistoryLimit: 1
status:
  lastScheduleTime: '2020-08-28T08:00:00Z'

oc get cronjobs returns no jobs.

Seth Wheeler
  • 353
  • 1
  • 2
  • 16
  • How exactly have you created your cronjob? Please, provide a redacted yaml manifest and a command used to apply it. What does `oc get cronjobs` says? Have you actually deleted project with `oc delete project ` or just by using commands you have specified? Are you sure your cronjob has an "app=app" label? – Andrew Aug 28 '20 at 11:22
  • @Andrew I have updated the post with some of the information you asked for. The `app=app` label was for the command `oc delete all -l` which per their help option: `Delete all resources associated with a running app, includes buildconfig,deploymentconfig,service,imagestream,route and pod, where 'appName' is listed in 'Labels' of 'oc describe [resource] [resource name]' output` I deleted the project through the UI, not by using the command. – Seth Wheeler Aug 28 '20 at 14:49

1 Answers1

1

Based on your updated question, i can see why oc delete all -l app=app haven't deleted your CronJob - there is no metadata.labels in it, so it wasn't selected. You can use

oc get all -lapp=app

to verify what is gona be deleted. There is one caveat though - all is actually not "everything", refer to Listing all resources in a namespace to see the supported way to get each and every resource in namespace.

But if you really removed a project - all resources should've been deleted. I can see only one possibility of CronJob existing - you may have added it to some other namespace too. You can use

oc get cronjob --all-namespaces --field-selector=metadata.name=you_cronjob_name

to search for cronjob with your name in all namespaces.

Andrew
  • 3,912
  • 17
  • 28