-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
Add support for alternate default_decoration_configs format that allows defaulting by cluster. #20656
Add support for alternate default_decoration_configs format that allows defaulting by cluster. #20656
Conversation
6973265
to
0b5e505
Compare
48a6efe
to
d0150b6
Compare
I don't know why I'm getting this error, I didn't touch anything related to this field AFAICT and this field was already unexported...
|
d0150b6
to
5be9725
Compare
Looks like the diff handling was already broken in that test case, but only exposed as a problem if the test case fails. I fixed that. |
More apparently unrelated errors for boilerplate in files I didn't touch...
It is unclear to me why this started failing now, but didn't fail on the PR that introduced the boilerplate: #20521 |
/cc |
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.
Generally looks good to me. Will come back again when there are more unit tests and documentation
prow/config/config.go
Outdated
// Repo matches against the "org/repo" that the presubmit or postsubmit is | ||
// associated with. If the job is a periodic, extra_refs[0] is used. If the | ||
// job is a periodic without extra_refs, the empty string will be used. | ||
Repo *regexp.Regexp `json:"-"` |
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.
Is there a particular reason must use regex instead of existing *
style? Ask user to learn something new is fine imo as long as it's well communicated. I'm interested in the reasoning behind this change.
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 don't think there is an existing *
(glob? wildcard?) matching style. The global config used key *
, but that was just a special case literal match.
I think regexp matching is overkill here, but I figured it would be most appropriate for consistency with other Prow config fields. run_if_changed
, branches
, exclude_branches
, trigger
, etc. all use regular expressions rather than *
matching.
I also considered naming this field OrgRepo
and just checking for string equality with the org or org/repo. This is consistent with other parts of Prow config, but I thought it more important that all the matching/filtering fields in this struct use a consistent matching system. I think it could be confusing (especially if we add more filter fields) if some things are matching literally (possibly against multiple fields), some are using *
matching, and some are using regexp.
WDYT?
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 don't have a strong preference on repo
field, I think either special case *
, glob, or regex works for me, my major concern is the patterns for org/repo
in other parts of prow are not using regex (they each have their own style, which I agree that it would be nice to be consistent across the board). And for cluster filed, I think the only reason using regex instead of literal is because of global default right? That would be fine with me as well.
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.
And for cluster filed, I think the only reason using regex instead of literal is because of global default right?
I was thinking it might be nice to reduce config size by using the cluster names to apply config across common clusters. e.g. All clusters with -trusted
suffix or all clusters containing istio
. This isn't that important though.
/assign @alvaroaleman
WDYT Alvaro?
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.
Hm, today we are fairly consistent for the orgRepo
field by having the *
, org
or org/repo
as choices, samples:
test-infra/prow/config/tide.go
Line 114 in b0edc0a
PRStatusBaseURLs map[string]string `json:"pr_status_base_urls,omitempty"` test-infra/prow/config/config.go
Line 495 in b0edc0a
JobURLPrefixConfig map[string]string `json:"job_url_prefix_config,omitempty"` test-infra/prow/config/config.go
Lines 918 to 919 in b0edc0a
// Use `org/repo`, `org` or `*` as key and an `SlackReporter` struct as value. type SlackReporterConfigs map[string]SlackReporter
Off of the top of my head I would also think that allowing regexes there is mostly prone to cause issues (someone creates a new repo that happens to match some regex it wasn't intended to match). run_if_changed
, branches
, eclude_branches
are IMHO not great counterexamples, because they need to provide capabilities to match against anything (more or less), whereas the format here is fairly clear and limited. trigger
is actually documented to match org
or org/repo
, on a five second glance I don't see anything regex in there:
test-infra/prow/plugins/config.go
Lines 363 to 364 in b0edc0a
// Repos is either of the form org/repos or just org. | |
Repos []string `json:"repos,omitempty"` |
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.
Ok that all makes good sense to me.
What are your thoughts on the cluster field then? I had hoped to use a consistent matching system, but the more I think about it, the more I'm thinking we should just have cluster
be a literal string match, at least initially. That is simpler and likely sufficient for existing use cases. With this new config slice pattern we can easily add more matching fields like repo_re
or cluster_re
down the road if we find a need for them.
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 don't really have an opinion regarding regex or not for cluster
. It makes IMHO more sense than using it for repo
, because for clusters you probably could have some kind of naming scheme that's based on trust domain but at the end of the day it boils down to what you need there and you know that better than me
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.
Ok I'm going to go with literal matching then, I think that will be sufficient for now. I like the idea of expanding functionality with something like cluster_re
if we find that we need alternative matching systems for any of these fields later on.
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.
Will come back again when there are more unit tests and documentation
Thanks, I ran into some more unrelated issues last night, but I have the majority of the tests done now. I'll notify when this is ready for another review.
prow/config/config.go
Outdated
// Repo matches against the "org/repo" that the presubmit or postsubmit is | ||
// associated with. If the job is a periodic, extra_refs[0] is used. If the | ||
// job is a periodic without extra_refs, the empty string will be used. | ||
Repo *regexp.Regexp `json:"-"` |
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 don't think there is an existing *
(glob? wildcard?) matching style. The global config used key *
, but that was just a special case literal match.
I think regexp matching is overkill here, but I figured it would be most appropriate for consistency with other Prow config fields. run_if_changed
, branches
, exclude_branches
, trigger
, etc. all use regular expressions rather than *
matching.
I also considered naming this field OrgRepo
and just checking for string equality with the org or org/repo. This is consistent with other parts of Prow config, but I thought it more important that all the matching/filtering fields in this struct use a consistent matching system. I think it could be confusing (especially if we add more filter fields) if some things are matching literally (possibly against multiple fields), some are using *
matching, and some are using regexp.
WDYT?
49de076
to
7db6b2a
Compare
PTAL, I think the way I implemented this preserves the reserialization behavior while still using 2 separate fields to make the generated docs more clear. |
Sorry, a bit underwater atm, will look early next week |
Yeah, the way it's implemented now looks good :) There are still a few outstanding comments from a previous review, though |
…ws defaulting by cluster.
caf55c3
to
0fc8369
Compare
My apologies, I forgot to implement those changes. I believe I've addressed everything now. |
@chaodaiG @alvaroaleman PTAL. Changes since the last review are in their own commit for convenience. |
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.
/lgtm
Looks good, thanks for all the work! Could you squash it though (or apply the tide squash label)?
/hold |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: alvaroaleman, chaodaiG, cjwagner The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
/label tide/merge-method-squash |
…on_config_entries Catching up with 1acac76 (Add support for alternate default_decoration_configs format that allows defaulting by cluster, 2021-03-17, kubernetes#20656), which transitioned the content from a map to an entry.
…on_config_entries Catching up with 1acac76 (Add support for alternate default_decoration_configs format that allows defaulting by cluster, 2021-03-17, kubernetes#20656), which transitioned the content from a map to an entry. Also some similar edits in other places, where I haven't drilled into the history as closely.
I'm opening this as WIP because I still need to add some more tests and docs.
Design Doc: https://docs.google.com/document/d/1VtamQuaR-TFVud3NjCRUV8Nqtp4WmBK1na7fNNiYHXU/edit?resourcekey=0-VXcyCZ9kcLJxQnnrUx4p0Q