Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Propagate creator labels of a CronWorkflow to the Workflow to be scheduled #11407

Merged

Conversation

umi0410
Copy link
Contributor

@umi0410 umi0410 commented Jul 20, 2023

Fixes #7286

Motivation

Currently, the creator labels of a CronWorkflow that has creator labels are not propagated to the Workflow to be scheduled.

Modifications

I made some labels related to the creator of a CronWorkflow to be propagated to the Workflow to be created.
The list of labels is as follows.

  • workflows.argoproj.io/creator
  • workflows.argoproj.io/creator-email
  • workflows.argoproj.io/creator-preferred-username

Verification

  1. Create a simple CronWorkflow like the following in the web console of an SSO-enabled environment:
    metadata:
      name: cron-workflow-test
    spec:
      workflowSpec:
        templates:
          - name: whalesay
            inputs: {}
            outputs: {}
            metadata: {}
            container:
              name: ''
              image: alpine:3.6
              command:
                - sh
                - '-c'
              args:
                - date; sleep 3
              resources: {}
        entrypoint: whalesay
        arguments: {}
      schedule: '* * * * *'
      concurrencyPolicy: Replace
      startingDeadlineSeconds: 0
  2. You can see the created CronWorkflow has some labels related to the creator's account:
    $ kubectl get cronwf cron-workflow-test -o yaml | yq '.metadata.labels'
      workflows.argoproj.io/creator: xxxxxxxxx-yyy-zzzz-aaaa-bbbbbbbbbb
      workflows.argoproj.io/creator-email: foo.at.example.com
      workflows.argoproj.io/creator-preferred-username: foo
  3. You can also see the Workflow created has the same creator-related labels. This is the new feature of this PR.
    $ kubectl get wf cron-workflow-test-1689872520 -o yaml | yq '.metadata.labels'
      workflows.argoproj.io/completed: "true"
      workflows.argoproj.io/creator: xxxxxxxxx-yyy-zzzz-aaaa-bbbbbbbbbb
      workflows.argoproj.io/creator-email: foo.at.example.com
      workflows.argoproj.io/creator-preferred-username: foo
      workflows.argoproj.io/cron-workflow: cron-workflow-test
      workflows.argoproj.io/phase: Succeeded
  4. Additionally, when loglevel of workflow-controller is set to debug, you can see the log of propagating sso labels at workflow-controller.
    The following is an example of logs about my account.
    time="2023-07-20T16:44:00.003Z" level=debug msg="propagated the label of the cron workflow to the workflow to be scheduled." key=workflows.argoproj.io/creator value=xxxxxxxxx-yyy-zzzz-aaaa-bbbbbbbbbb
    time="2023-07-20T16:44:00.003Z" level=debug msg="propagated the label of the cron workflow to the workflow to be scheduled." key=workflows.argoproj.io/creator-email value=foo.at.example.com
    time="2023-07-20T16:44:00.003Z" level=debug msg="propagated the label of the cron workflow to the workflow to be scheduled." key=workflows.argoproj.io/creator-preferred-username value=foo
    

…e scheduled

Signed-off-by: Jinsu Park <dev.umijs@gmail.com>
@umi0410 umi0410 force-pushed the propagate-cwf-sso-labels-to-wf branch from 015d0fd to d511cd3 Compare July 20, 2023 17:10
Copy link
Member

@terrytangyuan terrytangyuan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is great. Thanks!

@terrytangyuan terrytangyuan enabled auto-merge (squash) July 20, 2023 17:51
@terrytangyuan terrytangyuan merged commit 0d78208 into argoproj:master Jul 21, 2023
24 checks passed
@agilgur5 agilgur5 added this to the v3.5.0 milestone Jul 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Pass SSO labels to workflows from conworkflows.
3 participants