Repository navigation
feat(atc): support var_sources in pipeline. - #4600
Conversation
|
Hey thanks for picking this up! 🙂 Hoping to get to this soon and submit some feedback. I've got a few loose-ends to tidy up in in this area, so I'm going to address them beforehand just to make sure my head's in the right place with regard to the long-term vision:
Once I have this all cleaned up I'll come back and cross-reference your proposal with mine and make sure there's common ground and a clear path forward to the long-term roadmap. 🙂 My tentative thoughts are that it's fine to introduce them at the pipeline-level first since projects will take a while to get here, and starting with pipeline-level creds will at least get us away from a single global credential manager. I'd also be excited to use this as a cheaper way of testing credential management. Perhaps in combination with #4502 we can even add a Thanks again! I'll try to get to this soon. |
8c47a95 to
fd0ba98
Compare
|
I use two vaults in my test:
Pipeline: The pipeline Vault's config takes a variable The screen shots of my test result is simple, but it proves the change has been working: |
Hah, that's pretty cool. I was wondering about this part because these pipeline-level vars would otherwise need to be directly embedded (scary even with encryption). So with this it's sort of like having a hierarchy of credential management. 🤔 An interesting pattern. Up until now I've been hoping to remove the global credential manager, but I guess this would be one reason to keep it around. |
vito
left a comment
There was a problem hiding this comment.
Haven't had time to complete this review yet but I'll submit what I have so far. 🙂 This is a great start!
tl;dr of my broader feedback:
- I'm thinking of calling this
var_sources:instead ofcredential_managers: - For concourse/rfcs#32 and concourse/rfcs#21 I had concerns over how many credential managers we'd be keeping around at runtime, now that they're dynamic, and those concerns carry over here. Maybe we could have a centralized object that maintains a single instance of each pipeline's credential manager stack?
- The handling of the YAML/JSON config in addition to the flags is a little awkward. In the long run I'd like to find a broader solution to this, but in the meantime maybe you could check out how
skymarshalhandles this? - We'll probably need to encrypt the credential manager config in the database, since it won't always have the cred manager's creds interpolated from the global cred manager.
- I'm not sure if we need to store cred managers per-build, especially if we decide that maintaining single instances per-pipeline is feasible.
Thanks again for tackling this! It's a pretty big feature. To be honest it might warrant an RFC but I think it's fine to keep going here as a proof-of-concept for now. I don't see there being a whole lot of pushback on an RFC anyway.
| @@ -0,0 +1,4 @@ | |||
| BEGIN; | |||
| ALTER TABLE pipelines ADD COLUMN credential_managers json; | |||
There was a problem hiding this comment.
If we're encrypting this column it can't be JSON, fwiw. And I think we'll have to, since I don't think we can rely on interpolating creds from the outer (global) cred manager.
There was a problem hiding this comment.
Can we actually make credential_managers its own table? We could probably model them very similarly to resources.
There was a problem hiding this comment.
@pivotal-jwinters Thanks for the comment. I considered that at the beginning, and I decided to begin with a simple way as this doesn't impact big picture design of this feature. So I'd defer this change till other design parts get clear.
| @@ -0,0 +1,4 @@ | |||
| BEGIN; | |||
| ALTER TABLE pipelines ADD COLUMN credential_managers json; | |||
There was a problem hiding this comment.
Can we actually make credential_managers its own table? We could probably model them very similarly to resources.
fd0ba98 to
b258e81
Compare
|
@vito I have just pushed a new version, and resolved some review comments. |
4e451c1 to
5b2fc7c
Compare
|
@vito I just pushed a new commit. Highlights of this new commit:
In this version, I might not clean up code perfectly. The code may contain some commented lines, "EVAN" in logs, etc. Please ignore those nits. I'll clean up and squash later. |
vito
left a comment
There was a problem hiding this comment.
Haha, well I started reviewing but then noticed the meatier parts to review haven't been checked in. So this is mostly nitpicks and questions.
14d47ec to
374337f
Compare
|
@vito Really sorry for missing to check in the two new files, I always forget |
|
I was just perusing old PRs and saw one that reminded me of this work. I might have misunderstood the core concepts here, but if this gets merged, might it unblock #3081? |
5e340a6 to
663bdd5
Compare
|
@vito I just pushed again and addressed all of comments including data encryption and |
I think this PR will unblock #3081. Once this PR is merged, user may define credential in pipeline, but #3081 still needs to add |
45d7b7c to
450bbf8
Compare
|
@evanchaoli Taking another look at this today! One quick request: would you mind making subsequent changes as new commits instead of force-pushing? It'll just make it a bit easier for me to tell what's new when re-reviewing. For example I'm wondering what this |
There was a problem hiding this comment.
Looking good! Leaving some early reviews before I try things out by hand. I'm going to try getting the dummy credential manager working and use that for testing things out locally.
edit: I especially like the pipelineRef idea - thanks for that refactor!
|
I got the dummy credential manager working and wrote a |
450bbf8 to
413571d
Compare
Signed-off-by: Chao Li <[email protected]>
6349221 to
49b2a04
Compare
…face "StepBuilder". Signed-off-by: Chao Li <[email protected]>
Signed-off-by: Chao Li <[email protected]>
fbe0d45 to
8bf0212
Compare
vito
left a comment
There was a problem hiding this comment.
Great to see all the tests passing! At this point I only have minor things to comment on, so I think we're pretty close to mergeable. I'm going to preemptively approve since the value in getting this merged outweighs my pretty minor nitpicks.
I yield the floor to @concourse/core-api for further review. 🙂
| } | ||
|
|
||
| type VarSourceConfig struct { | ||
| Name string `json:"name"` |
There was a problem hiding this comment.
Actually, is this name used anywhere?
It seems like it would make sense to be able to explicitly reference the var source to fetch from, e.g. ((myvault:foo/bar.baz)). But I don't think that's been implemented.
I think we should either implement that or remove the field for now.
There was a problem hiding this comment.
((myvault:foo/bar.baz)) is exactly what one of our users asked to me when I demoed this feature to him. I plan to implement that with a separate PR as I want to make this feature work first, and don't want this PR to grow any further. :)
There was a problem hiding this comment.
@evanchaoli is there a strong use case for wanting to cycle through all cred managers? It seems like we could get into some weird behaviour if someone added a new cred manager which unknowingly overrides a value from another one. And they wouldn't know it until it was already running in the pipeline.
I know it adds more to this PR, but I would be in favour of referencing cred managers by name as being the only supported method. It's much more in line with how resources work, and the direction we want to take with re-usable resources/tasks in projects.
There was a problem hiding this comment.
@pivotal-jwinters I don't have a strong use case right now. One use case I can image is, it would be helpful for pipeline debugging. Like when debugging the pipeline, user may add a dummy var source in the first place, which might 1) make sure all vars can be interpolated; or 2) pin some vars to certain values.
The other point is that, I don't think much user would add more than one var_source to a pipeline. Practically, maintaining a Vault is not easy given the serious security matter. So I don't think cycle through all var sources would bring serious issue. Only when users start to use the feature, then we know if that's really an issue.
To support ((myvault:foo/bar.baz)) syntax, some more changes are needed, because with current code, var_source name is not tracked by creds.Secrets. Again, I don't want to make this PR any bigger, it has been functional, and should fit most of use cases.
As our communication has long delay due to time difference, I just thought over, if you strongly insist to support var source name, a quick trade-off I can do is, to restrict only the first var_source defined in pipeline will be used. This trade-off would 1) eliminate the "cycle through" concern, 2) not impact our use case because our use will mostly add only one var_source to a pipeline, 3) still support the debugging use case as I described above.
To summarize, I still suggest merge this PR first. If you are strongly against that, I can do the trade-off. Once this PR is merged, I commit to contribute a PR to support ((myvault:foo/bar.baz)) syntax.
There was a problem hiding this comment.
@evanchaoli I understand that it's functional and that it meets all your use cases, however if we introduce named credential managers later on, it will be a breaking change. However since this is going to be an experimental/undocumented feature maybe that's ok. I think as long as we get to the point where named credential managers are the only supported method before we remove the experimental tag, then I would be ok merging this as is.
There was a problem hiding this comment.
👍 to merging for now and requiring named var references later - I'm working that aspect into my RFC. 🙂
There was a problem hiding this comment.
@pivotal-jwinters Thanks for understanding. I'm absolutely fine with only removing the experimental tag after named syntax is supported. :) But to clarify, the next PR, for named var source, would NOT be a breaking change. The behavior I'm planning to implement is like:
((var1)): iterate over all var_sources including the system level credential manager to look forvar1((name1:var1)): only look up var sourcename1forvar1.((name1,[name2,...]:var1)): only look up the multiple specified var sources forvar1.((sys:var1)): only look up the system level credential manager forvar1((name1,[name2,...,]sys:var1)): only look up specified var sources as well as the system level credential manager forvar1.
which would leave the flexibility to users.
Anyway, please merge this PR first. If you have different opinion with the design, we may discuss in a new issue. Once this PR is merged, I'll create an issue to track the named var source change, and we may discuss the design over there.
|
Actually now I'm wondering if we should go through the RFC process for this. 🤔 There was a lot of nuance captured in concourse/rfcs#21 and its comments, and it's adding pretty significant functionality to pipelines, which is typically what the RFC process is for. I'm already going to have to wrap up all of our RFCs for v10 now that you've lit a fire under my ass with #4708 lol. I can write up a new RFC based on the team credential managers RFC, and have it reflect my understanding of this PR and maybe bring up some of the concerns/ideas from concourse/rfcs#21 so we can agree on the next steps to take after this is merged. I don't want your branch to set around forever and go stale in the meantime so I'm OK with merging this anyway and having it exist as an experimental or undocumented feature until the RFC process completes, as long as we're sure it won't cause any issues. |
036ddd9 to
b70e02c
Compare
@vito Thanks for understanding. I'm absolutely fine to have it as an experimental or undocumented feature for a while. |
e3e171e to
fb33bd5
Compare
Signed-off-by: Chao Li <[email protected]>
fb33bd5 to
a26aa3a
Compare
There was a problem hiding this comment.
@pivotal-jwinters Would you mind approving or dismissing your review? I think we're good to merge at this point and start working on the next step.
@evanchaoli I'll have an RFC up soon that covers ((var)) semantics with regard to var_sources - so I would recommend holding off on further work until we can align on how that should behave. 🙂 Feel free to start anyway, but e.g. I'm currently thinking we should just enforce named var usage for var_sources and have ((foo)) only query the global credential manager and support ((name:foo)) for var_sources. We can discuss this further in the RFC once I have a draft up.
As there is more work to be done after this PR is merged I've started updating our 'Credentials Redux' project to keep track of it:
I'm not entirely sure if you'll be able to move cards around and such (you currently have Triage contributor level but I'm not sure if that allows you to interact with projects), but I just wanted to start keeping track of this somewhere on our roadmap.
@vito Sure, I'll only start next step implementation after we align on the design. Do we need to open an issue and discuss design in the issue? BTW, I just tried, unfortunately, I'm not able to move cards on project. |
I'm going to either submit a new RFC or adapt concourse/rfcs#21 to it. Going to try and get something up today. I'll comment here when it's up! |
|
@evanchaoli submitted a draft here: concourse/rfcs#39 |

Resolve #4579
This is for initial review from design perspective.
Highlights of the changes:
atc/config.goatc/validate.go. Also to solve cyclic imports, movedvalidate.gotoatc/configvalidate/validate.go.credential_managersin tablepipelines.fly set-pipelinewill store pipeline credential managers to this new field.credential_managersin tablebuilds. When create new build, get the value frompipeline.atc/engine/builder.go, create pipeline secrets variables, put them and global secrets into aMultiVars, so that build steps can interpolate secrets from pipeline credential managers as well as the global credential manager.creds.Manager. When a build finishes, call this method to cleanup pipeline credential managers, basically, stop thereauthergo routine.Note: Tests have not been updated yet.
Contributor Checklist
Reviewer Checklist