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

set default build prune limits for group api #14845

Merged
merged 1 commit into from
Jun 28, 2017

Conversation

bparees
Copy link
Contributor

@bparees bparees commented Jun 22, 2017

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

@bparees
Copy link
Contributor Author

bparees commented Jun 22, 2017

[testextended][extended:core(builds)]

@bparees bparees force-pushed the default_pruning branch 2 times, most recently from 0389e9f to cf46f52 Compare June 22, 2017 20:40
@bparees
Copy link
Contributor Author

bparees commented Jun 22, 2017

@openshift/devex ptal
@smarterclayton @deads2k ptal also in case i've taken an insane approach.

@openshift openshift deleted a comment from openshift-bot Jun 22, 2017
@openshift openshift deleted a comment from openshift-bot Jun 22, 2017
@bparees
Copy link
Contributor Author

bparees commented Jun 22, 2017

[test]

Copy link
Contributor

@gabemontero gabemontero left a 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.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

comment - GroupStrategy

code - LegacyStrategy

Copy link
Contributor Author

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.
Copy link
Member

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/ ?

Copy link
Contributor Author

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"

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated

@smarterclayton
Copy link
Contributor

smarterclayton commented Jun 22, 2017 via email

@bparees
Copy link
Contributor Author

bparees commented Jun 23, 2017

For reference here's the other backcompat change view it on GitHub

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?

// 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)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could be consts?

Copy link
Contributor Author

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)

Copy link
Contributor

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?

Copy link
Contributor Author

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?

Copy link
Contributor

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}
Copy link
Contributor

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 {
Copy link
Contributor

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?

Copy link
Contributor Author

@bparees bparees Jun 23, 2017

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

@openshift openshift deleted a comment from openshift-bot Jun 25, 2017
@openshift openshift deleted a comment from openshift-bot Jun 25, 2017
@openshift openshift deleted a comment from openshift-bot Jun 25, 2017
@openshift openshift deleted a comment from openshift-bot Jun 25, 2017
@openshift openshift deleted a comment from openshift-bot Jun 25, 2017
@bparees
Copy link
Contributor Author

bparees commented Jun 26, 2017

@jim-minter made it a constant
@deads2k introduced a full strategy hierarchy

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) {
Copy link
Contributor

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?

Copy link
Contributor Author

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?

@@ -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)
Copy link
Contributor

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?

Copy link
Contributor Author

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?

Copy link
Contributor

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.

@@ -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)
Copy link
Contributor

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.

Copy link
Contributor Author

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.

Copy link
Contributor Author

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() {
Copy link
Contributor

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.

Copy link
Contributor Author

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.

Copy link
Contributor

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?

Copy link
Contributor

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?

Copy link
Contributor Author

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.

Copy link
Contributor Author

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)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@openshift-bot
Copy link
Contributor

Evaluated for origin merge up to d039a9b

@smarterclayton
Copy link
Contributor

[test]

@openshift openshift deleted a comment from openshift-bot Jun 27, 2017
@bparees
Copy link
Contributor Author

bparees commented Jun 27, 2017

@smarterclayton @stevekuznetsov ummm?

[INFO] Starting server
chcon: invalid context: /var/lib/openshift/openshift.local.volumes	system_u:object_r:openshift_var_lib_t:s0
[ERROR] PID 23536: test/extended/setup.sh:88: `${sudo} chcon "${label}" ${VOLUME_DIR}` exited with status 1.
[INFO] 		Stack Trace: 
[INFO] 		  1: test/extended/setup.sh:88: `${sudo} chcon "${label}" ${VOLUME_DIR}`
[INFO] 		  2: test/extended/core.sh:8: os::test::extended::setup
[INFO]   Exiting with code 1.
/data/src/github.com/openshift/origin/hack/lib/log/system.sh: line 31: 26206 Terminated              sar -A -o "${binary_logfile}" 1 86400 > /dev/null 2> "${stderr_logfile}"
[INFO] [CLEANUP] Beginning cleanup routines...
[INFO] [CLEANUP] Dumping cluster events to _output/scripts/core/artifacts/events.txt
error: A server URL must be specified
[INFO] [CLEANUP] Dumping etcd contents to _output/scripts/core/artifacts/etcd
[WARNING] No compiled `etcdhelper` binary was found. Attempting to build one using:
[WARNING]   $ hack/build-go.sh tools/etcdhelper
++ Building go targets for linux/amd64: tools/etcdhelper
/data/src/github.com/openshift/origin/hack/build-go.sh took 65 seconds
ERROR: unable to create client config: open /tmp/openshift/core/openshift.local.config/master/master.etcd-client.crt: no such file or directory
[INFO] [CLEANUP] Dumping container logs to _output/scripts/core/logs/containers
[INFO] [CLEANUP] Truncating log files over 200M
[INFO] [CLEANUP] Stopping docker containers
[INFO] [CLEANUP] Removing docker containers
[INFO] [CLEANUP] Killing child processes
[INFO] [CLEANUP] Pruning etcd data directory
[ERROR] test/extended/core.sh exited with code 1 after 00h 02m 03s
make: *** [test-extended] Error 1
++ export status=FAILURE
++ status=FAILURE
+ set +o xtrace
########## FINISHED STAGE: FAILURE: RUN EXTENDED TESTS [00h 02m 03s] ##########

https://ci.openshift.redhat.com/jenkins/job/test_pull_request_origin_extended/771/consoleFull

stevekuznetsov referenced this pull request Jun 28, 2017
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.
@stevekuznetsov
Copy link
Contributor

@eparis looks like your changes in 88e4c71 may be causing the above

@bparees
Copy link
Contributor Author

bparees commented Jun 28, 2017

/me shakes tiny fist @eparis

@stevekuznetsov
Copy link
Contributor

xref: #14937

@openshift openshift deleted a comment from openshift-bot Jun 28, 2017
@openshift openshift deleted a comment from openshift-bot Jun 28, 2017
@openshift openshift deleted a comment from eparis Jun 28, 2017
@openshift-bot
Copy link
Contributor

Evaluated for origin testextended up to 17a2e33

@openshift-bot
Copy link
Contributor

Evaluated for origin test up to 17a2e33

@openshift-bot
Copy link
Contributor

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)

@openshift-bot
Copy link
Contributor

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

@smarterclayton smarterclayton merged commit 583c3bd into openshift:master Jun 28, 2017
@bparees bparees deleted the default_pruning branch June 30, 2017 21:04
@jorgemoralespou
Copy link

@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?

@bparees
Copy link
Contributor Author

bparees commented Jul 14, 2017

@jorgemoralespou that's probably a better question for @jwforres or @spadgett but it's a good point.

@jwforres
Copy link
Member

@bparees what are the new defaults?

@jorgemoralespou
Copy link

jorgemoralespou commented Jul 14, 2017 via email

@jorgemoralespou
Copy link

jorgemoralespou commented Jul 14, 2017

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.

@jwforres
Copy link
Member

jwforres commented Jul 14, 2017 via email

@bparees
Copy link
Contributor Author

bparees commented Jul 14, 2017

it's 5. @jorgemoralespou where did you see 1?

@jorgemoralespou
Copy link

@bparees lost in translation. Read a for 1 in your first comment.

introduces behavior that will default a successful and failed build history limit

@spadgett
Copy link
Member

@bparees
Copy link
Contributor Author

bparees commented Jul 14, 2017

There. Are. FOUR. Builds.

@jorgemoralespou
Copy link

jorgemoralespou commented Jul 14, 2017 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.