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 for DeploymentConfigSpec.RevisionHistoryLimit in apps/v1 #15642

Conversation

tnozicka
Copy link
Contributor

@tnozicka tnozicka commented Aug 4, 2017

At this point we don't default DeploymentConfigSpec.RevisionHistoryLimit in apps/v1 which is causing the deployments to have unlimited history which will lead to performance issues at scale and when deploying regularly.

Note that upstream also defaulted RevisionHistoryLimit to 10 for Deployments in kubernetes/kubernetes#49924

Needs to be backported to 3.6.1 as well.

cc: @smarterclayton @mfojtik @Kargakis

@openshift-merge-robot openshift-merge-robot added the size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label Aug 4, 2017
@tnozicka
Copy link
Contributor Author

tnozicka commented Aug 4, 2017

@openshift/api-review

@tnozicka tnozicka force-pushed the add-default-for-deploymentconfigs branch 2 times, most recently from 5bd21ec to d724258 Compare August 4, 2017 19:10
@0xmichalis
Copy link
Contributor

/approve
/lgtm

@openshift-ci-robot openshift-ci-robot added the lgtm Indicates that a PR is ready to be merged. label Aug 4, 2017
@tnozicka
Copy link
Contributor Author

tnozicka commented Aug 5, 2017

infra failed
/test unit

@0xmichalis
Copy link
Contributor

/retest

2 similar comments
@tnozicka
Copy link
Contributor Author

tnozicka commented Aug 7, 2017

/retest

@tnozicka
Copy link
Contributor Author

tnozicka commented Aug 7, 2017

/retest

@smarterclayton smarterclayton removed the lgtm Indicates that a PR is ready to be merged. label Aug 7, 2017
@smarterclayton
Copy link
Contributor

smarterclayton commented Aug 7, 2017

My email never got delivered it looks like. The defaults can only be applied when creating via the "apps.openshift.io" group, not the default group. There needs to be specific code to check for that just like: https://github.com/openshift/origin/blob/master/pkg/cmd/server/origin/legacy.go#L190

Removing label

@tnozicka
Copy link
Contributor Author

tnozicka commented Aug 8, 2017

@smarterclayton my bad :( It was already like 9 PM on Friday for me and I was misguided by defaulters located under path deploy/apis/apps/v1/defaults.go. Should have tested creating resources in both API groups though...

I am feeling a bit hesitant to do this at storage layer but I might be wrong. We have defaulters, right? But at this point we register the same ones for legacy and the new group

LegacySchemeBuilder = runtime.NewSchemeBuilder(addLegacyKnownTypes, addConversionFuncs, RegisterDefaults)
AddToSchemeInCoreGroup = LegacySchemeBuilder.AddToScheme
SchemeBuilder = runtime.NewSchemeBuilder(addKnownTypes, addConversionFuncs, RegisterDefaults)

Shouldn't I better plumb it there?

@tnozicka tnozicka changed the title Set default for DeploymentConfigSpec.RevisionHistoryLimit in apps/v1 WIP - Set default for DeploymentConfigSpec.RevisionHistoryLimit in apps/v1 Aug 8, 2017
@smarterclayton
Copy link
Contributor

smarterclayton commented Aug 8, 2017 via email

@tnozicka tnozicka force-pushed the add-default-for-deploymentconfigs branch from d724258 to 1c0c4a3 Compare August 10, 2017 16:28
@openshift-merge-robot openshift-merge-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Aug 10, 2017
@@ -206,7 +207,8 @@ func LegacyStorage(storage map[schema.GroupVersion]map[string]rest.Storage) map[
case "deploymentConfigs":
restStorage := s.(*deploymentconfigetcd.REST)
store := *restStorage.Store
restStorage.DeleteStrategy = orphanByDefault(store.DeleteStrategy)
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 have my doubts about if this ever worked - restStorage should have been store

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@smarterclayton @mfojtik This seems to be indeed a bug that we have carried for a long time.

What do we want to do with legacy API cascade deletion? We enabled it for new DCs by

"ownerReferences":[{"apiVersion":"%s","kind":"%s","name":"%s","uid":"%s","controller":true,"blockOwnerDeletion":true}],
but fixing this bug seems to mitigate it. You can see it broken in our test using the legacy client:
err = oc.Client().DeploymentConfigs(namespace).Delete(dcName)
https://ci.openshift.redhat.com/jenkins/job/test_pull_request_origin_extended_conformance_install_update/4085/testReport/junit/(root)/Extended/deploymentconfigs__should_adhere_to_Three_Laws_of_Controllers__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.

I was wrong that the patch would change the propagation policy. (We used to set a finalizer here, but now there is only blockOwnerDeletion which doesn't affect it in that way. So I will rephrase the question:

@smarterclayton @mfojtik I guess we initially wanted DCs created by legacy API not to have cascading deletion but given that we have failed at it due to this bug. Given that it has already been in a release (https://github.com/openshift/origin/blame/master/pkg/cmd/server/origin/legacy.go#L209) do we want to turn it back again? What's the policy for that?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Contributor

Choose a reason for hiding this comment

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

@tnozicka that is right, it should be store and not restStorage (@deads2k).

I think we should fix this bug and backport to 3.5, @deads2k @smarterclayton thoughts?

@tnozicka tnozicka force-pushed the add-default-for-deploymentconfigs branch 3 times, most recently from daa4e87 to a78eaf1 Compare August 10, 2017 16:50
@tnozicka
Copy link
Contributor Author

I wanted to wrap the defaulting functions just for group API SchemeBuilder but that didn't work because they get called even for legacy resources (it calls defaulting functions twice for legacy resources) so I ended up modifying it on storage layer.

I am not excited to have defaulting scattered between 2 places but this is probably the only option here. And BuildConfigs do the same.

I will add an integration test tomorrow but this is mostly done.


dc := obj.(*deployapi.DeploymentConfig)

if dc.Spec.RevisionHistoryLimit == nil {
Copy link
Contributor

Choose a reason for hiding this comment

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

Split this into its own method for sanity. func AppsV1DeploymentConfigLayeredDefaults(*deployapi.DeploymentConfig) and add a good godoc comment.

@tnozicka tnozicka force-pushed the add-default-for-deploymentconfigs branch from a78eaf1 to b5dedb9 Compare August 10, 2017 18:21
@tnozicka tnozicka force-pushed the add-default-for-deploymentconfigs branch from 0f626b9 to a7a5b81 Compare August 11, 2017 19:06
@tnozicka tnozicka changed the title WIP - Set default for DeploymentConfigSpec.RevisionHistoryLimit in apps/v1 Set default for DeploymentConfigSpec.RevisionHistoryLimit in apps/v1 Aug 11, 2017
@smarterclayton
Copy link
Contributor

Looks good to me, go ahead and squash.

@tnozicka tnozicka force-pushed the add-default-for-deploymentconfigs branch from a7a5b81 to 0df2c1c Compare August 14, 2017 07:34
@tnozicka
Copy link
Contributor Author

yum repo flake
/retest

@smarterclayton
Copy link
Contributor

/retest

@tnozicka
Copy link
Contributor Author

I will need to plumb in the new group client for tests and use that in

g.By("deleting owned RCs when deleted", func() {
// FIXME: Add delete option when we have new client available.
// This is working fine now because of finalizers on RCs but when GC gets fixed
// and we remove them this will probably break and will require setting deleteOptions
// to achieve cascade delete
err = oc.Client().DeploymentConfigs(namespace).Delete(dcName)

instead of the legacy client - that's why the extended_conformance_gce test is failing

@tnozicka tnozicka force-pushed the add-default-for-deploymentconfigs branch from 0df2c1c to 3aa370c Compare August 23, 2017 22:14
@openshift-merge-robot openshift-merge-robot added size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. and removed size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Aug 23, 2017
@tnozicka
Copy link
Contributor Author

tnozicka commented Aug 23, 2017

  • rebased to master
  • plumbed in the group API into testing framework (only for AppsV1 now, but in a general and extensible way
  • fixed the cascade delete test using the group API

@smarterclayton
Copy link
Contributor

Looks perfect

/lgtm

@openshift-ci-robot openshift-ci-robot added the lgtm Indicates that a PR is ready to be merged. label Aug 23, 2017
@openshift-merge-robot openshift-merge-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Aug 23, 2017
@tnozicka tnozicka force-pushed the add-default-for-deploymentconfigs branch from 3aa370c to c30b39f Compare August 24, 2017 05:47
@openshift-merge-robot openshift-merge-robot removed the lgtm Indicates that a PR is ready to be merged. label Aug 24, 2017
@tnozicka
Copy link
Contributor Author

Seems like some changes in code generation went into master from last time I run make update.
Updated files:

	modified:   pkg/user/generated/informers/externalversions/generic.go
	new file:   pkg/user/generated/informers/externalversions/user/v1/identity.go
	modified:   pkg/user/generated/informers/externalversions/user/v1/interface.go
	modified:   pkg/user/generated/informers/internalversion/generic.go
	new file:   pkg/user/generated/informers/internalversion/user/internalversion/identity.go
	modified:   pkg/user/generated/informers/internalversion/user/internalversion/interface.go
	modified:   pkg/user/generated/listers/user/internalversion/expansion_generated.go
	new file:   pkg/user/generated/listers/user/internalversion/identity.go
	modified:   pkg/user/generated/listers/user/internalversion/user.go
	modified:   pkg/user/generated/listers/user/v1/expansion_generated.go
	new file:   pkg/user/generated/listers/user/v1/identity.go

no other changes

@tnozicka
Copy link
Contributor Author

/retest

…to 10.

Fix tests now that we are really not doing cascade delete for legacy API. (Brings group API into tests.)
@tnozicka tnozicka force-pushed the add-default-for-deploymentconfigs branch from c30b39f to e74af9d Compare August 25, 2017 08:46
@tnozicka
Copy link
Contributor Author

Another change in code generation in master - rebased and added new generated files:

	modified:   api/docs/apis-apps.openshift.io/v1.DeploymentConfig.adoc
	modified:   api/docs/oapi/v1.DeploymentConfig.adoc

@mfojtik
Copy link
Contributor

mfojtik commented Aug 25, 2017

/lgtm

@openshift-ci-robot openshift-ci-robot added the lgtm Indicates that a PR is ready to be merged. label Aug 25, 2017
@openshift-merge-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: kargakis, mfojtik, smarterclayton, tnozicka

The full list of commands accepted by this bot can be found here.

Needs approval from an approver in each of these OWNERS Files:
  • OWNERS [mfojtik,smarterclayton]

You can indicate your approval by writing /approve in a comment
You can cancel your approval by writing /approve cancel in a comment

@openshift-merge-robot
Copy link
Contributor

/test all [submit-queue is verifying that this PR is safe to merge]

@openshift-merge-robot
Copy link
Contributor

Automatic merge from submit-queue

@openshift-merge-robot openshift-merge-robot merged commit a6abbaf into openshift:master Aug 25, 2017
@tnozicka
Copy link
Contributor Author

@Kargakis not that I want to complain but submit queue probably shouldn't merge PRs with needs-api-review label

@tnozicka tnozicka deleted the add-default-for-deploymentconfigs branch August 25, 2017 13:42
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. lgtm Indicates that a PR is ready to be merged. needs-api-review size/XL Denotes a PR that changes 500-999 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants