Skip to content

Fix deployment generator after introducing deployments in apps/v1beta1#42362

Merged
k8s-github-robot merged 3 commits into
kubernetes:masterfrom
soltysh:deployment_generators
Mar 10, 2017
Merged

Fix deployment generator after introducing deployments in apps/v1beta1#42362
k8s-github-robot merged 3 commits into
kubernetes:masterfrom
soltysh:deployment_generators

Conversation

@soltysh

@soltysh soltysh commented Mar 1, 2017

Copy link
Copy Markdown
Contributor

This PR does two things:

  1. Switches all generator to produce versioned objects, to bypass the problem of having an object in multiple versions, which then results in not having stable generator (iow. producing exactly the same object).
  2. Introduces new generator for apps/v1beta1 deployments.

@Kargakis @janetkuo ptal

@kubernetes/sig-apps-pr-reviews @kubernetes/sig-cli-pr-reviews ptal

This is a followup to #39683, so I'm adding 1.6 milestone.

Introduce new generator for apps/v1beta1 deployments

@soltysh soltysh added area/workload-api/deployment release-note Denotes a PR that will be considered when it comes time to generate release notes. sig/apps Categorizes an issue or PR as relevant to SIG Apps. labels Mar 1, 2017
@soltysh soltysh added this to the v1.6 milestone Mar 1, 2017
@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Mar 1, 2017
@k8s-github-robot k8s-github-robot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Mar 1, 2017
@calebamiles calebamiles added the do-not-merge DEPRECATED. Indicates that a PR should not merge. Label can only be manually applied/removed. label Mar 1, 2017
@calebamiles

Copy link
Copy Markdown
Contributor

Added do-not-merge label for new feature. @soltysh is this PR a bug fix or a new feature? We are currently in code slush and new features should follow the exception process. The previous expectation from the 1.5 release was to approve a singular exception which should have covered PRs which were currently in flight. I'm a bit worried about these large changes coming in so late in the release process but maybe someone from @kubernetes/release-team will have other opinions.

cc: @ethernetdan

@janetkuo

janetkuo commented Mar 1, 2017

Copy link
Copy Markdown
Member

We need to handle version skew using discovery. We already have the discovery code in cmd/run.go. So if the server doesn't support apps/v1beta1, we fall back to extensions/v1beta1, and manually change default values to match the behavior in apps/v1beta1.

Please also update the PR title to make it more descriptive.

@janetkuo

janetkuo commented Mar 1, 2017

Copy link
Copy Markdown
Member

@calebamiles this is more of a bug fix because kubectl run default behavior is changed (after #39683 is merged), and we need this so that we don't break users

@calebamiles

Copy link
Copy Markdown
Contributor

@janetkuo, thank you for your description but I feel like I'm even more confused about why #39683 was merged. @ethernetdan, my gut instinct would be to revert #39683 and deal with that PR and this one during the 1.7 release cycle Thoughts, @ethernetdan?

cc" @kubernetes/release-team

@ethernetdan

Copy link
Copy Markdown
Contributor

@calebamiles I think I have to agree - the original PR did not follow the exception process and should not have been merged. Given the criteria we have been applying to other exceptions I don't think if it would've been approved.

I'd say let's put a revert PR in to see how cleanly it can be removed and we can discuss the change there. How does that sound?

@smarterclayton

Copy link
Copy Markdown
Contributor

Deployments not going to beta in 1.6 is pretty significant - id prefer that @soltysh start the exception process now and have the discussion there.

@calebamiles

Copy link
Copy Markdown
Contributor

Revert PR: #42368

@k8s-reviewable

Copy link
Copy Markdown

This change is Reviewable

@soltysh

soltysh commented Mar 2, 2017

Copy link
Copy Markdown
Contributor Author

@smarterclayton @ethernetdan @calebamiles I've emailed about this and CronJobs exception Monday afternoon (CET) and have not heard back since than other than initial approval from @idvoretskyi and a few +1 on it. I assumed this was enough to proceed with this.

@0xmichalis

Copy link
Copy Markdown
Contributor

Worth noting that the PR has been ready for review for two weeks and the change has been discussed in sig-apps even longer before the PR was opened (more than a month).

@soltysh soltysh changed the title Deployment generators Fix deployment generator after introducing deployments in apps/v1beta1 Mar 2, 2017
@soltysh soltysh force-pushed the deployment_generators branch from 7b42b8b to c426c8f Compare March 2, 2017 13:51
@soltysh

soltysh commented Mar 2, 2017

Copy link
Copy Markdown
Contributor Author

@Kargakis @janetkuo hopefully all comments addressed. I've added additional cmd test for the new generator and updated the title. ptal

Comment thread pkg/kubectl/cmd/run.go Outdated
switch restartPolicy {
case api.RestartPolicyAlways:
if contains(resourcesList, v1beta1.SchemeGroupVersion.WithResource("deployments")) {
if contains(resourcesList, appsv1beta1.SchemeGroupVersion.WithResource("deployments")) {

@0xmichalis 0xmichalis Mar 2, 2017

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

you got these backwards?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

OMG, I need a ☕️

@soltysh soltysh force-pushed the deployment_generators branch from c426c8f to d1944ff Compare March 2, 2017 14:06
@soltysh

soltysh commented Mar 2, 2017

Copy link
Copy Markdown
Contributor Author

@Kargakis should be fixed.

@0xmichalis

Copy link
Copy Markdown
Contributor

TestGenerate needs to be fixed

@soltysh soltysh force-pushed the deployment_generators branch from d1944ff to d50d207 Compare March 2, 2017 14:51
@k8s-github-robot k8s-github-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 Mar 2, 2017
@janetkuo

janetkuo commented Mar 8, 2017

Copy link
Copy Markdown
Member

Just chatted with @bgrant0607 offline about this PR and #42392. In conclusion, we think we should:

  1. Make extensions/v1betat1 the preferred deployment version instead of apps/v1beta1 (but don't revert Add apps/v1beta1 deployments with new defaults #39683)
  2. Make kubectl run and kubectl create use the old extensions/v1beta1 deployment generator by default
  3. New kubectl with apps/v1beta1 generator should work on old clusters (fall back to extensions/v1beta1 and apply new defaults)

More details about the discussions with @bgrant0607:

We agree that new defaults is a big UX improvement, and it might be okay to change the default values of deployment in kubectl run and kubectl create. However, we don't want to rush it at this moment. Let's wait for user feedback first.

As a side note, this behavior change problem could have been solved if we allow users to specify their preference for kubectl. For example, in each new release, kubectl will tell the users "hey behavior X is changed, do you want to keep the old or use the new behavior?", and users' answer will be kept in some preference file.

@soltysh

soltysh commented Mar 9, 2017

Copy link
Copy Markdown
Contributor Author

Make extensions/v1betat1 the preferred deployment version instead of apps/v1beta1 (but don't revert #39683)

That depends on what you mean preferred. If by preferred you mean that kubectl get deployment will reach out to extensions/v1beta1 that's not possible at the moment. The discovery mechanics do not allow us to specify preferred version for resource cohabiting in multiple groups (@kubernetes/sig-api-machinery-misc for confirmation). AFAIK it will pick one based on alphabetical order, so in this case apps/v1beta1 is the preferred one.
Having said that, both deployments are sharing single storage and data available under both API endpoints are the same (except for defaults when creating new deployments) thus it doesn't matter which endpoint you're hitting, as long as we're using kubectl 1.6 (or newer) which will know from discovery what is available. So the only worry is the next point, which is already addressed in this PR.

Make kubectl run and kubectl create use the old extensions/v1beta1 deployment generator by default

Done. One can explicitly use new generator for both kubectl run and kubectl create deployment specifying --generator flag. Appropriate test are in hack/make-rules/test-cmd-util.sh.

New kubectl with apps/v1beta1 generator should work on old clusters (fall back to extensions/v1beta1 and apply new defaults)

That I will object to, this will only complicate the code and confuse users. Only posting a deployment object to apps/v1beta1 will actually apply new defaults on server (!), no defaults are applied on client and this should stay as is. It's perfectly fine and already done to fallback to old generator for older clusters.

As a side note, this behavior change problem could have been solved if we allow users to specify their preference for kubectl. For example, in each new release, kubectl will tell the users "hey behavior X is changed, do you want to keep the old or use the new behavior?", and users' answer will be kept in some preference file.

This is awesome idea! I've created #42787 to discuss this further.

@0xmichalis

Copy link
Copy Markdown
Contributor

If we are ok with taking the kubectl compatibility breakage while relying on users handcrafting configs in order to take advantage of the new defaults, then I won't block on this anymore. Changes LGTM.

@bgrant0607

Copy link
Copy Markdown
Member

The issue I'm using for preferences is #10693

@janetkuo

janetkuo commented Mar 9, 2017

Copy link
Copy Markdown
Member

That I will object to, this will only complicate the code and confuse users. Only posting a deployment object to apps/v1beta1 will actually apply new defaults on server (!), no defaults are applied on client and this should stay as is. It's perfectly fine and already done to fallback to old generator for older clusters.

OK, maybe print some warning message like "generator foo isn't supported by server, falling back to bar", for this new client + old server case?

@soltysh

soltysh commented Mar 9, 2017

Copy link
Copy Markdown
Contributor Author

OK, maybe print some warning message like "generator foo isn't supported by server, falling back to bar", for this new client + old server case?

That's already done in this PR.

@soltysh

soltysh commented Mar 9, 2017

Copy link
Copy Markdown
Contributor Author

See this and this for the warnings.

@ethernetdan

Copy link
Copy Markdown
Contributor

@soltysh, @janetkuo, @bgrant0607: would it be possible to make a decision on this soon?

Currently this issue is breaking skew testing and blurring signal on upgrades.

cc/ @skriss

@soltysh

soltysh commented Mar 9, 2017

Copy link
Copy Markdown
Contributor Author

@ethernetdan this is done. Based on what @janetkuo said this is ready for merge. Just needs her lgtm and approval for merge.

@janetkuo janetkuo left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Only a few nits, LGTM otherwise

Comment thread pkg/kubectl/cmd/create_deployment.go Outdated
// fallback to the old generator if server does not support apps/v1beta deployments
if generatorName == cmdutil.DeploymentBasicAppsV1Beta1GeneratorName &&
!contains(resourcesList, appsv1beta1.SchemeGroupVersion.WithResource("deployments")) {
fmt.Fprintf(cmdErr, "New deployments generator specified, but apps/v1beta1.Deployments are not available, falling back to the old one.\n")

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Some suggestions:

  1. add generator names in the error message (i.e. cmdutil.DeploymentBasicV1Beta1GeneratorName and cmdutil.DeploymentBasicAppsV1Beta1GeneratorName)
  2. add "WARNING: " to the beginning of the error message

Comment thread pkg/kubectl/cmd/create_deployment.go Outdated
return fmt.Errorf("failed to discover supported resources: %v", err)
}
generatorName := cmdutil.GetFlagString(cmd, "generator")
// fallback to the old generator if server does not support apps/v1beta deployments

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

nit: v1beta1

Comment thread pkg/kubectl/cmd/run.go
if contains(resourcesList, v1beta1.SchemeGroupVersion.WithResource("deployments")) {
generatorName = "deployment/v1beta1"
// TODO: we need to deprecate this along with extensions/v1beta1.Deployments
// in favor of the new generator for apps/v1beta1.Deployments

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I assume we'll deprecate it by updating generator docs?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Or should we print deprecation message whenever extensions/v1beta1 generator is used (it'd be a bit too noisy)?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

We'll update the generator docs, which btw. needs updating when this merges. That's what we did when removing extensions/v1beta1.Jobs.

Comment thread pkg/kubectl/cmd/run.go
schedule := cmdutil.GetFlagString(cmd, "schedule")
if len(schedule) != 0 && len(generatorName) == 0 {
generatorName = "cronjob/v2alpha1"
generatorName = cmdutil.CronJobV2Alpha1GeneratorName

@janetkuo janetkuo Mar 9, 2017

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

We should check if cronjob is supported as well. But this can be fixed in a follow-up.

Comment thread pkg/kubectl/cmd/run.go Outdated
// TODO: this should be removed alongside with extensions/v1beta1 depployments generator
if generatorName == cmdutil.DeploymentAppsV1Beta1GeneratorName &&
!contains(resourcesList, appsv1beta1.SchemeGroupVersion.WithResource("deployments")) {
fmt.Fprintf(cmdErr, "New deployments generator specified, but apps/v1beta1.Deployments are not available, falling back to the old one.\n")

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Comment thread pkg/kubectl/run.go
return result, nil
}

// populateResourceListV1 takes strings of form <resourceName1>=<value1>,<resourceName1>=<value2>

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

nit: document what's returned

@soltysh soltysh force-pushed the deployment_generators branch from 7cfc63a to 597a359 Compare March 10, 2017 11:08
@soltysh

soltysh commented Mar 10, 2017

Copy link
Copy Markdown
Contributor Author

@janetkuo I've addressed the nits, since I'm at it I've also added the check for cronjob, ptal

@k8s-ci-robot

k8s-ci-robot commented Mar 10, 2017

Copy link
Copy Markdown
Contributor

@soltysh: The following test(s) failed:

Test name Commit Details Rerun command
Jenkins GKE smoke e2e d50d2078a25a4fb0232b8875e2d5306e4f9b7174 link @k8s-bot cvm gke e2e test this
Jenkins GCI GKE smoke e2e d50d2078a25a4fb0232b8875e2d5306e4f9b7174 link @k8s-bot gci gke e2e test this

Full PR test history. Your PR dashboard. Please help us cut down on flakes by linking to an open issue when you hit one in your PR.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. I understand the commands that are listed here.

@soltysh

soltysh commented Mar 10, 2017

Copy link
Copy Markdown
Contributor Author

@k8s-bot non-cri e2e test this

@janetkuo

Copy link
Copy Markdown
Member

/approve
/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Mar 10, 2017
@deads2k

deads2k commented Mar 10, 2017

Copy link
Copy Markdown
Contributor

/approve

@k8s-github-robot

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is APPROVED

The following people have approved this PR: deads2k, janetkuo, soltysh

Needs approval from an approver in each of these OWNERS Files:

We suggest the following people:
cc
You can indicate your approval by writing /approve in a comment
You can cancel your approval by writing /approve cancel in a comment

@k8s-github-robot k8s-github-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Mar 10, 2017
@k8s-github-robot

Copy link
Copy Markdown

Automatic merge from submit-queue (batch tested with PRs 38805, 42362, 42862)

@k8s-github-robot k8s-github-robot merged commit d2d3884 into kubernetes:master Mar 10, 2017
@soltysh soltysh deleted the deployment_generators branch March 10, 2017 22:04
@janetkuo

Copy link
Copy Markdown
Member

Hey @soltysh will you prepare the doc for the new generator?

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/workload-api/deployment cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/bug Categorizes issue or PR as related to a bug. lgtm "Looks good to me", indicates that a PR is ready to be merged. release-blocker release-note Denotes a PR that will be considered when it comes time to generate release notes. sig/apps Categorizes an issue or PR as relevant to SIG Apps. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.