Skip to content

Comments

Break out task step into core and runtime sides#4109

Merged
ddadlani merged 9 commits intomasterfrom
separate-runtime
Jul 29, 2019
Merged

Break out task step into core and runtime sides#4109
ddadlani merged 9 commits intomasterfrom
separate-runtime

Conversation

@ddadlani
Copy link
Contributor

@ddadlani ddadlani commented Jul 8, 2019

This is a draft PR to attempt splitting out the TaskStep into core-specific and runtime-specific concerns.

The idea is to put all runtime-specific concerns for all steps into the worker.Client so that we have a single place to optimize container placement and worker selection for stories such as #3695, #2928 and #3301. This PR attempts it only for the task step.

The tests do not currently pass, however this is a draft PR so that others can give their feedback on this approach. Fixing the tests is a work in progress.

@kcmannem
Copy link
Contributor

kcmannem commented Jul 8, 2019

I like this change

ImageFetcherSpec,
TaskProcessSpec,
chan string,
) (int, []VolumeMount, error)
Copy link
Contributor

Choose a reason for hiding this comment

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

Why is Run returning VolumeMount?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Because we need to registerOutputs in the TaskStep. Decoupling volumes/storage from Running a step is something we would need to look into, but in the absence of a separate Storage implementation, we would have to return volumes this way.

For example, we would likely register "outputs" beforehand with a specific storage implementation, and then de-register them if the task failed. That would allow us to not depend on VolumeMounts in the future.

@xtreme-sameer-vohra
Copy link
Contributor

Overall, the Task Step looks much simpler than before and once this style of refactoring is applied to the other steps, they might similarly become much more cleaner, to the point, where there may arise 1 or 2 generic steps.

One thing to watch out for is how Client would evolve as a result of this path ( once we add the other steps) . Might it become quite large with lots of state to initialize and private functions to DRY things up. This might in turn making testing much more complicated as it becomes a thick client. In this regard, the current step design (eg. K8sTaskStep, GardenTaskStep ) would be smaller interfaces with dependencies can easily be injected for testing.

@ddadlani
Copy link
Contributor Author

@xtreme-sameer-vohra thanks for reviewing the PR!

Overall, the Task Step looks much simpler than before and once this style of refactoring is applied to the other steps, they might similarly become much more cleaner, to the point, where there may arise 1 or 2 generic steps.

@nader-ziada and I were looking at the code, and we realized that the Get and Put steps and Checks also do a very similar thing, in that they select a worker, create a container and then run a defined script which is very similar to the setup for the task script. In the future, ideally we would be able to remove the concept of a "type" of step from runtime, and instead have a defined set of things (select worker, create container, run script, return result) that would allow us to run any kind of step.

One thing to watch out for is how Client would evolve as a result of this path ( once we add the other steps) . Might it become quite large with lots of state to initialize and private functions to DRY things up. This might in turn making testing much more complicated as it becomes a thick client. In this regard, the current step design (eg. K8sTaskStep, GardenTaskStep ) would be smaller interfaces with dependencies can easily be injected for testing.

I agree. Currently worker.Client is making a lot of decisions on what to do. In the ideal future I would see it become runtime.Client which simply decides on what runtime backend to use and then invoke the required method on that. The code currently in worker.Client is more suited to being in a runtime implementation rather than in a client. Hopefully future refactor efforts enable this view.

Divya Dadlani and others added 3 commits July 15, 2019 16:41
move worker-specific logic into worker.Client

Signed-off-by: Divya Dadlani <[email protected]>
use TaskResult as return value

Signed-off-by: Nader Ziada <[email protected]>
Divya Dadlani added 2 commits July 23, 2019 16:49
Fix conflicts caused by PR #4118 - addition of `limit-task-step`
container placement strategy
#4052

Signed-off-by: Divya Dadlani <[email protected]>
@ddadlani ddadlani marked this pull request as ready for review July 23, 2019 21:41
@ddadlani ddadlani marked this pull request as ready for review July 26, 2019 15:24
go func(logger lager.Logger, config atc.TaskConfig, events chan runtime.Event, delegate TaskDelegate) {
for ev := range events {
switch ev.EventType {
case runtime.InitializingEvent:
Copy link
Contributor

Choose a reason for hiding this comment

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

Doesn't look like this event is called ?

case runtime.StartingEvent:
step.delegate.Starting(logger, config)

case runtime.FinishedEvent:
Copy link
Contributor

Choose a reason for hiding this comment

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

Doesn't look like this event is called ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

we'll address these changes in a follow up PR because it's been a while since this PR has been open and keeping it up to date with master is problematic.

}

step.succeeded = (status == 0)
close(events)
Copy link
Contributor

Choose a reason for hiding this comment

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

Should it be RunTaskStep's responsibility to close the channel since it is the producer?

- task_step - move event processing block closer to consumer
- worker/client.go - avoid hoisting to improve readability
Minor refactor

Signed-off-by: Divya Dadlani <[email protected]>
@ddadlani ddadlani mentioned this pull request Jul 29, 2019
@ddadlani
Copy link
Contributor Author

Another thing to consider is that for heavy tasks like Strabo, we will be creating a lot more goroutines since a new event goroutine is created for every task container

@ddadlani ddadlani merged commit d89eca9 into master Jul 29, 2019
@ddadlani ddadlani deleted the separate-runtime branch August 1, 2019 15:32
@jamieklassen jamieklassen added this to the v5.5.0 milestone Aug 26, 2019
@jamieklassen
Copy link
Member

@concourse/runtime can you folks decide whether this needs a release note? On the surface it's a refactor, but I see allusions to operability effects. If it doesn't need a release note, just add the release/undocumented tag, and if it does need one, can you open a PR making the appropriate modifications to https://github.com/concourse/concourse/blob/master/release-notes/latest.md.

@xtreme-sameer-vohra
Copy link
Contributor

@pivotal-jamie-klassen
The change should be transparent to users so I don't believe we want to include anything in the release notes.

@ddadlani
Only a single go routine would be created to manage the events per task as opposed to new go routine per event ?

@ddadlani
Copy link
Contributor Author

I agree with @xtreme-sameer-vohra , I don't think this needs to be documented because behavior shouldn't change for our users. I'll add the label now.

@xtreme-sameer-vohra not sure what you mean? We did not have goroutines for task events before this change

@ddadlani ddadlani added the release/undocumented This didn't warrant being documented or put in release notes. label Aug 27, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

release/undocumented This didn't warrant being documented or put in release notes.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants