Closed
Description
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:
- 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"
- 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
...
- 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
Labels
No labels