openshiftopenshift-3

Openshift Deleted Cronjob Still Running


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.


Solution

  • 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.