Skip to content

feat(atc): add set_pipeline step. - #4708

Merged
vito merged 14 commits into
concourse:masterfrom
evanchaoli:set-pipeline
Dec 5, 2019
Merged

vito merged 14 commits into
concourse:masterfrom
evanchaoli:set-pipeline

Conversation

@evanchaoli

@evanchaoli evanchaoli commented Nov 5, 2019 •

Copy link
Copy Markdown
Contributor

Existing Issue

There is a RFC concourse/rfc#31.

Why do we need this PR?

This will enable to automatically reset a pipeline from itself.

Changes proposed in this pull request

  • Set a new step set_pipeline as well as events of it.

Test pipeline:

resources:
- name: mygit
  type: git
  source:
    uri: [email protected]:chaol/fortest.git
    branch: master
    private_key: ((chaol-gitlab-private-key))

jobs:
- name: self-reset
  public: true
  plan:
  - get: mygit
    trigger: true
  - set_pipeline: sp
    params:
      pipeline_name: self
      config: mygit/test_self_reset.yml
      load_vars_from:
       - mygit/credential.yml

- name: normal-job
  public: true
  plan:
  - task: a-task
    config:
      platform: linux
      image_resource:
        type: registry-image
        source: {repository: busybox}
      run:
        path: sh
        args:
         - -exc
         - |
           echo hello2

There are two jobs in this pipeline. The first job is used to self-reset the pipeline. The second job is a normal job.

The web UI should be updated also, my backend code has been able to successfully set-pipeline, but UI cannot display the entire build. @Twiknight is helping on the UI change.

Contributor Checklist

Are the following items included as part of this PR? Please delete checkbox items that don't apply.

Reviewer Checklist

This section is intended for the core maintainers only, to track review progress. Please do not
fill out this section.

  • Code reviewed
  • Tests reviewed
  • Documentation reviewed
  • Release notes reviewed
  • PR acceptance performed
  • New config flags added? Ensure that they are added to the BOSH
    and Helm packaging; otherwise, ignored for the integration tests (for example, if they are Garden configs that are not displayed in the --help text).

@evanchaoli
evanchaoli requested review from a team November 5, 2019 08:56
Comment thread atc/exec/set_pipeline_step.go Resolved
Comment thread atc/exec/set_pipeline_step.go Resolved
@evanchaoli
evanchaoli force-pushed the set-pipeline branch 3 times, most recently from ee7d492 to b730f8d Compare November 6, 2019 06:26
@evanchaoli

evanchaoli commented Nov 6, 2019 •

Copy link
Copy Markdown
Contributor Author

So far, I have made the feature functional and the existing unit tests pass. @Twiknight also has done UI part changes, unit tests not added yet.

Highlights of the change:

  • Add set_pipeline step, which works similar to a task step, so that user may wrap on_success, on_failure, etc. steps around it to do error handling, notifying, and so on.
  • set_pipeline the following parameters (reflecting to fly set-pipeline command):
    • config: path of pipeline YAML file. The file should come from other resource, like git
    • pipeline_name: pipeline name to set. If name is self, then do self set.
    • var: variables passing to pipeline. (fly set-pipeline also supports --yaml-var option, but I think it's not needed if we define vars in YAML.)
    • load_vars_from: variable files. The files should come from other resources, like git.
    • fail_when_no_diff: When set to true, if there is pipeline change, the step will fail. Default is false. I add this flag in order to leave the flexibility to users.
  • Move config diff code from fly/command/internal/setpipelinehelper to atc/config_diff.go because the set_pipeline step also needs to do pipeline diff.

The web UI looks like below. As you can see, pipeline diff is shown on the UI.

self-set

Maybe we need a new icon for the set_pipeline step. However we are not good at art, so leaving that to some art talent to contribute with further PR.

@pivotal-jwinters and @vito Can you guys please take an initial review. If no significant comments, we'll start to add unit test cases. For this feature, maybe a testflight case is deserved.

@vito vito left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Awesome! This is the first step on our v10 roadmap so this is a pretty momentous occasion. 🙂

FWIW, I also had started on this a while back - mainly as a test of our contributor experience with adding a new step type. I wanted to find all the 'gotcha' places that the compiler couldn't help me find in hopes of being able to refactor those areas in the future.

If my changes are of any use to you for comparison, you can find them on the feature/set-pipeline-step branch - here's the diff. I snuck in some refactors along the way. Selfishly I would like to see some of those refactors here too but I'm happy to submit those as separate PRs. (I probably should have done that in the first place.)

This wip commit message has a few breadcrumbs for what I was working on.

Here's a tl;dr of my feedback:

  • We should avoid using params for core step types; I think it's important for that field to only ever be used as opaque schema-less config passed to resources/prototypes
    • use the x in set_pipeline: x as the pipeline name
    • use step-level file: (same field as task step) for specifying the pipeline config
    • use step-level vars: (same field task step) for specifying pipeline vars
    • introduce step-level vars_files: (instead of load_vars_from) - but IMO only if necessary. Do you need it for your own pipelines?
  • I'm +1 with handling self to set the current pipeline, but I wonder if that self syntax can be resolved to a pipeline name before we're running the step.
  • I don't think we should have a fail_when_no_diff; it should just succeed.
  • We can introduce generic initialize/start/finish events so we don't have to keep adding these 3 events for each step. It'd be nice if the web UI just had 3 events to handle for updating any step's progress in the UI.
  • There are various refactorings I'd like to see from my fork, but I don't expect you to do them. They're there if you want to steal the code, or I can just submit PRs for them later (or maybe even to your fork).

Thanks again for starting on this! Super cool to see our roadmap being pushed forward by the community. 🎊

Comment thread atc/db/pipeline.go Resolved
Comment thread atc/config_diff.go Resolved
Comment thread atc/config_diff.go Resolved
Comment thread atc/config_diff.go Resolved
Comment thread atc/config_diff.go Resolved
Comment thread atc/exec/set_pipeline_step.go Resolved
Comment thread atc/exec/set_pipeline_step.go Resolved
Comment thread atc/plan.go Resolved
Comment thread atc/plan.go Resolved
Comment thread atc/exec/set_pipeline_step.go Resolved
@vito

vito commented Nov 6, 2019

Copy link
Copy Markdown
Contributor

Also, since this started through the RFC process, we'll need to finish it through the RFC process as well: https://github.com/concourse/rfcs#resolution

It's fine to start working on it ahead of time, we just need to make sure what we actually deliver lines up with what everyone agreed on through the RFC. I don't expect any trouble here, it's just due diligence.

I'll try and finalize all of my v10 RFCs and start the resolution process soon, which will involve a blog post announcing it. I'll make note of this PR too. 🙂

@jamieklassen

Copy link
Copy Markdown

Big +1 on generic step events - our consumers of those events care about the different step types really. Like fly does show the task config before a task step but that could be made generic, I think.

@evanchaoli
evanchaoli force-pushed the set-pipeline branch 3 times, most recently from ed4cc5b to 2ba2ab9 Compare November 8, 2019 09:32

@vito vito left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

thanks for porting over some of the refactors! 👍

Comment thread atc/engine/builder/delegate_factory.go Resolved
Comment thread atc/event/types.go Resolved
Comment thread atc/event/types.go Resolved
Comment thread atc/event/types.go Resolved
Comment thread atc/exec/artifact/repository.go Resolved
Comment thread atc/exec/set_pipeline_step.go Resolved
Comment thread atc/exec/set_pipeline_step.go Resolved
Comment thread atc/set_pipeline.go Resolved
@evanchaoli

evanchaoli commented Nov 9, 2019 •

Copy link
Copy Markdown
Contributor Author

@vito I just addressed all current review comments for backend. UI change is still ongoing.

edit: UI part change has been done by @Twiknight. Most of UI changes are picked up from your commit. I have also added a testflight test for the set-pipeline step. We will start to add unit test cases once you have no significant comment for the current changes.

edit: I also created a PR for mock resource (concourse/mock-resource#3) to auto replace START_VAR/END_VAR with ((/)), so that we can easily create pipeline/task yml files with variables. Please take a look.

@evanchaoli

Copy link
Copy Markdown
Contributor Author

Screen shot with the latest UI change:

set-pipeline2

@evanchaoli
evanchaoli force-pushed the set-pipeline branch 2 times, most recently from 9b20633 to 0c72889 Compare November 11, 2019 08:20
Comment thread atc/scheduler/factory/build_factory.go Outdated
case planConfig.SetPipeline != "":
name := planConfig.SetPipeline
if name == "self" {
name = job.PipelineName()

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Does the db.Job get threaded through everywhere just so we can do this?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@pivotal-jwinters Sorry for my English. I don't quite get your point. Can you please explain more? And what's your suggestion?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@evanchaoli sorry my fault, I should have been more clear. It just seems like there are a lot of changes that need to be made in order to pass the db.Job object all the way down to this low level. I just wanted to confirm that the db.Job object is only needed because of the pipeline name, and if it is, maybe there's a simpler way of getting that info here.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@pivotal-jwinters Yeah, I wonder a simpler way too. Here the entry point is method buildFactory.Create. Obviously we cannot store a db.Job object in buildFactory because it is global and stateless. I initially thought to add pipelineName as an extra parameter to buildFactory.Create, but that would also need to thread the extra parameter through a lot of levels. So I decided to change the first parameter from JobConfig to Job, which at least keep count of parameters unchanged, and it make future change easier if some other info of job/pipeline is needed at any level.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@pivotal-jwinters Yeah, I ultimately suggested this so that we don't have to deal with interpreting self at the plan/step-level. Using the job here feels OK to me since it's at the pipeline/job -> plan translation stage and keeps us from having to pass pipeline information down to the generic plan/step types.

I guess I didn't anticipate the impact this would have on the tests though (having to pluck .Config off everywhere). To be honest these tests are already super high-maintenance so I guess it's not too surprising. I remember wanting to find a way to get better value out of how we test this stuff at some point.

@vito vito Nov 15, 2019 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@pivotal-jwinters The problem with waiting until everything is done perfectly is that we withold useful features in the short-term for the sake of having everything perfect in the long-term. In the meantime, users who try Concourse may be disappointed by the lack of basic functionality, and may just use something else. Remember, we're not here to just strive for a perfect design, we're working on software for people to use, and those users exist today. It doesn't help anyone if Concourse v10 finally ships but by then everyone has adopted other solutions that addressed their needs more quickly.

My point was that this could have been a useful MVP before we even came up with the idea for 'projects'. By getting that MVP out more quickly we would have at least met the basic needs of users already and collected useful feedback/information about how it's used. Maybe we would have even come up with a different idea. Maybe we would have come up with 'projects' and ultimately deprecated set_pipeline: self. Who knows?

We're lucky to have a pretty far view of the future plans right now - but I don't think we should let that long-term vision cheat us and our users out of short-term wins if we can also identify a transition from the short-term to the long-term. We need to balance our ideal roadmap with the time it takes to get there, and be conscious of the fact that not many of those features in the roadmap have been put in front of actual users yet.

At this point this discussion is more attached to ideology than technical details - in this case the basic functionality is still there, and at the end of the day we're debating a feature that's easy to replace with simple templating. I just think it's been a mistake of ours to continuously chase "perfect" at the expense of "good". We're going to have to be able to continuously iterate on, refactor, and deprecate Concourse functionality regardless. I think it's something to become good at, not something to avoid.

The problem with that approach is that it makes maintaining the code and making changes towards our actual roadmap much more difficult.

I agree in general but honestly this is a pretty simple thing to reason about and implement. The code diff is super inflated by the test setup, and those tests were already known to be a pain in the butt to maintain and of questionable value.

Especially when all we're doing is hazarding a guess at how users might use this feature.

It's not a guess, this is a user-requested feature that was made before this RFC was even known about. 😅 It was also a use case that has been discussed at length in #1200. If anything is guess right now, it's Projects.

To be honest, I don't really have a horse in this race. I don't think we should include it if no one's asking for it, but a user has asked for it, and I think it's justifiable.

I'm going to move this point under "open questions" so we can collect more feedback on it. Right now we seem to have 4 strongly opinionated people here and I'd rather wait until we can align on something before just making a snap decision one way or another. I would like to hear more from other people on this subject and just make sure everyone is aware of the trade-offs either way.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@vito I'm not suggesting we wait for perfect, I'm suggesting we make small incremental changes and see how people use them.

I agree in general but honestly this is a pretty simple thing to reason about and implement.

I actually don't see it that way at all. We're taking what used to be static configuration and now saying that it can be updated at any point out from under us. That's breaking a very large boundary IMO.

Reading through #1200 it seems like the majority of people are asking for gitops. That seems like a much larger endorsement for projects than self-aware pipelines (at least to me anyway).

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I'm not suggesting we wait for perfect, I'm suggesting we make small incremental changes and see how people use them.

Fair.

I actually don't see it that way at all. We're taking what used to be static configuration and now saying that it can be updated at any point out from under us. That's breaking a very large boundary IMO.

I guess I just don't really see that boundary as being broken in a unique way by allowing self. Pipelines can always change at any point, whether it's user-initiated, initiated by a Project, initiated by a separate pipeline using set_pipeline, or initiated by the same pipeline, either by using self or by being given its own name. Concourse has had to support this since day 1 - it's why builds and their build plans are decoupled from pipelines.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@evanchaoli implementing a feature with a plan to deprecate it down the road doesn't seem like a very sustainable approach to me.

@pivotal-jwinters I would predict that self will not be deprecated in a viewable long term. As I suggested in last comment, we can disable self in Projects, but keep self for standalone pipelines. Have anything been planed to deprecated standalone pipeline and enforce all pipelines to reside under projects?

Especially when all we're doing is hazarding a guess at how users might use this feature.

Why do you consider "self" as a guessed feature? This PR is contributed by a REAL user. I have stated clearly that, I, AS A USER, need self. My motivation was only set_pipeline: self rather than set_pipeline: other_pipeline. I'm not randomly picking up some issue and contribute, I implement something by myself because our users need it, and we cannot see when that can be done from Concourse side. I represent a large group of users behind me.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@vito vito left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Small things now. 🙂

Thanks for adding a testflight test! Are you waiting on concourse/mock-resource#3 before adding tests for the vars stuff? (I noticed nothing uses it yet.)

Comment thread atc/exec/set_pipeline_step.go Resolved
Comment thread atc/exec/set_pipeline_step.go Resolved
Comment thread atc/exec/set_pipeline_step.go Resolved
Comment thread atc/scheduler/factory/build_factory.go Outdated
case planConfig.SetPipeline != "":
name := planConfig.SetPipeline
if name == "self" {
name = job.PipelineName()

ghost Nov 12, 2019

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@pivotal-jwinters Yeah, I ultimately suggested this so that we don't have to deal with interpreting self at the plan/step-level. Using the job here feels OK to me since it's at the pipeline/job -> plan translation stage and keeps us from having to pass pipeline information down to the generic plan/step types.

I guess I didn't anticipate the impact this would have on the tests though (having to pluck .Config off everywhere). To be honest these tests are already super high-maintenance so I guess it's not too surprising. I remember wanting to find a way to get better value out of how we test this stuff at some point.

@evanchaoli

ghost commented Nov 12, 2019 •

Copy link
Copy Markdown
Contributor Author

Thanks for adding a testflight test! Are you waiting on concourse/mock-resource#3 before adding tests for the vars stuff? (I noticed nothing uses it yet.)

@vito Once the mock-resource PR is merged, I can add var_files and vars to the testflight test, however I think which is a nice-to-have but a blocker, because var_files and vars have been tested in unit tests.

Comment thread atc/api/config_test.go Resolved
@evanchaoli evanchaoli changed the title WIP: feat(atc): add set_pipeline step. feat(atc): add set_pipeline step. Nov 13, 2019
@evanchaoli

ghost commented Nov 21, 2019

Copy link
Copy Markdown
Contributor Author

@vito @pivotal-jwinters @kcmannem Looks like it's hard to reach an agreement if or not "self" should be supported, while I believe we all agree that "set-pipeline" is very useful. To unblock this PR, I have removed "self". Please consider to include this PR in release 6.0.0. Once this PR is merged, I'll create a new PR to add "self" back, then you guys may take time to decide if or not accept that PR.

ghost left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@evanchaoli Sorry for the wait - this latest iteration looks good to me! Tried it out manually and didn't find any issues. I'm going to merge this in and submit a separate PR that adds a warning notice when the step runs, since I don't think we want to fully support it until the RFC process completes. I'll start adding documentation and label it 'experimental' there too.

@vito
vito merged commit cfe2a7a into concourse:master Dec 5, 2019
@jamieklassen jamieklassen added this to the v5.8.0 milestone Dec 9, 2019
@jamieklassen jamieklassen added the release/documented Documentation and release notes have been updated. label Dec 11, 2019
@evanchaoli evanchaoli mentioned this pull request Feb 4, 2020
2 of 10 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement release/documented Documentation and release notes have been updated.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants