Fix deployment generator after introducing deployments in apps/v1beta1#42362
Conversation
|
Added cc: @ethernetdan |
|
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. |
|
@calebamiles this is more of a bug fix because |
|
@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 |
|
@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? |
|
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. |
|
Revert PR: #42368 |
|
@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. |
|
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). |
7b42b8b to
c426c8f
Compare
| switch restartPolicy { | ||
| case api.RestartPolicyAlways: | ||
| if contains(resourcesList, v1beta1.SchemeGroupVersion.WithResource("deployments")) { | ||
| if contains(resourcesList, appsv1beta1.SchemeGroupVersion.WithResource("deployments")) { |
There was a problem hiding this comment.
you got these backwards?
c426c8f to
d1944ff
Compare
|
@Kargakis should be fixed. |
|
TestGenerate needs to be fixed |
d1944ff to
d50d207
Compare
|
Just chatted with @bgrant0607 offline about this PR and #42392. In conclusion, we think we should:
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 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, |
That depends on what you mean preferred. If by preferred you mean that
Done. One can explicitly use new generator for both
That I will object to, this will only complicate the code and confuse users. Only posting a deployment object to
This is awesome idea! I've created #42787 to discuss this further. |
|
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. |
|
The issue I'm using for preferences is #10693 |
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, @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 |
|
@ethernetdan this is done. Based on what @janetkuo said this is ready for merge. Just needs her lgtm and approval for merge. |
janetkuo
left a comment
There was a problem hiding this comment.
Only a few nits, LGTM otherwise
| // 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") |
There was a problem hiding this comment.
Some suggestions:
- add generator names in the error message (i.e.
cmdutil.DeploymentBasicV1Beta1GeneratorNameandcmdutil.DeploymentBasicAppsV1Beta1GeneratorName) - add "WARNING: " to the beginning of the error message
| 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 |
| 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 |
There was a problem hiding this comment.
I assume we'll deprecate it by updating generator docs?
There was a problem hiding this comment.
Or should we print deprecation message whenever extensions/v1beta1 generator is used (it'd be a bit too noisy)?
There was a problem hiding this comment.
We'll update the generator docs, which btw. needs updating when this merges. That's what we did when removing extensions/v1beta1.Jobs.
| schedule := cmdutil.GetFlagString(cmd, "schedule") | ||
| if len(schedule) != 0 && len(generatorName) == 0 { | ||
| generatorName = "cronjob/v2alpha1" | ||
| generatorName = cmdutil.CronJobV2Alpha1GeneratorName |
There was a problem hiding this comment.
We should check if cronjob is supported as well. But this can be fixed in a follow-up.
| // 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") |
There was a problem hiding this comment.
| return result, nil | ||
| } | ||
|
|
||
| // populateResourceListV1 takes strings of form <resourceName1>=<value1>,<resourceName1>=<value2> |
7cfc63a to
597a359
Compare
|
@janetkuo I've addressed the nits, since I'm at it I've also added the check for cronjob, ptal |
|
@soltysh: The following test(s) failed:
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. DetailsInstructions 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. |
|
@k8s-bot non-cri e2e test this |
|
/approve |
|
/approve |
|
[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: |
|
Automatic merge from submit-queue (batch tested with PRs 38805, 42362, 42862) |
|
Hey @soltysh will you prepare the doc for the new generator? |
This PR does two things:
apps/v1beta1deployments.@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.