-
-
Notifications
You must be signed in to change notification settings - Fork 871
Instanced pipelines - Add instance vars as part of the pipeline identifier #5896
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
Instanced pipelines - Add instance vars as part of the pipeline identifier #5896
Conversation
|
Hey @vito, I've been playing around with fly commands for instanced pipeline and I think I've found a way to simplify the fly UX. Instead of adding e.g.: Then :
This also simplifies group operations (like pausing all instances of a group). By just splitting the flag's value on "/", if there's an instance vars suffix we can easily distinguish between instanced and group operations. What do you think? |
|
@mouellet Good idea! Seems like a good use of the flag system, since in these cases the intent of the flag is to identify a single pipeline, and specifying the vars is necessary in order to do that. One suggestion: the order of |
|
Sorry for the lack of feedback on this @mouellet. It looks really good so far! Was playing around with setting some pipelines, and noticed a couple things:
$ fly -t dev sp -n -p prs -c pipeline.yml -i number=5896
... (succeeds)
$ fly -t dev sp -n -p prs -c pipeline.yml -i number=5897
... (succeeds)
$ fly -t dev sp -n -p prs -c pipeline.yml
... (succeeds)I suspect we want to disallow the third
concourse/atc/db/migration/migrations/1594400645_add_instancevars_to_pipelines.up.sql Lines 7 to 9 in a1371a0
|
Yeah that's a good point, the RFC doesn't really make this clear. 🤔 I think we should disallow it; seems pretty sneaky. |
I had the same question, but for now I see all pipelines as pipeline instances whether they have instance vars or not... The Pipeline Groups concept hasn't been introduced yet and I think it's somewhat related to that. BTW, we should have a discussion about that soon!
Expect this to be working in the next commits (still WIP...) |
Hmm, that's interesting! All of the UI designs that @matthewpereira has mocked up are under the assumption that all pipeline instances sharing a name would have the same set of instance variables, but I'm realizing now that isn't necessarily the case. Pipeline instances sharing a name may not have the same pipeline configuration, either. Granted, the use case of the |
Hey @aoldershaw , right now I'm focusing on replacing the It does allow for everything that you said, and it alone doesn't resolve the rfc... But I think it'll make it flexible enough for which ever design we pick fo the Pipeline Groups as well as pipeline group operations. Maybe the |
823e62c to
2834a51
Compare
|
Hey @mouellet, sorry, I was mostly just thinking out loud as it's something I hadn't really thought of (and wasn't sure if our designer was aware of it or not). I think the approach you're taking now makes sense! |
e9f808f to
e8e4984
Compare
Hey @vito, I implemented this and it works great! Definitely more intuitive. There is one thing however, unmarshalling the flag is a little tricky... Both pipeline name and job/resource name should be valid identifiers, but not the instance vars with its colon. And dealing with the cases where someone forgot to add the job/resource name at the end (e.g. So I added an error when the job/resource name is not a valid identifier even if we only emit warnings for now. Is that ok or should we wait for the valid identifiers to be enforced? |
Hmm, good question. I think we might have to leave it as a warning for now, since we don't want it to break for someone who has an existing job with invalid characters and was able to use the |
46bd19b to
9a67bde
Compare
d380c99 to
76180f6
Compare
|
@vito, should I also update the logging, tracing and metrics w/ the pipeline instance vars? We could use the whole Maybe could use the dot notations when it's only a string, like with What do you think? |
|
@mouellet Hmm I wonder if it would be better to just log IDs. Logging pipeline names implies we need to also log e.g. team name/ID, project name/ID (later), and other things to disambiguate since names are non-unique at various levels. It adds an extra step if you're e.g. trying to search for logs of pipeline XYZ, but on the other hand it's precise, less verbose, and won't involve false positives or additional filtering. 🤔 What do you think? Side note: maybe we should start a pattern of adding a method like |
|
@vito, maybe this is out of scope for the current PR? It's already quite large and feature flagged... I suggest we open an issue for that, replacing all names with IDs. In logging, at the API level, etc. |
|
@mouellet 👍 yeah sounds wise, that would probably be a bigger change |
concourse#5808 Signed-off-by: Mathieu Ouellet <[email protected]>
concourse#5808 Signed-off-by: Mathieu Ouellet <[email protected]>
concourse#5808 Signed-off-by: Mathieu Ouellet <[email protected]>
…peline name concourse#5808 Signed-off-by: Mathieu Ouellet <[email protected]>
concourse#5808 Signed-off-by: Mathieu Ouellet <[email protected]>
concourse#5808 Signed-off-by: Mathieu Ouellet <[email protected]>
concourse#5808 Signed-off-by: Mathieu Ouellet <[email protected]>
concourse#5808 Signed-off-by: Mathieu Ouellet <[email protected]>
concourse#5808 Signed-off-by: Mathieu Ouellet <[email protected]>
…notation concourse#5808 Signed-off-by: Mathieu Ouellet <[email protected]>
concourse#5808 Signed-off-by: Mathieu Ouellet <[email protected]>
When the feature is disabled, the flag is only hidden in the 'fly set-pipeline' command, but the api will error if a instance-vars was specified. Also, the set_pipeline step will error on validation if instance_vars are specified. concourse#5808 Signed-off-by: Mathieu Ouellet <[email protected]>
concourse#5808 Signed-off-by: Mathieu Ouellet <[email protected]>
concourse#5808 Signed-off-by: Mathieu Ouellet <[email protected]>
concourse#5808 Signed-off-by: Mathieu Ouellet <[email protected]>
So that we don't get 404 in the UI for instanced pipelines. concourse#5808 Signed-off-by: Mathieu Ouellet <[email protected]>
concourse#5808 Signed-off-by: Mathieu Ouellet <[email protected]>
concourse#5808 Signed-off-by: Mathieu Ouellet <[email protected]>
concourse#5808 Signed-off-by: Mathieu Ouellet <[email protected]>
nil instance_vars were created as json 'null' and not Postgres 'NULL', so the partial index wouldn't have worked. concourse#5808 Signed-off-by: Mathieu Ouellet <[email protected]>
concourse#5808 Signed-off-by: Mathieu Ouellet <[email protected]>
Revert "web: make ordering pipelines working with instanced pipelines" This reverts commit 9974c92 Revert "web: add instance vars in elm's pipeline identifier" This reverts commit 9158d34 Revert "web: fix elm-analyse issues & elm benchmarks compilation" This reverts commit d3d22ba Signed-off-by: Mathieu Ouellet <[email protected]>
concourse#5808 Signed-off-by: Mathieu Ouellet <[email protected]>
concourse#5808 Signed-off-by: Mathieu Ouellet <[email protected]>
concourse#5808 Signed-off-by: Mathieu Ouellet <[email protected]>
da82019 to
2229139
Compare
| BaseResourceType *VolumeBaseResourceType `json:"base_resource_type"` | ||
| PipelineID int `json:"pipeline_id"` | ||
| PipelineName string `json:"pipeline_name"` | ||
| PipelineInstanceVars InstanceVars `json:"pipeline_instance_vars"` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe omitempty?
|
|
||
| func (flag *InstanceVarPairFlag) UnmarshalFlag(value string) error { | ||
| flag.Value = atc.DotNotation{} | ||
| for _, v := range strings.Split(value, ",") { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if we can get rid of this splitting - it's nice to be able to define vars using dot notation as it avoid shell semantics with {}, but sometimes it may be more convenient to just provide raw YAML surrounded by quotes.
Writing -i foo.bar=1 -i foo.baz=2 isn't that much more annoying than -i foo.bar=1,foo.baz=2, and allowing you do put -i 'foo={bar: 1, baz: 2}' or -i "foo=$(jq ...)" is pretty nice IMO
|
|
||
| func unmarshalDotNotation(value string) (atc.DotNotation, error) { | ||
| dn := atc.DotNotation{} | ||
| for _, v := range strings.Split(value, ",") { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would also be nice to not require dot notation for querying, but that's not so obvious to me how to do that, so I'm fine with this
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks again for the awesome contribution and sorry for the delay! We really appreciate your patience!
I'm going to merge this now - any updates can be handled in another PR (no pressure to address any of the comments I left - we're happy to do this)
What does this PR accomplish?
Bug Fix | Feature | Documentation
Changes proposed by this PR:
ATC
jsonbcolumn in thepipelinestable with unique partial index.pipelineNamemethod parameter withatc.PipelineRef.instance_varsattribute to theset_pipelinestep.API
instance_varsquery param as html encoded raw json to all endpoints based on/api/v1/teams/:team_name/pipelines/:pipeline_name.Fly commands
--instance-varflag toset-pipelinecommand (e.g.:fly set-pipeline -p branch --instance-var branch=feature/foo)flaghelpers.*Flage.g.:
Also support complex json and numeric values as strings or numbers:
fly ... -p 'pipeline-name/foo.bar.baz:1,foo.bar.qux:"2",bar.0:1,bar.1:"2"'Notes to reviewer:
Pipeline Groups & UI changes are out of scope of this PR. I feature flagged the use of instance vars in the step and the api so we can merge asap as it is quite large.
Contributor Checklist
Reviewer Checklist
BOSH and
Helm packaging; otherwise, ignored for
the integration
tests
(for example, if they are Garden configs that are not displayed in the
--helptext).