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

feature: add validation for what flow the run_id belongs to #1452

Conversation

saikonen
Copy link
Collaborator

@saikonen saikonen commented Jun 13, 2023

The new CLI commands for argo-workflows that accept a run_id have had a pending issue regarding production token authorization, and lacking any guard against passing an arbitrary run_id to a flow file that the user has a valid production token for.

This PR introduces checks for

  • the run_id is of the same flow_name as the CLI command was issued on
  • the run_id is of the same project and branch as the CLI command was issued on
  • the user issuing the command has a production token for the workflow with the run_id
  • the run_id is for an Argo Workflow (existing prefix check, simply moved it to the same validation function)

@saikonen saikonen requested a review from savingoyal June 13, 2023 13:23
# Project and branch are stored in the workflow template name so this is the easiest comparison to perform.
if workflow_name != deployed_workflow_template_name:
raise MetaflowException(
"The run_id *%s* belongs to the workflow *%s*, not to the workflow *%s*\n"
Copy link
Collaborator

Choose a reason for hiding this comment

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

We don't communicate to the user how deployed_workflow_template_name is imputed. Can we check for project_name and branch_name and compare them with that?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Added some more robust checks that separately verify that the user is targeting the correct branch and project, and notifying which one is not matching the deployed workflow. Do the changes seem adequate?

@saikonen saikonen requested a review from savingoyal June 19, 2023 17:27
@saikonen saikonen merged commit 63cc392 into feature/add-argo-workflows-suspend-command Jun 26, 2023
@saikonen saikonen deleted the feature/add-run_id-validation branch June 26, 2023 16:28
saikonen added a commit that referenced this pull request Jun 26, 2023
* first draft of suspend/unsuspend for argo

* rename run_id arg to name

* move exception for workflow not found

* move argo workflow name validation to cli

* decouple pause method

* add production token validation

* feature: add validation for what flow the run_id belongs to (#1452)

* add validation for what flow the run_id belongs to

* test using workflow production token for authorization directly.

* rework run_id validation to perform separate checks for project_name and branch_name, accounting for --name. refactor Argo resource name sanitization
wangchy27 pushed a commit that referenced this pull request Jul 13, 2023
* first draft of suspend/unsuspend for argo

* rename run_id arg to name

* move exception for workflow not found

* move argo workflow name validation to cli

* decouple pause method

* add production token validation

* feature: add validation for what flow the run_id belongs to (#1452)

* add validation for what flow the run_id belongs to

* test using workflow production token for authorization directly.

* rework run_id validation to perform separate checks for project_name and branch_name, accounting for --name. refactor Argo resource name sanitization
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants