diff --git a/cmd/argo/commands/verify.go b/cmd/argo/commands/verify.go index 65efc8a3d8cb..8e5d2848986d 100644 --- a/cmd/argo/commands/verify.go +++ b/cmd/argo/commands/verify.go @@ -13,7 +13,8 @@ import ( ) func verifyWorkflows(ctx context.Context, serviceClient workflowpkg.WorkflowServiceClient, namespace string, workflowNames []string) { - _, _ = fmt.Fprintln(os.Stderr, "verifying workflows...") + _, _ = fmt.Fprintln(os.Stdout) + _, _ = fmt.Fprintln(os.Stdout, "VERIFICATION") failAtEnd := false for _, name := range workflowNames { wf, err := serviceClient.GetWorkflow(ctx, &workflowpkg.WorkflowGetRequest{ diff --git a/docs/fields.md b/docs/fields.md index ef7aff564a9a..03316a1ae3b3 100644 --- a/docs/fields.md +++ b/docs/fields.md @@ -136,6 +136,8 @@ Workflow is the definition of a workflow resource - [`k8s-owner-reference.yaml`](https://github.com/argoproj/argo-workflows/blob/master/examples/k8s-owner-reference.yaml) +- [`k8s-patch.yaml`](https://github.com/argoproj/argo-workflows/blob/master/examples/k8s-patch.yaml) + - [`k8s-set-owner-reference.yaml`](https://github.com/argoproj/argo-workflows/blob/master/examples/k8s-set-owner-reference.yaml) - [`k8s-wait-wf.yaml`](https://github.com/argoproj/argo-workflows/blob/master/examples/k8s-wait-wf.yaml) @@ -481,6 +483,8 @@ WorkflowSpec is the specification of a Workflow. - [`k8s-owner-reference.yaml`](https://github.com/argoproj/argo-workflows/blob/master/examples/k8s-owner-reference.yaml) +- [`k8s-patch.yaml`](https://github.com/argoproj/argo-workflows/blob/master/examples/k8s-patch.yaml) + - [`k8s-set-owner-reference.yaml`](https://github.com/argoproj/argo-workflows/blob/master/examples/k8s-set-owner-reference.yaml) - [`k8s-wait-wf.yaml`](https://github.com/argoproj/argo-workflows/blob/master/examples/k8s-wait-wf.yaml) @@ -844,6 +848,8 @@ CronWorkflowSpec is the specification of a CronWorkflow - [`k8s-owner-reference.yaml`](https://github.com/argoproj/argo-workflows/blob/master/examples/k8s-owner-reference.yaml) +- [`k8s-patch.yaml`](https://github.com/argoproj/argo-workflows/blob/master/examples/k8s-patch.yaml) + - [`k8s-set-owner-reference.yaml`](https://github.com/argoproj/argo-workflows/blob/master/examples/k8s-set-owner-reference.yaml) - [`k8s-wait-wf.yaml`](https://github.com/argoproj/argo-workflows/blob/master/examples/k8s-wait-wf.yaml) @@ -1165,6 +1171,8 @@ WorkflowTemplateSpec is a spec of WorkflowTemplate. - [`k8s-owner-reference.yaml`](https://github.com/argoproj/argo-workflows/blob/master/examples/k8s-owner-reference.yaml) +- [`k8s-patch.yaml`](https://github.com/argoproj/argo-workflows/blob/master/examples/k8s-patch.yaml) + - [`k8s-set-owner-reference.yaml`](https://github.com/argoproj/argo-workflows/blob/master/examples/k8s-set-owner-reference.yaml) - [`k8s-wait-wf.yaml`](https://github.com/argoproj/argo-workflows/blob/master/examples/k8s-wait-wf.yaml) @@ -1812,6 +1820,8 @@ Template is a reusable and composable unit of execution in a workflow - [`k8s-owner-reference.yaml`](https://github.com/argoproj/argo-workflows/blob/master/examples/k8s-owner-reference.yaml) +- [`k8s-patch.yaml`](https://github.com/argoproj/argo-workflows/blob/master/examples/k8s-patch.yaml) + - [`k8s-set-owner-reference.yaml`](https://github.com/argoproj/argo-workflows/blob/master/examples/k8s-set-owner-reference.yaml) - [`k8s-wait-wf.yaml`](https://github.com/argoproj/argo-workflows/blob/master/examples/k8s-wait-wf.yaml) @@ -2871,6 +2881,8 @@ ResourceTemplate is a template subtype to manipulate kubernetes resources - [`k8s-owner-reference.yaml`](https://github.com/argoproj/argo-workflows/blob/master/examples/k8s-owner-reference.yaml) +- [`k8s-patch.yaml`](https://github.com/argoproj/argo-workflows/blob/master/examples/k8s-patch.yaml) + - [`k8s-set-owner-reference.yaml`](https://github.com/argoproj/argo-workflows/blob/master/examples/k8s-set-owner-reference.yaml) - [`k8s-wait-wf.yaml`](https://github.com/argoproj/argo-workflows/blob/master/examples/k8s-wait-wf.yaml) @@ -3568,6 +3580,10 @@ MetricLabel is a single label for a prometheus metric - [`hello-world.yaml`](https://github.com/argoproj/argo-workflows/blob/master/examples/hello-world.yaml) +- [`k8s-owner-reference.yaml`](https://github.com/argoproj/argo-workflows/blob/master/examples/k8s-owner-reference.yaml) + +- [`k8s-patch.yaml`](https://github.com/argoproj/argo-workflows/blob/master/examples/k8s-patch.yaml) + - [`output-result-workflow.yaml`](https://github.com/argoproj/argo-workflows/blob/master/examples/output-result-workflow.yaml) - [`pod-metadata-wf-field.yaml`](https://github.com/argoproj/argo-workflows/blob/master/examples/pod-metadata-wf-field.yaml) @@ -4008,6 +4024,8 @@ ObjectMeta is metadata that all persisted resources must have, which includes al - [`k8s-owner-reference.yaml`](https://github.com/argoproj/argo-workflows/blob/master/examples/k8s-owner-reference.yaml) +- [`k8s-patch.yaml`](https://github.com/argoproj/argo-workflows/blob/master/examples/k8s-patch.yaml) + - [`k8s-set-owner-reference.yaml`](https://github.com/argoproj/argo-workflows/blob/master/examples/k8s-set-owner-reference.yaml) - [`k8s-wait-wf.yaml`](https://github.com/argoproj/argo-workflows/blob/master/examples/k8s-wait-wf.yaml) @@ -4561,6 +4579,8 @@ A single application container that you want to run within a pod. - [`k8s-orchestration.yaml`](https://github.com/argoproj/argo-workflows/blob/master/examples/k8s-orchestration.yaml) +- [`k8s-owner-reference.yaml`](https://github.com/argoproj/argo-workflows/blob/master/examples/k8s-owner-reference.yaml) + - [`k8s-wait-wf.yaml`](https://github.com/argoproj/argo-workflows/blob/master/examples/k8s-wait-wf.yaml) - [`key-only-artifact.yaml`](https://github.com/argoproj/argo-workflows/blob/master/examples/key-only-artifact.yaml) @@ -4958,13 +4978,6 @@ ManagedFieldsEntry is a workflow-id, a FieldSet and the group version of the res OwnerReference contains enough information to let you identify an owning object. An owning object must be in the same namespace as the dependent, or be cluster-scoped, so there is no namespace field. -
-Examples with this field (click to open) -
- -- [`k8s-owner-reference.yaml`](https://github.com/argoproj/argo-workflows/blob/master/examples/k8s-owner-reference.yaml) -
- ### Fields | Field Name | Field Type | Description | |:----------:|:----------:|---------------| @@ -5197,6 +5210,8 @@ PersistentVolumeClaimSpec describes the common attributes of storage devices and - [`k8s-owner-reference.yaml`](https://github.com/argoproj/argo-workflows/blob/master/examples/k8s-owner-reference.yaml) +- [`k8s-patch.yaml`](https://github.com/argoproj/argo-workflows/blob/master/examples/k8s-patch.yaml) + - [`k8s-set-owner-reference.yaml`](https://github.com/argoproj/argo-workflows/blob/master/examples/k8s-set-owner-reference.yaml) - [`k8s-wait-wf.yaml`](https://github.com/argoproj/argo-workflows/blob/master/examples/k8s-wait-wf.yaml) diff --git a/examples/k8s-owner-reference.yaml b/examples/k8s-owner-reference.yaml index e0dae0fa5362..52550fab28a4 100644 --- a/examples/k8s-owner-reference.yaml +++ b/examples/k8s-owner-reference.yaml @@ -1,30 +1,35 @@ -# This example creates a Kubernetes resource that will be deleted -# when the workflow is deleted via Kubernetes GC. -# -# A configmap is used for this example, but the same approach would apply -# to other more interesting resource types. -# -# https://kubernetes.io/docs/concepts/workloads/controllers/garbage-collection/ apiVersion: argoproj.io/v1alpha1 kind: Workflow metadata: generateName: k8s-owner-reference- + labels: + workflows.argoproj.io/test: "true" + annotations: + workflows.argoproj.io/description: | + This example creates a Kubernetes resource that will be deleted + when the workflow is deleted via Kubernetes GC. + + A workflow is used for this example, but the same approach would apply + to other resource types. + + https://kubernetes.io/docs/concepts/workloads/controllers/garbage-collection/ + workflows.argoproj.io/verify.py: | + assert status["phase"] == "Succeeded" spec: - entrypoint: k8s-owner-reference + entrypoint: main templates: - - name: k8s-owner-reference - resource: - action: create - manifest: | - apiVersion: v1 - kind: ConfigMap - metadata: - generateName: owned-eg- - ownerReferences: - - apiVersion: argoproj.io/v1alpha1 - blockOwnerDeletion: true - kind: Workflow - name: "{{workflow.name}}" - uid: "{{workflow.uid}}" - data: - some: value + - name: main + resource: + action: create + setOwnerReference: true + manifest: | + apiVersion: argoproj.io/v1alpha1 + kind: Workflow + metadata: + generateName: owned-eg- + spec: + entrypoint: main + templates: + - name: main + container: + image: argoproj/argosay:v2 \ No newline at end of file diff --git a/examples/k8s-patch.yaml b/examples/k8s-patch.yaml new file mode 100644 index 000000000000..efb329c507e0 --- /dev/null +++ b/examples/k8s-patch.yaml @@ -0,0 +1,25 @@ +apiVersion: argoproj.io/v1alpha1 +kind: Workflow +metadata: + generateName: k8s-patch- + labels: + workflows.argoproj.io/test: "true" + annotations: + workflows.argoproj.io/description: | + This example patches + workflows.argoproj.io/verify.py: | + assert status["phase"] == "Succeeded" +spec: + entrypoint: main + templates: + - name: main + resource: + action: patch + mergeStrategy: json + flags: + - pod + - "{{pod.name}}" + manifest: | + - op: add + path: /metadata/annotations/foo + value: bar \ No newline at end of file diff --git a/manifests/quick-start/base/workflow-role.yaml b/manifests/quick-start/base/workflow-role.yaml index ee483e53355c..f71a23833ec7 100644 --- a/manifests/quick-start/base/workflow-role.yaml +++ b/manifests/quick-start/base/workflow-role.yaml @@ -5,7 +5,6 @@ metadata: name: workflow-role rules: # pod get/watch is used to identify the container IDs of the current pod - # pod patch is used to annotate the step's outputs back to controller (e.g. artifact location) - apiGroups: - "" resources: @@ -13,6 +12,8 @@ rules: verbs: - get - watch + # pod patch is used to annotate the step's outputs back to controller (e.g. artifact location) + # This is ONLY needed if the step/task has outputs that are used by another step or task. - patch # logs get/watch are used to get the pods logs for script outputs, and for log archival - apiGroups: @@ -23,7 +24,7 @@ rules: - get - watch # This allows one workflow to create another. - # Not needed for the majority of use cases. + # This is only needed for resource templates. - apiGroups: - argoproj.io resources: diff --git a/workflow/verify/verifier.go b/workflow/verify/verifier.go index 0d261220659f..d6854691da4b 100644 --- a/workflow/verify/verifier.go +++ b/workflow/verify/verifier.go @@ -18,7 +18,8 @@ func Workflow(wf *wfv1.Workflow) error { nodes[n.DisplayName] = n } return python.Run(verify, map[string]interface{}{ - "metadata": wf, + "metadata": wf.ObjectMeta, + "spec": wf.Spec, "nodes": nodes, "status": wf.Status, })