-
Notifications
You must be signed in to change notification settings - Fork 4.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
set default build prune limits for group api #14845
Conversation
[testextended][extended:core(builds)] |
0389e9f
to
cf46f52
Compare
@openshift/devex ptal |
[test] |
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 minor nit
var Strategy = strategy{kapi.Scheme, names.SimpleNameGenerator} | ||
var Strategy = strategy{kapi.Scheme, names.SimpleNameGenerator, false} | ||
|
||
// GroupStrategy is the default logic that applies when creating and updating BuildConfig objects. |
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.
comment - GroupStrategy
code - LegacyStrategy
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, fixed.
var Strategy = strategy{kapi.Scheme, names.SimpleNameGenerator} | ||
var Strategy = strategy{kapi.Scheme, names.SimpleNameGenerator, false} | ||
|
||
// LegacyStrategy is the default logic that applies when creating and updating BuildConfig objects. |
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.
Should this comment and the one for Strategy be more explanatory? Like, why would one be applied over the other? As they stand it sounds like they are both applied by default?
Also, s/applies/is applied/ ?
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'll expand the comment. applies is correct/intentional. "this is the rule that applies in this situation"
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.
updated
For reference here's the other backcompat change view it on GitHub
<#14818 (comment)>
…On Thu, Jun 22, 2017 at 7:23 PM, OpenShift Bot ***@***.***> wrote:
continuous-integration/openshift-jenkins/testextended SUCCESS (
https://ci.openshift.redhat.com/jenkins/job/test_pull_
request_origin_extended/700/) (Base Commit: 4423ff5
<4423ff5>)
(PR Branch Commit: cf46f52
<cf46f52>)
(Extended Tests: core(builds))
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#14845 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ABG_p-BPUsi0Wa4xqh6tLIOL9guyeZThks5sGvd2gaJpZM4OCz7a>
.
|
looks at least superficially similar to what i've done here. That one might be a bit more architectually pure but do you have any concerns w/ how i've done it here? |
pkg/build/api/types.go
Outdated
// DefaultSuccessfulBuildsHistoryLimit is the default number of successful builds to retain | ||
// if the buildconfig does not specify a value. This only applies to buildconfigs created | ||
// via the new group api resource, not the legacy resource. | ||
DefaultSuccessfulBuildsHistoryLimit = int32(5) |
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.
could be consts?
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.
no because i need a pointer value at assignment time and you can't take an address of a const.
(so they could be consts, but then we'd have to do a secondary assignment at the point of use)
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's a nit, but isn't that a good argument for them to be consts?
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.
you mean to avoid someone inadvertently changing them after something else has a pointer to 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.
Yes.
// LegacyStrategy is the default logic that applies when creating BuildConfig objects. | ||
// Specifically it will not set the default build pruning limit values because that was not | ||
// part of the legacy api. | ||
var LegacyStrategy = strategy{kapi.Scheme, names.SimpleNameGenerator, true} |
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.
Nice. I like having different strategies.
|
||
// legacy buildconfig api does not apply default pruning values, to maintain | ||
// backwards compatibility. | ||
if !s.legacy { |
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.
Any chance of actually having different types and losing this if block?
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.
you mean two separate impls? (with one presumably embedding the other and then overriding this specific logic?) I can..
@jim-minter made it a constant ptal |
// Canonicalize normalizes the object after validation. | ||
func (strategy) Canonicalize(obj runtime.Object) { | ||
} | ||
|
||
// PrepareForCreateCommon clears fields that are not allowed to be set by end users on creation. | ||
// This is shared by the Group and Legacy strategies. | ||
func (s strategy) PrepareForCreateCommon(ctx apirequest.Context, obj runtime.Object) { |
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.
This could just be PrepareForCreate
and the impl are just specific when they call, right?
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.
if i didn't want to share the common behavior, yes. but I didn't want to write the common behavior in both impls. Am I missing a composition pattern?
pkg/cmd/cli/cmd/exporter.go
Outdated
@@ -148,7 +148,7 @@ func (e *DefaultExporter) Export(obj runtime.Object, exact bool) error { | |||
return deployrest.Strategy.Export(ctx, obj, exact) | |||
|
|||
case *buildapi.BuildConfig: | |||
buildconfigrest.Strategy.PrepareForCreate(ctx, obj) | |||
buildconfigrest.GroupStrategy.PrepareForCreate(ctx, obj) |
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.
Shouldn't this vary based on how you requested the buildconfig?
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. can i determine that by looking at the obj.TypeMeta?
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.
leave this as legacy. The new endpoint will have it, the old one won't, and you don't want to twiddle it.
pkg/cmd/server/origin/legacy.go
Outdated
@@ -198,6 +199,7 @@ func LegacyStorage(storage map[schema.GroupVersion]map[string]rest.Storage) map[ | |||
restStorage := s.(*buildconfigetcd.REST) | |||
store := *restStorage.Store | |||
store.DeleteStrategy = orphanByDefault(store.DeleteStrategy) |
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.
This ought to actually be updated to just set it properly in the legacy strategy, right? Followup is ok.
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.
yeah i guess that makes sense. i'll just do it here.
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.
updated.
@@ -149,4 +152,34 @@ var _ = g.Describe("[builds][pruning] prune builds based on settings in the buil | |||
|
|||
}) | |||
|
|||
g.It("buildconfigs should have a default history limit set when created via the group api", func() { |
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.
Seems like you might want this as an integration test to stop any merge from succeeding if it breaks 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.
we run these tests nightly and check the results, i can live w/ it for now at least.
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.
Why not add them to conformance, they should be cheap?
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.
Or are they not cheap?
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.
they're "relatively" cheap. they all involve running builds which is never less than a minute or so, even though we're not pushing anywhere.
anyway i did end up adding a unit test, so at least if someone breaks the strategy we'll know. if they stop using the strategy, we'll find out when the nightly run fails.
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.
(sorry, these tests in particular do not run builds. i guess i can add just the new ones to conformance)
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.
done
Evaluated for origin merge up to d039a9b |
[test] |
@smarterclayton @stevekuznetsov ummm?
https://ci.openshift.redhat.com/jenkins/job/test_pull_request_origin_extended/771/consoleFull |
docker should be able to handle all of this correctly without the two problems in this patch. It hard codes svirt_sandbox_file_t, which is actually policy specific, even if basically everyone uses our reference policy. It means that things under that directory could (if they can break out of their mount namespace) see this directory. docker doesn't require this anymore. So remove this custom hack.
/me shakes tiny fist @eparis |
xref: #14937 |
Evaluated for origin testextended up to 17a2e33 |
Evaluated for origin test up to 17a2e33 |
continuous-integration/openshift-jenkins/test SUCCESS (https://ci.openshift.redhat.com/jenkins/job/test_pull_request_origin/2760/) (Base Commit: 3ff2db7) (PR Branch Commit: 17a2e33) |
continuous-integration/openshift-jenkins/testextended SUCCESS (https://ci.openshift.redhat.com/jenkins/job/test_pull_request_origin_extended/777/) (Base Commit: 3ff2db7) (PR Branch Commit: 17a2e33) (Extended Tests: core(builds)) |
@bparees should documentation be updated that the "build history" graph will no longer be seeing while using this new endpoint, as by default will never reach the amount of builds to show that graph? Is it worth keeping that graph in the page? |
@jorgemoralespou that's probably a better question for @jwforres or @spadgett but it's a good point. |
@bparees what are the new defaults? |
1 success and 1 failed I think.
|
Although looking at the code it seems to be 5 each. I seem to have misunderstood first comment as it defaulted to 1. So disregard the comment. |
On Fri, Jul 14, 2017 at 8:43 AM, Jorge Morales Pou ***@***.*** > wrote:
Although looking at the code it seems to be 5 each.
5 would show up in the history
… I'll let @bparees <https://github.com/bparees> answer.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#14845 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ABZk7f3wcxi9-zA_DhIw93tZW2RMmwzkks5sN2JigaJpZM4OCz7a>
.
|
it's 5. @jorgemoralespou where did you see 1? |
@bparees lost in translation. Read a for 1 in your first comment.
|
We show the chart if there are 4 builds. |
There. Are. FOUR. Builds. |
@bparees I'm liking you more every day. I know is not reciprocal though.
We'll get there ONE (1) day.
|
introduces behavior that will default a successful and failed build history limit for buildconfigs that are created via the new group api. legacy api behavior remains the same (no default limit, all builds are kept).