Skip to content
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

Merged
merged 5 commits into from Mar 17, 2021

Conversation

cjwagner
Copy link
Member

@cjwagner cjwagner commented Jan 29, 2021

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

@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. labels Jan 29, 2021
@k8s-ci-robot k8s-ci-robot added area/prow Issues or PRs related to prow area/prow/crier Issues or PRs related to prow's crier component area/prow/deck Issues or PRs related to prow's deck component area/prow/spyglass Issues or PRs related to prow's spyglass UI sig/testing Categorizes an issue or PR as relevant to SIG Testing. approved Indicates a PR has been approved by an approver from all required OWNERS files. labels Jan 29, 2021
@cjwagner cjwagner changed the title Add support for alternate default_decoration_configs format that allows defaulting by cluster. [WIP] Add support for alternate default_decoration_configs format that allows defaulting by cluster. Jan 29, 2021
@k8s-ci-robot k8s-ci-robot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Jan 29, 2021
@cjwagner cjwagner force-pushed the decoration-defaulting branch 2 times, most recently from 48a6efe to d0150b6 Compare January 29, 2021 22:23
@k8s-ci-robot k8s-ci-robot added area/config Issues or PRs related to code in /config area/release-eng Issues or PRs related to the Release Engineering subproject sig/release Categorizes an issue or PR as relevant to SIG Release. labels Jan 29, 2021
@cjwagner
Copy link
Member Author

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...

--- FAIL: TestGeneratePeriodics (0.00s)
panic: cannot handle unexported field at {[]config.Periodic}[0].interval:
	"k8s.io/test-infra/prow/config".Periodic
consider using a custom Comparer; if you control the implementation of type, you can also consider using an Exporter, AllowUnexported, or cmpopts.IgnoreUnexported [recovered]
	panic: cannot handle unexported field at {[]config.Periodic}[0].interval:
	"k8s.io/test-infra/prow/config".Periodic
consider using a custom Comparer; if you control the implementation of type, you can also consider using an Exporter, AllowUnexported, or cmpopts.IgnoreUnexported
goroutine 123 [running]:
testing.tRunner.func1.1(0x2302dc0, 0xc0001c9810)
	GOROOT/src/testing/testing.go:1057 +0x46a
testing.tRunner.func1(0xc00050e900)
	GOROOT/src/testing/testing.go:1060 +0x636
panic(0x2302dc0, 0xc0001c9810)
	GOROOT/src/runtime/panic.go:975 +0x3e9
github.com/google/go-cmp/cmp.validator.apply(0xc000453c20, 0x2476fc0, 0xc0001b4128, 0x1a6, 0x2476fc0, 0xc0000ecba8, 0x1a6)
	external/com_github_google_go_cmp/cmp/options.go:244 +0x70e
github.com/google/go-cmp/cmp.(*state).tryOptions(0xc000453c20, 0x2967f80, 0x2476fc0, 0x2476fc0, 0xc0001b4128, 0x1a6, 0x2476fc0, 0xc0000ecba8, 0x1a6, 0x0)
	external/com_github_google_go_cmp/cmp/compare.go:303 +0x15a
github.com/google/go-cmp/cmp.(*state).compareAny(0xc000453c20, 0x29417c0, 0xc000590700)
	external/com_github_google_go_cmp/cmp/compare.go:258 +0x434
github.com/google/go-cmp/cmp.(*state).compareStruct(0xc000453c20, 0x2967f80, 0x2482860, 0x2482860, 0xc0001b4000, 0x199, 0x2482860, 0xc0000eca80, 0x199)
	external/com_github_google_go_cmp/cmp/compare.go:427 +0x58e
github.com/google/go-cmp/cmp.(*state).compareAny(0xc000453c20, 0x2941780, 0xc00007c900)
	external/com_github_google_go_cmp/cmp/compare.go:286 +0x17a8
github.com/google/go-cmp/cmp.(*state).statelessCompare(0xc000453c20, 0x2941780, 0xc00007c900, 0x2967f80, 0x2967f80)
	external/com_github_google_go_cmp/cmp/compare.go:229 +0xfc
github.com/google/go-cmp/cmp.(*state).compareSlice.func2(0x0, 0x0, 0x0, 0x353a1c0)
	external/com_github_google_go_cmp/cmp/compare.go:493 +0x105
github.com/google/go-cmp/cmp/internal/diff.Difference(0x5, 0x5, 0xc000597210, 0x5, 0x5, 0xc000041880)
	external/com_github_google_go_cmp/cmp/internal/diff/diff.go:241 +0x2b4
github.com/google/go-cmp/cmp.(*state).compareSlice(0xc000453c20, 0x2967f80, 0x22c8f20, 0x22c8f20, 0xc00000e340, 0x97, 0x22c8f20, 0xc00000e360, 0x97)
	external/com_github_google_go_cmp/cmp/compare.go:492 +0x852
github.com/google/go-cmp/cmp.(*state).compareAny(0xc000453c20, 0x2932480, 0xc0002a5ec0)
	external/com_github_google_go_cmp/cmp/compare.go:288 +0x117f
github.com/google/go-cmp/cmp.Diff(0x22c8f20, 0xc00000e340, 0x22c8f20, 0xc00000e360, 0x0, 0x0, 0x0, 0x6, 0x0)
	external/com_github_google_go_cmp/cmp/compare.go:119 +0x105
k8s.io/apimachinery/pkg/util/diff.legacyDiff(...)
	external/io_k8s_apimachinery/pkg/util/diff/diff.go:51
k8s.io/apimachinery/pkg/util/diff.ObjectDiff(...)
	external/io_k8s_apimachinery/pkg/util/diff/diff.go:58
k8s.io/test-infra/releng/config-forker.TestGeneratePeriodics(0xc00050e900)
	releng/config-forker/main_test.go:704 +0x19b2
testing.tRunner(0xc00050e900, 0x2657c78)
	GOROOT/src/testing/testing.go:1108 +0x203
created by testing.(*T).Run
	GOROOT/src/testing/testing.go:1159 +0x797

@cjwagner
Copy link
Member Author

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.

@cjwagner
Copy link
Member Author

More apparently unrelated errors for boilerplate in files I didn't touch...

2 files have incorrect boilerplate headers:
prow/test/integration/test/crier_test.go
prow/test/integration/test/overall_test.go

It is unclear to me why this started failing now, but didn't fail on the PR that introduced the boilerplate: #20521

@spiffxp
Copy link
Member

spiffxp commented Jan 30, 2021

/cc

Copy link
Contributor

@chaodaiG chaodaiG left a 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

// 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:"-"`
Copy link
Contributor

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.

Copy link
Member Author

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?

Copy link
Contributor

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.

Copy link
Member Author

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?

Copy link
Member

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:

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:

// Repos is either of the form org/repos or just org.
Repos []string `json:"repos,omitempty"`

Copy link
Member Author

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.

Copy link
Member

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

Copy link
Member Author

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.

releng/config-forker/main.go Show resolved Hide resolved
Copy link
Member Author

@cjwagner cjwagner left a 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.

releng/config-forker/main.go Show resolved Hide resolved
// 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:"-"`
Copy link
Member Author

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?

@k8s-ci-robot k8s-ci-robot added the area/prow/plank Issues or PRs related to prow's plank component label Feb 10, 2021
@cjwagner
Copy link
Member Author

cjwagner commented Mar 4, 2021

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.
Only the newest commit contains substantive code changes since the last review, other commits were just rebased.

@alvaroaleman
Copy link
Member

Sorry, a bit underwater atm, will look early next week

@alvaroaleman
Copy link
Member

Yeah, the way it's implemented now looks good :) There are still a few outstanding comments from a previous review, though

@cjwagner
Copy link
Member Author

There are still a few outstanding comments from a previous review, though

My apologies, I forgot to implement those changes. I believe I've addressed everything now.

@cjwagner
Copy link
Member Author

@chaodaiG @alvaroaleman PTAL. Changes since the last review are in their own commit for convenience.

Copy link
Member

@alvaroaleman alvaroaleman left a 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)?

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Mar 17, 2021
@alvaroaleman
Copy link
Member

/hold

@k8s-ci-robot k8s-ci-robot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Mar 17, 2021
@k8s-ci-robot
Copy link
Contributor

[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 /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@cjwagner
Copy link
Member Author

/label tide/merge-method-squash
/hold cancel

@k8s-ci-robot k8s-ci-robot added tide/merge-method-squash Denotes a PR that should be squashed by tide when it merges. and removed do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. labels Mar 17, 2021
@k8s-ci-robot k8s-ci-robot merged commit 1acac76 into kubernetes:master Mar 17, 2021
@k8s-ci-robot k8s-ci-robot added this to the v1.21 milestone Mar 17, 2021
@cjwagner cjwagner deleted the decoration-defaulting branch May 4, 2021 00:48
wking added a commit to wking/kubernetes-test-infra that referenced this pull request Jun 23, 2021
…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.
wking added a commit to wking/kubernetes-test-infra that referenced this pull request Jun 23, 2021
…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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. area/config Issues or PRs related to code in /config area/prow/crier Issues or PRs related to prow's crier component area/prow/deck Issues or PRs related to prow's deck component area/prow/plank Issues or PRs related to prow's plank component area/prow/spyglass Issues or PRs related to prow's spyglass UI area/prow Issues or PRs related to prow area/release-eng Issues or PRs related to the Release Engineering subproject area/testgrid cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm "Looks good to me", indicates that a PR is ready to be merged. sig/release Categorizes an issue or PR as relevant to SIG Release. sig/testing Categorizes an issue or PR as relevant to SIG Testing. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. tide/merge-method-squash Denotes a PR that should be squashed by tide when it merges.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants