Skip to content

clean-jobs workflow step doesn't clean jobs created with WorkflowRun #178

Closed
kubevela/catalog
#738
@oanasc

Description

@oanasc

Describe the bug
WorkflowRun creates a job that is labeled with workflowrun.oam.dev/name and the underlying pod is labeled with workflow.oam.dev/name this difference means clean-jobs is not deleting the jobs when there aren't any matchingLabels provided.

To Reproduce
Steps to reproduce the behavior:

  1. Apply an WorkflowRun, in this example is an addon but should behave the same way with any
apiVersion: core.oam.dev/v1alpha1
kind: WorkflowRun
metadata:
  name: enable-addons-test
  namespace: vela-system
spec:
  mode: 
  workflowSpec:
    steps:
      - name: Enable chartmuseum
        type: addon-operation
        properties:
          addonName: chartmuseum
          operation: enable
          args:
          - --override-definitions

      - name: Clean
        type: clean-jobs
        if: always
        properties:
          namespace: "vela-system"
  1. The first step creates a job and a pod, notice the difference in the labels between the pod using workflow.* and the job using workflowrun.*
apiVersion: v1
kind: Pod
metadata:
  name: enable-addons-test-qealctrkbx-gx2dr
  generateName: enable-addons-test-qealctrkbx-
  namespace: vela-system
  labels:
    workflow.oam.dev/name: enable-addons-test
    workflow.oam.dev/session: qealctrkbx
   ...
--
apiVersion: batch/v1
kind: Job
metadata:
  name: enable-addons-test-qealctrkbx
  namespace: vela-system
  labels:
    enable-addon.oam.dev: enable-addons-test
    workflowrun.oam.dev/name: enable-addons-test
    workflowrun.oam.dev/namespace: vela-system
    ...
  1. Then the clean-jobs runs and that tries for filter both the job and the pod a single parameter for matchingLabels which results in only the pods being cleaned up
if parameter.labelselector == _|_ {
    matchingLabels: "workflow.oam.dev/name": context.name
}

Expected behavior
It should cleanup both pods and jobs

Additional context
A couple of options when it comes to the fix:

  • should the pod have the workflowrun annotation?
  • or should the clean-jobs delete if is workflow or workflowrun which is a trivial fix

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions