Does deleting an argo cron workflow delete all argo workflows started by it as well

10/29/2020

It looks like the case that when I delete an Argo cron workflow with argo cron delete, all the previous workflows (completed as well as still running ones) will also be deleted based on my observation. I'm not totally sure though and I haven't found a more detailed doc than https://argoproj.github.io/argo/cli/argo_cron_delete/.

What if I'd like to keep all the history workflows when e.g. updating the frequency of a cron workflow, e.g. to run every Monday instead of every day? What would be the recommended way to do such an update?

-- zyxue
argo-cron-workflows
argo-workflows
kubernetes

2 Answers

10/29/2020

If you want to keep workflow data around for a while, you should persist them to a database using Argo's workflow archive tool.

Just to confirm your issue, I did a quick test using their "hello-world" cron workflow:

apiVersion: argoproj.io/v1alpha1
kind: CronWorkflow
metadata:
  name: hello-world
spec:
  schedule: "* * * * *"
  timezone: "America/Los_Angeles"   # Default to local machine timezone
  startingDeadlineSeconds: 0
  concurrencyPolicy: "Replace"      # Default to "Allow"
  successfulJobsHistoryLimit: 4     # Default 3
  failedJobsHistoryLimit: 4         # Default 1
  suspend: false                    # Set to "true" to suspend scheduling
  workflowSpec:
    entrypoint: whalesay
    templates:
      - name: whalesay
        container:
          image: docker/whalesay:latest

Deleting the cron workflow does indeed delete the hello-world workflow kicked off by it. I'm especially confident because I have other workflows that have been sitting on my Minikube cluster for days without being deleted.

If you don't want to use the workflow archive, you can use kubectl edit cronworkflow <workflow name>. I just tested, and the update will not delete the child workflows.

If you're using something like Kustomize or Helm, it's possible your changes might delete/recreate the cron workflows rather than simply patching them. You'd have to check the docs of those projects.

I agree, the docs should be more clear. I'd recommend opening a PR against their argo cron delete page.

-- crenshaw-dev
Source: StackOverflow

10/29/2020

To add to Michael's answer:

CronWorkflows are owners of all the Workflows they spawn, so how their respective Workflows are deleted when the parent CronWorkflow is deleted is governed by Kubernetes' Garbage Collection policies. Argo does not delete the child Workflows of a CronWorkflow when the latter is deleted, Kuebrnetes does. You can see the Kubernetes doc for more options on how to manage this.

(Edit: adding more info)

For example, to delete a CronWorkflow while leaving its children Workflows intact, you can run:

kubectl delete cwf my-cwf --cascade=false

Source: I developed the CronWorkflow feature.

-- Simon
Source: StackOverflow