Skip to content

How do you use set-pipeline? #1200

Closed
Closed

Description

@vito

Currently set-pipeline is manually invoked by a user to submit a pipeline config from their local machine. This is great for rapid iteration, but also goes against a Concourse principle of having versioned, persistent, reproducible config.

Are you still using set-pipeline manually? Have you written scripts to automate it? Are you continuously configuring it using something like the Concourse Pipelines resource? How are you handling credentials?

Activity

  1. marco-m commented on May 23, 2017

    @marco-m
    Contributor

    I am investigating Concourse since a week, with the idea of replacing a Jenkins deployment. The question you are asking is one of the main questions I had. I plan to use scripts and SaltStack exactly for reproducibility. I read about the pipeline resource and I want to investigate it more. Another question I had is why we need to specify the pipeline name in the command line, why not having the pipeline name in the YAML file ? The notion of naming things in the YAML files is already there for every concept. The --pipeline option could become required only if the pipeline name in the YAML file is not present...

  2. vito commented on May 23, 2017

    @vito
    ContributorAuthor

    @marco-m The name is not in the .yml so that you can use a single pipeline template to configure differently-parameterized and thus differently-named pipelines.

  3. Chumper commented on May 24, 2017

    @Chumper

    What about integrating seeding from a repository directly into concourse?

    I would love to have the opportunity to state one or multiple repositories that concourse will then watch (or hook) and seed accordingly.
    It doesn't need to have fancy diff mechanics, just the seeding would work fine.

    That would make it easier to start with the correct "version everything" mindset.

  4. marco-m commented on May 27, 2017

    @marco-m
    Contributor

    @vito Thanks for the explanation regarding the lack of pipeline name in the configuration file. Makes sense.

  5. freelock commented on Jun 1, 2017

    @freelock
    Contributor

    We use a bot that calls set-pipeline. Not sure how typical our setup is, but it's working well for us managing 60+ pipelines currently.

    We have two pipeline yaml files that differ based on the platform being managed (we manage a lot of Drupal sites and a few WordPress sites -- we have a different pipeline per platform). All of the scripts and supporting tasks are in the same repo as our pipeline. We keep a separate credentials.yml file and a wrapper script that reads the secrets that need to be passed in as separate parameters when a pipeline is set.

    We have one Matrix chatroom filled with bots -- our control bot, Concourse notifications, gitolite notifications, notifications from a couple different PM tools we use.

    We then have one chatroom per project, and our bot stores some project state there (the project alias, the platform, etc). Our developers and PMs, and sometimes customers, are in the project chatroom. The bot relays and prettifies results from Concourse (from the bot room), and users can trigger the bot to do stuff.

    When our bot is called to run a concourse job (usually either on user request or as a result of a gitolite post-commit hook message), it:

    1 - Checks for a recent Concourse auth token, and if it doesn't have one, calls fly login.
    2 - Calls the wrapper for set-pipeline if the pipeline was disabled.
    3 - Enables the pipeline
    4 - Calls fly trigger-job on the corresponding job

    Due to performance issues we were having with more than 3 - 4 active pipelines in previous versions, the bot queues up jobs and makes sure that only 1 is running at a time. (We did make this concurrency a value we can easily change, but haven't yet bumped it up). So it inserts the triggered job into its queue, with an expected notification that signals the pipeline for the triggered job is complete.

    5 - As concourse jobs send notifications, (via the matrix-notification-resource), the bot drops a message in the room and/or updates the state (metadata about job success, setting flags that allow/disallow actions like triggering deployments only if tests have passed)
    6 - When the pipeline has reached the last job in a given sequence, or reports a failure, the bot pauses the pipeline and starts the next job in the queue.

    So we use a bot to provide some level of control over authorizing who may trigger which jobs, and managing most of the secrets.

    Our pipelines use quite a few resources, including:

    • pipelines git repo, contains all our concourse configuration, pipelines, supporting scripts for both variations
    • aliases repo, provides connection addresses for each site and environment
    • project repos, the actual code
    • pool repos, locks contain addresses for external test environments such as a Selenium Grid resource
    • Docker images for deployment, various tests

    This is all working really well for us right now!

    I would say the areas we'd like to see improvements are largely around security. I'm definitely in favor of some sort of improved management of secrets -- right now we just protect the bot's execution environment and greatly limit the attack surface area, which seems ok but I'd love some auditing/pen-testing of the ATC and workers to know if any stale task containers might be exploited to reveal keys to the kingdom.

    The other big concern is the team login structure -- this doesn't work for us, we're just using the "Main" team. We really want read-only and read-execute-only logins that do not have the ability to set a pipeline. As it is, we do not want any of our pipelines to be publicly viewable -- we want a login for each pipeline we may give to a customer so they can view each job and task, including the detail, but not be able to do anything more than that.

    And then I would like a login for each pipeline that would allow triggering jobs, pausing particular resource versions and tasks, while being unable to pause/unpause the entire pipeline or set the pipeline in any way -- this to me feels like a security risk, as we basically have a single login that lots of people have, which might allow an attacker to upload a modified pipeline that somehow gains access to production systems. (Right now I'm not sure how they would do this without the secrets kept by the bot, but it feels like there's a way to exploit in there -- I would rather put a really strong, well-guarded password as the main team and have some weaker ones that our devs can use to mostly manage pipeline jobs if something happens that breaks things that our bot can't handle...)

    Oh wait, of course, there's a trivial way to exploit this -- fly get-pipeline shows all your secrets, to anyone who can load it. There's the big vulnerability that might keep me up at night -- an easy way to show an SSH private key... This is the stuff that needs to get nailed down!

  6. marco-m commented on Jun 1, 2017

    @marco-m
    Contributor

    "We really want read-only and read-execute-only logins that do not have the ability to set a pipeline"

    +1

  7. DanielJonesEB commented on Jul 6, 2017

    @DanielJonesEB

    @vito We hack on pipelines a lot, inlining Bash scripts in tasks in the main pipeline YAML, and using set-pipeline to find out if they work. Most of our work is plumbing together IaaSes and CF.

    We've been toying with a tool to automatically inline/extract task scripts, so it's trivial to go from hacking to not completely awful.

    We've got a pair currently looking at a pattern for promoting pipelines. We want to parameterise all gets to have version specifiers, and on 'dev' pipelines these will be latest. Dev pipeline runs, and when the whole thing has passed, we write all the versions of all the resources to a vars file, and put that.

    Downstream pipelines (think 'production') pick up this vars file of pinned resource versions, and then it calls set-pipeline on itself, effectively locking it to a known good set of resources.

  8. DanielJonesEB commented on Jul 14, 2017

    @DanielJonesEB

    Should all pipelines forcibly start with a resource that holds the pipeline itself, and sets itself? Maybe if there was an equivalent of how execute uploads a resource version from the local system, there could be an extra command that sets a pipeline from a one-off version of the pipeline resource, thus keeping fast-iterators happy.

  9. cjcjameson commented on Aug 16, 2017

    @cjcjameson
    Contributor

    @jmcatamney @khuddlefish @chrishajas @Chibin @pivotal-mike @divyabhargov @larham @professor and many others could comment on our workflow, but I'll start (feel free to edit my post):

    We script around fly set-pipeline, especially for "dev" pipelines -- ones "forked" from the master pipeline but running a particular branch. We have reasons & benefits from this forking of dev pipelines, but you're asking about main reasons & benefits for the scripting around fly set-pipeline:

    • Some neat scripting around fly login
    • consistent naming of dev pipelines so we know what team created them
    • a way to use the majority of the same credentials that the master pipeline does, but update git branch names and S3 buckets. I've told people that you can just pass multiple -l flags and the "last one takes precedence", but a custom configuration file format took hold to override these properties. The script outputs them into -v flags, I think.
    • default to individual jobs paused but the pipeline overall unpaused. This is honestly the killer feature. When you make a dev pipeline, you only care about a few jobs out of the 40. For this case, the default of pipeline-paused + jobs unpaused is the exact opposite of what we want.
  10. freelock commented on Aug 16, 2017

    @freelock
    Contributor

    Ooh, love the idea of an option to set all jobs in a pipeline to paused on creation...

    We do use set-pipeline every time we start a new job, so I would not want this to change the paused state of jobs that are unchanged -- but if we can set a default in the pipeline itself that is used when it's first loaded, or new jobs are added to the pipeline, that would be really slick...

  11. pn-santos commented on Aug 16, 2017

    @pn-santos

    We use a script that has some pre-set options and custom logic (like using the name of the git checkout as the pipeline name, default ci/pipeline.yml location in the repo, set credentials repo location and load the vars, etc.) so anyone can update the pipeline and then run a single command to: validate pipeline + set-pipeline + up + ep (we like to make everything public since we run everything inside our VPN).

    I currently have in my TODOs to explore the pipeline resource to see if we can get self-updating pipelines (but we would still use the script to do the first push)

  12. cjcjameson commented on Aug 16, 2017

    @cjcjameson
    Contributor

    @freelock indeed, we also have the issue where we run our script a second or third time to update something, and it resets the paused-ness back to whatever it's initial opinion was. Seems like a hard nut to crack for the core Concourse product. But your suggestion of the pipeline.yml declaring "default paused-ness" I think is possibly good...!

  13. jmcatamney commented on Aug 16, 2017

    @jmcatamney

    Some more details on the workflow @cjcjameson mentioned:

    Regarding credential handling, since fly login requires either clicking on a link or entering credentials but we want our script to set up a pipeline with no manual intervention even if you haven't logged in recently, we script around with the Links browser. Developers can log into Git once with Links to save those credentials, then our pipeline script tests whether you're currently logged in and if you aren't it runs fly login, grabs the authentication link, accesses it with the stored Git credentials, and continues with setting the pipeline.

    It mostly works fine, but it's hackish and breaks whenever the login process changes. I'd personally appreciate an option to tell fly "This is my dev box, leave me logged in forever unless something about my credentials changes" to avoid the issue.


    Regarding the custom configuration file, we do use the "last -l" method; the script reads in a configuration file, transforms some values (e.g. replacing placeholders with Github user names and bucket names), writes it out in .yml format, and passes the resulting file with -l to the script after the other .yml files used. We do it that way because if someone wants to do something unusual (e.g. use someone else's S3 bucket or pull test code from a different repo) it's easier to edit their config file than to edit the script where it's constructing the set-pipeline command.


    Regarding pausing jobs, the script currently re-pauses everything except a default set of jobs because we don't have a good way to distinguish between "This is the first time I'm flying the pipeline, pause everything except a minimal set of jobs" and "I've run this script already for this pipeline, leave the paused/unpaused job states alone". That can probably be solved with the default paused-ness suggestion, so +1 to that.


    An as-yet-unmentioned issue we have with setting pipelines is dealing with timed triggers. We have some jobs that take a fairly long time to run or rely on limited shared resources, so we use a time resource to only run them once each weeknight, once a week, or the like. This works fine most of the time, but when you're iterating on some code that needs to run those tests the jobs won't trigger when you push changes because the time constraint isn't satisfied, unless you manually edit the pipeline file before running set-pipeline to change the resource to something that can currently be satisfied.

    It would be nice to have a flag you could set when setting a pipeline to tell it to ignore any time resources, so you could set up normal time constraints for your main pipeline, set a pipeline for development that ignores those constraints while you're pushing changes, and then reset the pipeline to obey time constraints once you're done.

  14. 19 remaining items

  15. vito commented on Mar 13, 2019

    @vito
    ContributorAuthor

    As a side-tangent, I think there may be undertones here around 'what is a pipeline', and I think that may be causing mental friction when discussing other CI solutions, as their 'pipelines' tend to be more like Concourse 'jobs'. The difference being that Concourse pipelines are really just a namespace of jobs and resources.

    This is a key difference, because there is no such thing as a "run of a pipeline", for example. Another key difference is that pipelines define all their jobs all at once, and the change takes effect immediately, even for downstream jobs that haven't run yet.

    @marco-m This is kind of a shot in the dark, but I wonder if the kinds of things you're proposing would be more appropriate to think about at the job level. I'm not really sure how to word this now, as it's kind of just a suspicion. As a vague example, could jobs be configured in such a way that they learn their build plan YAML at runtime based on their own inputs?

    ...I'm leaving this kind of vague because I'm not too sure myself and I'm hoping you have an "a-ha!" reaction and can meet me in the middle. 😛

  16. marco-m commented on Mar 13, 2019

    @marco-m
    Contributor

    @vito

    As a side-tangent, I think there may be undertones here around 'what is a pipeline', and I think that may be causing mental friction when discussing other CI solutions, as their 'pipelines' tend to be more like Concourse 'jobs'. The difference being that Concourse pipelines are really just a namespace of jobs and resources.

    Yes, I think you nailed it.

    ("Concourse knows about git, but only sometimes, and not always in the same way."). This is why I'm trying to lean as hard as possible on the same core set of principles and ideas

    I agree. This is why I put that suggestion under "I am not sure wether I am able to propose something concrete actually."

    On the other hand, the race condition I am talking about is real and, in my recollections, easy to reproduce. I though it was a known problem, but you comment makes me think it is not the case. I will open a ticket with a repro.

    Mmh, re-reading what you wrote:

    This is a key difference, because there is no such thing as a "run of a pipeline", for example. Another key difference is that pipelines define all their jobs all at once, and the change takes effect immediately, even for downstream jobs that haven't run yet.

    Exactly. This is the race condition, in the sense that downstream jobs can fail. Again, I will repro it.

  17. DanielJonesEB commented on Mar 13, 2019

    @DanielJonesEB

    On Concourse's side, I can't imagine a scenario where running set-pipeline would affect a build that's already running; its plan is already figured out by that point, so it's not even looking at the pipeline config anymore and should just finish whatever it was doing. I'm not sure what else it would do, to be honest.

    This is a key difference, because there is no such thing as a "run of a pipeline", for example.

    It wouldn't affect a build that was already running, but it could certainly affect a 'run of a pipeline', and that's something we've had to guard against (and seen customers do) by using a pool resource as a lock, so there's only one 'run' possible at a time, with a set-pipeline as one of the first steps.

    The challenge then would be surfacing this in the UI in a way that's not confusing, which is indeed a challenge, since they'll have a pipeline on the dashboard, but not the one they necessarily expect.

    Yep, would be a pretty drastic change. One team has many pipeline-sources (generators? meta-pipelines?), one pipeline has one pipeline-source.

  18. DanielJonesEB commented on Mar 13, 2019

    @DanielJonesEB

    As an aside, at Concourse London User Group some Pivots explicitly called out as a beginner's error folks mistakenly thinking that serial groups could protect against concurrent/out-of-sequence runs.

  19. vito commented on Mar 13, 2019

    @vito
    ContributorAuthor

    Exactly. This is the race condition, in the sense that downstream jobs can fail. Again, I will repro it.

    Ah, now that I think of it I have seen one example. It's usually when tasks use file: and expect certain inputs, and then the pipeline removes those get steps. I can't really think of any other examples off the top of my head.

    It wouldn't affect a build that was already running, but it could certainly affect a 'run of a pipeline', and that's something we've had to guard against (and seen customers do) by using a pool resource as a lock, so there's only one 'run' possible at a time, with a set-pipeline as one of the first steps.

    As an aside, at Concourse London User Group some Pivots explicitly called out as a beginner's error folks mistakenly thinking that serial groups could protect against concurrent/out-of-sequence runs.

    Yeah, this is another bit of awkwardness with trying to push 'runs of a pipeline' into the Concourse mental model. It's something I've thought about making first-class and replacing serial_groups. I've never really focused on it though. (There's too much to do!)

  20. DanielJonesEB commented on Mar 13, 2019

    @DanielJonesEB

    Yeah, this is another bit of awkwardness with trying to push 'runs of a pipeline' into the Concourse mental model. It's something I've thought about making first-class and replacing serial_groups.

    Maybe something like having 'modal resources'. Some resources that have gets in the pipeline can be flagged as modal, and thus only one permutation of the set of all modal resources is allowed to run at a time, and subsequent versions are queued? That's my crap idea having thought about it for all of 15 seconds whilst staring out of a window, so is undoubtedly completely unworkable.

    I've never really focused on it though. (There's too much to do!)

    Ha, I bet :)

  21. chenbh commented on Mar 13, 2019

    @chenbh
    Contributor

    I'm in full agreement that setting a pipeline that sets pipelines isn't the best UX, but I think that's something we can make easier by having fly set-pipeline just support syntactic sugar for it:

    I wonder if we can give fly the ability to submit a pipeline configuration from a URL and somebody (e.g. concourse-ci.org) can host a set of "meta-pipelines" that would be used to read and set the CI pipelines

    $ curl https://concourse-ci.org/pipelines/load-ci-from-git.yml
    
    resources:
    - name: repo
      type: git
      source: 
        uri: ((github-repo))
        paths: pipeline.yml  # or make it a var that can be passed in
    
    - name: ci-pipeline
      type: concourse-pipeline
      source:
        target: ((target))
        insecure: "false"
        teams:
        - name: ((team))
          username: ((user))
          password: ((pass))
    
    
    jobs:
    - name: set-pipeline
      plan:
      - get: repo
        trigger: true
      - put: ci-pipeline
        params:
          pipelines_file: repo/pipeline.yml
    

    And to use it

    fly set-pipeline -p meta-pipeline \
      --config-from-url https://concourse-ci.org/pipelines/load-ci-from-git.yml \
      --var "github-repo=https://github.com/concourse/concourse.git" \
      --var target, team, user, pass....
    

    Pros:

    • Easy to copy/paste and get your CI up and running
    • Concourse don't have to know about git (other than having the resource)
    • Fairly easy to extend to whatever other configuration you want your pipeline.yml to be (hg, s3 bucket?????)

    Cons:

    • Still has a meta pipeline whose only job is to update the CI pipeline
    • Must explicitly specify fly settings
    • Meta-pipelines might become pretty complex and require lots of vars to be passed in (default values in pipeline configurations?)
  22. DanielJonesEB commented on Mar 14, 2019

    @DanielJonesEB

    I wonder if we can give fly the ability to submit a pipeline configuration from a URL and somebody (e.g. concourse-ci.org) can host a set of "meta-pipelines" that would be used to read and set the CI pipelines

    Interesting idea! In my mind, this starts to touch on higher-level value offerings to be built atop Concourse - like 'buildpacks' for CI pipelines. Some thing that you point at your code, which then generates you a meta-pipeline and/or a pipeline.

  23. eedwards-sk commented on Mar 15, 2019

    @eedwards-sk

    Vito mentions how ugly the fly cli could be to set a pipeline where you also have to specify a git resource.

    ...but imo, the fly cli is already pretty ugly (heavily parameterized). I rarely use it directly, often wrapping it to provide all the vars (-l, -c, -p etc)

    I don't see why adding more vars is a big deal if it gives us the results we need?

  24. jshearer commented on Mar 17, 2019

    @jshearer

    As someone who doesn't know that much about how concourse works internally, I'd like to add to what @marco-m said.

    I'd like to switch from GitLab or CircleCI to concourse since I love the task definition and planning, individual docker containers per task, scheduling, cost, etc. The problem is that even with @vito's suggestion of a meta-pipeline to create pipelines, and the concourse pipeline resource, it's still significantly harder to get the workflow I want up and running.

    In gitlab and circle, I can just create a pipeline file in my repo with a well known name, teach the CI system about my repo, and everything just works -- branch builds, updates to the pipeline config get picked up atomically, pipeline changes per branch (i.e I can push a change to the pipeline in a branch and that pipeline will run only for that branch) and no worrying about "oh shit, I changed my pipeline but forgot to run fly update-the-pipeline". If the meta-pipeline suggestion solves this (i.e, it takes the place of "teaching the CI system about my repo", and I only have to do it once), then I think that's great.

    In addition, not only do I not have to worry about forgetting to manually update the pipeline, I don't have to worry about builds potentially running against an old version of the pipeline when I push an update to the repo that changes the pipeline yaml before I or the meta resource have time to update it.

    In thinking about this more, it seems like really only the last issue I mentioned is a problem:

    1. Push change to project repo containing pipeline change, and code change
    2. The meta-pipeline picks up this change, and applies it to the main pipeline
    3. The main pipeline detects a change in the repo and runs

    The problem is, are 2 and 3 guaranteed to happen in that order? What if 3 just happens to run before 2? Now I'm running an old version of the pipeline against the new commit, and who knows what might happen.

    I actually like the idea of storing all of the meta-pipelines in version control and just having to manually configure concourse once at the very beginning to pull meta-pipelines from a single repo, so then you can also keep which repos concourse should watch for pipelines in version control.

  25. vito commented on Mar 18, 2019

    @vito
    ContributorAuthor

    @jshearer Yeah, I think we're all on the same page. The meta-pipeline proposal would solve the first part of what you said (teach concourse about my repo and everything's automatic from there). But it won't solve that race condition. Cheers for adding your perspective, it's good to know a lot of people are aligned on this.

  26. ari-becker commented on Mar 19, 2019

    @ari-becker

    @vito We approach this with a meta-pipeline that sets our other pipelines through the Concourse Pipeline resource. I'm not too keen on any kind of proposal which launches Concourse with knowledge of a meta-pipeline since our meta-pipeline is itself generated. Currently we run our meta-pipeline generation script by hand, but I could see us putting the script in a cronjob.

    We too suffer from the race condition mentioned by @jshearer. My proposal would be to add a parent_pipeline optional field to pipelines which, if set, waits to perpetuate new versions to the pipeline until those versions have been processed by the parent_pipeline for any resources shared by both pipelines. This would ensure that pipelines would be reset by the meta-pipeline before they begin processing their resources' new versions. (edit: naturally fits under the hierarchical pipelines proposal #532 )

    When I first started using Concourse, I was coming from Jenkins and Jenkinsfiles and wondering why Concourse didn't have them. But any organization at scale ends up using Jenkins shared libraries to keep a consistent configuration across repositories, and the Jenkinsfile just ends up being a wrapper around that shared library. We find that the meta-pipeline pattern scales much better, and IMO some kind of .concourse-ci.yaml file would be an anti-pattern, not least of which because such a per-repository file could not be generated, as there would be no way to instruct Concourse how to generate the .concourse-ci.yaml file per-repository.

    IMO the two uses for set-pipeline are for setting the meta-pipeline and for hacking on development pipelines.

  27. ukabu commented on Jun 4, 2019

    @ukabu

    What about a fly -t target set-pipeline -p pipeline-name --resource git --source "uri=...,other_source_params=...." --check_every 5m ...

    This way, Concourse doesn't have to "know" about git. Could use any resource as the source of the pipeline.

    This would also define the source resource in the pipeline without having to redefine it.

    For external resource, we could pass a --resource_type ....

  28. vito commented on Jul 29, 2019

    @vito
    ContributorAuthor

    Hi all, thanks a lot for helping me map this out. I think I've got a plan that addresses this, and I've outlined it in the v10 Roadmap blog post. 🙂

    Specifically, this has led to concourse/rfcs#32 which proposes a workflow that maps pretty closely to what we talked about here. A set_pipeline step is involved, but only as a small piece of the puzzle.

    I'm going to close this issue and direct the conversation there. Please take a look and leave feedback, and thanks again!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions