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 createPipelineRun to Pipeline Controller #93

Merged
merged 2 commits into from
Oct 5, 2018

Conversation

tejal29
Copy link
Contributor

@tejal29 tejal29 commented Oct 4, 2018

This addresses a part of #61.
In this commit, we are adding createPipelineRun to PipelineRun Controller.
This method will be used in PipelineRun.reconcile in future when we detect the pipelineRun
does not have tasksruns for tasks in the pipeline.

@knative-prow-robot
Copy link

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: tejal29

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

@knative-prow-robot knative-prow-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. approved Indicates a PR has been approved by an approver from all required OWNERS files. labels Oct 4, 2018
@tejal29 tejal29 force-pushed the invoke_tasks branch 3 times, most recently from bc36991 to a903657 Compare October 4, 2018 07:03
Copy link
Member

@nader-ziada nader-ziada left a comment

Choose a reason for hiding this comment

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

nice!

should the PipelineRun just create the first taskRun and let the taskRun controller create the following ones if the first passes? it works also if all taskRun are created, but this will make the testRun controller more complicated since it will have to wait for the one taskRun to finish before creating a build for the next one

}

// TODO fetch the taskruns status for this pipeline run.
Copy link
Member

Choose a reason for hiding this comment

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

should probably call createPipelineRun() here

// TODO fetch the taskruns status for this pipeline run.

// TODO check status of tasks and update status of PipelineRuns

return nil
}

func (c *Reconciler) createPipelineRun(ctx context.Context, p *v1alpha1.Pipeline) error {
Copy link
Member

Choose a reason for hiding this comment

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

this func is actually not creating the pipelineRun, its creating the contents of the pipelineRun, so maybe we can add something to the name to make it more clear. Maybe createPipelineRunTaskRuns or something?

}

func randomizeTaskRunName(t *v1alpha1.Task) string {
return util.AppendRandomString(t.Name)
Copy link
Member

Choose a reason for hiding this comment

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

can we just use the name of the pipeline in combination with the name of the task?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

i can add pipeline-run name in combination of name of task hoping we would a unique name for each pipeline-run.

return util.AppendRandomString(t.Name)
}

func (c *Reconciler) getPipelineIfExists(pr *v1alpha1.PipelineRun) (*v1alpha1.Pipeline, error) {
Copy link
Member

Choose a reason for hiding this comment

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

no need for IfExists in the name

@@ -11,7 +11,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

package test
package util
Copy link
Member

Choose a reason for hiding this comment

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

I don't think we need this

if err != nil {
return errors.NewBadRequest(fmt.Sprintf("pipeline %q is not valid due to %v", p.Name, err))
}
for _, t := range tasks {
Copy link
Member

Choose a reason for hiding this comment

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

check my comment in the review, should we create all taskRun or just the first one and taskRun controller can do the rest?

@tejal29
Copy link
Contributor Author

tejal29 commented Oct 4, 2018

@pivotal-nader-ziada Thanks! I completely forgot the flow. For the initial demo we were targeting linear pipeline. However, in future, it should be able to run tasks in parallel. we probably need to have a method that should check if all inputs for a given task are available and then run.

@tejal29 tejal29 force-pushed the invoke_tasks branch 2 times, most recently from d810552 to 7e3ef32 Compare October 4, 2018 22:48
@nader-ziada
Copy link
Member

looks good, but has conflicts now because of #97

Just one nit: can you remove the fmt.Println(p) in pipelinerun.go

if err != nil {
return err
}
c.PipelineClientSet.PipelineV1alpha1().TaskRuns(p.Namespace).Create(tr)
Copy link
Member

Choose a reason for hiding this comment

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

Can we move the this line inside the createTask func, also check for any errors coming back

In this commit, we are adding createPipelineRun to PipelineRun Controller.
This method will be used in PipelineRun.reconcile in future when we detect the pipelineRun
does not any taskruns for tasks in the pipeline.
In previous commit, the pipeline controller creates TaskRuns for
all tasks in the PipelineSpec. I changed to only create one `TaskRun`.
It creates a `TaskRun` for the first `Task` for which `TaskRun` does not
exist.
@tejal29
Copy link
Contributor Author

tejal29 commented Oct 5, 2018

@pivotal-nader-ziada This is ready for last look. Sorry, i messed the commit history. Instead of running git commit -m i ran git commit --amend

@nader-ziada
Copy link
Member

/lgtm

@knative-prow-robot knative-prow-robot added the lgtm Indicates that a PR is ready to be merged. label Oct 5, 2018
@knative-prow-robot knative-prow-robot merged commit 96a8b6f into tektoncd:master Oct 5, 2018
khrm pushed a commit to khrm/pipeline that referenced this pull request Jul 23, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. lgtm Indicates that a PR is ready to be merged. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants