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

StatefulSet: Don't try to update immutable hostname/subdomain fields. #51044

Merged
merged 1 commit into from
Aug 22, 2017

Conversation

kow3ns
Copy link
Member

@kow3ns kow3ns commented Aug 21, 2017

What this PR does / why we need it: The StatefulSet controller no longer attempts to mutate "hostname" or "subdomain" fields of the "pod.spec" to enforce the network identity of Pods in a StatefeulSet. Since these fields are set upon creation and immutable thereafter setting the annotations is no longer necessary.
fixes: #51043

@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Aug 21, 2017
@kow3ns kow3ns added the release-note-none Denotes a PR that doesn't merit a release note. label Aug 21, 2017
@k8s-github-robot k8s-github-robot added approved Indicates a PR has been approved by an approver from all required OWNERS files. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. release-note-label-needed and removed release-note-label-needed labels Aug 21, 2017
Copy link
Member

@enisoc enisoc left a comment

Choose a reason for hiding this comment

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

LGTM overall, one nit.

func initIdentity(set *apps.StatefulSet, pod *v1.Pod) {
updateIdentity(set, pod)
// Set these immutable fields only on initial Pod creation, not updates.
// Set hostname/subdomain in preparation for removal of the annotations.
Copy link
Member

Choose a reason for hiding this comment

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

This line of the comment is not applicable on this branch, since the annotations were already removed.

@enisoc
Copy link
Member

enisoc commented Aug 21, 2017

@kow3ns Random crazy idea: What if we continue to check whether the hostname/subdomain (fields) match our expectation, and if not, we delete the Pod? Basically a StatefulSet Pod in this state is broken anyway, and the controller's job is to repair them when they're broken.

@kow3ns
Copy link
Member Author

kow3ns commented Aug 21, 2017

@enisoc Possible to do, but probably unnecessary as the fields are immutable, and, if you came to 1.8.x by way of 1.7.x, you are already using the fields.

@kow3ns kow3ns force-pushed the sts-immutable-network-id branch from 6fb66ef to a6473d8 Compare August 21, 2017 20:08
@enisoc
Copy link
Member

enisoc commented Aug 21, 2017

Yes it's unnecessary on master. I was thinking about for the cherrypick into 1.7. The hostname/subdomain fields are part of the desired state that the controller wants to maintain. Should we give up on the Pod if those fields are immutable, or should we delete the Pod in order to make progress towards the desired state?

@kow3ns
Copy link
Member Author

kow3ns commented Aug 21, 2017

It requires some thought, you upgrade form 1.6 to 1.7, and all of a sudden you get an automatic rolling update across all of your stateful applications (assuming we do the safe thing and orchestrate the deletion trying to preserve availability where possible). If we warn users that the update has to be manually, prior to the upgrade, they can update applications individually, and safely, prior to performing the 1.6.x to 1.7.x upgrade.

@enisoc
Copy link
Member

enisoc commented Aug 21, 2017

Even if we do this, I would still recommend that users do it themselves before upgrading. The scenario I'm hoping to mitigate is if the user fails follow the recommendation. Their StatefulSet will get into a broken state that the controller can choose to either try to fix (by deleting Pods) or do nothing (because deleting Pods could make things worse). This may be moot though, because making a change that starts to delete Pods is probably too scary to do in a patch release. That's why I prefaced it by saying it's a crazy idea. :)

@enisoc
Copy link
Member

enisoc commented Aug 21, 2017

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Aug 21, 2017
@k8s-github-robot
Copy link

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: enisoc, kow3ns

Associated issue: 51043

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

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

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

Automatic merge from submit-queue (batch tested with PRs 51102, 50712, 51037, 51044, 51059)

@k8s-github-robot k8s-github-robot merged commit 336e38b into kubernetes:master Aug 22, 2017
@enisoc enisoc changed the title fix #51043 StatefulSet: Don't try to update immutable hostname/subdomain fields. Aug 22, 2017
@wojtek-t wojtek-t added this to the v1.7 milestone Aug 23, 2017
@wojtek-t wojtek-t added cherry-pick-approved Indicates a cherry-pick PR into a release branch has been approved by the release branch manager. cherrypick-candidate labels Aug 23, 2017
k8s-github-robot pushed a commit that referenced this pull request Aug 23, 2017
Automatic merge from submit-queue

Manual cherrypick of #51043

StatefulSet controller no longer attempts to mutate v1.PodSpec.Hostname or v1.PodSpec.Subdomain
fixes: #51043 
Partial fix for #48327 

Manual cherrypick of #51044

```release-note
StatefulSet: Fix "forbidden pod updates" error on Pods created prior to upgrading to 1.7. (#48327)
```
@k8s-cherrypick-bot
Copy link

Commit found in the "release-1.7" branch appears to be this PR. Removing the "cherrypick-candidate" label. If this is an error find help to get your PR picked.

k8s-github-robot pushed a commit that referenced this pull request Sep 27, 2017
Automatic merge from submit-queue.

Allow Hostname and Subdomain to be set if empty

**What this PR does / why we need it**:
This PR allows the Hostname and Subdomain field of v1.PodSpec to be set when empty, and modifies the StatefulSet controller to set them when empty. 

For #48327: 
We have merged #50942 to ensure that the Hostname and Subdomain fields are set when a new Pod is created. Users should upgrade to 1.6.9 and perform a rolling restart of all Pods in their StatefulSets to ensure that these fields are set prior to an upgrade to 1.7.5.
We have merged #51149 and #51044 to rollback the attempted mutation introduced in #44137.
This PR allows the Hostname and Subdomain field to be set exactly once, so that when users fail to read the notes, and encounter this issue, their clusters should self heal (even though they will experience a temporary network disruption for Pods in their StatefulSets.)

```release-note
StatefulSet will now fill the `hostname` and `subdomain` fields if they're empty on existing Pods it owns. This allows it to self-correct the issue where StatefulSet Pod DNS entries disappear after upgrading to v1.7.x (#48327).
```
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. cherry-pick-approved Indicates a cherry-pick PR into a release branch has been approved by the release branch manager. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm "Looks good to me", indicates that a PR is ready to be merged. release-note-none Denotes a PR that doesn't merit a release note. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

StatefulSet controller sets immutable fields of v1.PodSpec
7 participants