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

Add doc for break feature for loop #749

Merged
merged 2 commits into from
Oct 14, 2021

Conversation

pugangxa
Copy link
Contributor

@pugangxa pugangxa commented Oct 9, 2021

The feature to support break in pipelineloop is already implemented. This is to add the document for that.

Can refer to the code

lastLoopTask := ""
for key, val := range run.ObjectMeta.Labels {
if key == "last-loop-task" {
lastLoopTask = val
}
}
if lastLoopTask != "" {
skippedTaskList := pr.Status.SkippedTasks
for _, task := range skippedTaskList {
if task.Name == lastLoopTask {
// Mark run successful and stop the loop pipelinerun
run.Status.MarkRunSucceeded(pipelineloopv1alpha1.PipelineLoopRunReasonSucceeded.String(),
"PipelineRuns completed successfully with the conditions are met")
run.Status.Results = []runv1alpha1.RunResult{{
Name: "condition",
Value: "pass",
}}
}
}
}

I just run the example https://github.com/kubeflow/kfp-tekton/blob/master/tekton-catalog/pipeline-loops/examples/pipelinespec-with-run-condition.yaml and it works well, you can see the loop is defined to run 3 times but break when condition met while just run 2 times.

➜  examples git:(master) ✗ k describe run simplepipelinelooprun
Name:         simplepipelinelooprun
Namespace:    gang-test
Labels:       custom.tekton.dev/pipelineLoop=conditionloop
              last-loop-task=task-fail
Annotations:  kubectl.kubernetes.io/last-applied-configuration:
                {"apiVersion":"custom.tekton.dev/v1alpha1","kind":"PipelineLoop","metadata":{"annotations":{},"name":"conditionloop","namespace":"gang-tes...
API Version:  tekton.dev/v1alpha1
Kind:         Run
......................
Events:
  Type    Reason     Age                    From              Message
  ----    ------     ----                   ----              -------
  Normal  Started    2m36s (x2 over 2m36s)  run-pipelineloop
  Normal  Running    2m36s (x2 over 2m36s)  run-pipelineloop  Iterations completed: 0
  Normal  Running    2m10s                  run-pipelineloop  Iterations completed: 1
  Normal  Succeeded  2m5s (x2 over 2m5s)    run-pipelineloop  PipelineRuns completed successfully with the conditions are met

@pugangxa
Copy link
Contributor Author

pugangxa commented Oct 9, 2021

@Udiknedormin I have added the document for break feature for loop, please let me know if something unclear.
Note:

  • Now there's no DSL interface in dsl.ParallelFor, may need enhance.
  • Only one task can be specified now, may need enhance. Before remember we considered to specify it in CRD and support list but seems it's enough with current design.
  • For parallelism it will just break and stop starting new pipelineruns but the ones that already started will continue running.

@Tomcli
Copy link
Member

Tomcli commented Oct 13, 2021

@pugangxa @Udiknedormin is this PR ready to merge?

For DSL support on this feature, we probably need to know some workflow use cases. If we just want to experiment with it, we can use the task annotations as the feature flag to enable breaks.

@pugangxa
Copy link
Contributor Author

@pugangxa @Udiknedormin is this PR ready to merge?

For DSL support on this feature, we probably need to know some workflow use cases. If we just want to experiment with it, we can use the task annotations as the feature flag to enable breaks.

Yes there's requirements to support break in loop and this is to show the ability of that in pipeline loop now, I think we can let it go currently and enhance later when requirement is more clear, thanks.

@Tomcli
Copy link
Member

Tomcli commented Oct 14, 2021

/lgtm
/approve

@google-oss-robot
Copy link

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: pugangxa, Tomcli

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@google-oss-robot google-oss-robot merged commit 01ed233 into kubeflow:master Oct 14, 2021
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.

3 participants