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

Specify DHCP domain for hostname #61890

Conversation

dims
Copy link
Member

@dims dims commented Mar 29, 2018

What this PR does / why we need it:

In 9a8c6db, we looked at the hostname
in the metadata service and used '.' as the delimiter to chop off the
dhcp_domain (specified in nova.conf). However administrators need to
better control the dhcp domain better as there may be a '.' in the host
name itself. So let's introduce a config option that we can use and
default it to what nova uses when dhcp_domain is not specified which is
"novalocal"

Which issue(s) this PR fixes (optional, in fixes #<issue number>(, fixes #<issue_number>, ...) format, will close the issue(s) when PR gets merged):
Fixes #

Special notes for your reviewer:

Release note:

new dhcp-domain parameter to be used for figuring out the hostname of a node

@k8s-ci-robot k8s-ci-robot added size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. do-not-merge/release-note-label-needed Indicates that a PR should not merge because it's missing one of the release note labels. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. labels Mar 29, 2018
@k8s-ci-robot k8s-ci-robot added approved Indicates a PR has been approved by an approver from all required OWNERS files. release-note Denotes a PR that will be considered when it comes time to generate release notes. and removed do-not-merge/release-note-label-needed Indicates that a PR should not merge because it's missing one of the release note labels. labels Mar 29, 2018
@dims
Copy link
Member Author

dims commented Mar 29, 2018

cc @voelzmo

@dims
Copy link
Member Author

dims commented Mar 29, 2018

/test pull-kubernetes-integration

@voelzmo
Copy link

voelzmo commented Mar 29, 2018

Hey @dims,

I'm not sure if this PR goes into the right direction. As proposed in #57765 (comment), #61774 (comment), and #61000 (comment) I think we should not use metadata.hostname, but rather metadata.UUID instead.

@dims
Copy link
Member Author

dims commented Mar 29, 2018

@voelzmo this PR fixes the problem you mentioned about "what happens if the hostname has a dot". are there other problems/issues that i am not aware of?

@voelzmo
Copy link

voelzmo commented Mar 29, 2018

@dims Here's a quick summary

Here is the issue with this approach:

  • This fix works, if and only if the VM name doesn't need sanitation. If we have a funny VM name such as in my original example:

E.g. some weird display name like lol/what?This is weird. Ümlauts rule! gets a reasonable hostname:

screen shot 2018-01-10 at 08 52 49

this *doesn't* work, as there's no way to compute the VM name from the sanitized hostname.

In conclusion, the current implementation is working under the exact same conditions as the original implementation which used VM name instead of hostname. It also doesn't work in the case when the VM name contains funny characters, as in my example.

Therefore, I'd suggest to go back to square one and take the UUID instead. This allows you for a much cleaner way to resolve a VM given a hostname (it just returns the same UUID string), and it allows people to assign arbitrary VM names they like, for one reason or another.
The drawback is: your nodenames contain UUIDs.

WDYT?

/cc @afritzler @BugRoger

@dims
Copy link
Member Author

dims commented Mar 29, 2018

@voelzmo so the outstanding problem is that if hostname from metadata has been sanitized, then there is no way to find the vm. right? Can we please create a fresh issue? of course the history above is invaluable as well. thanks for that!

@BugRoger
Copy link
Contributor

BugRoger commented Mar 29, 2018

I’m ok with this commit. In our use case we have the VM names under control. ;)

I prefer a name over a UUID as the node’s name is intended for humans. And there’s yet another guid in Kubernetes anyway. But I see the problems with the transformation not being bijective.

Nova allows to store and query information in tags. It would be an option to store the sanitized name in a tag.

Another option would be to just error the registration for malformed names.

In any case, this whole naming “interface” is in my opinion pretty messy und hard to follow. Maybe a refactoring would be the right (and gargantuan) way to go.

My vote would be to throw an error.

@dims
Copy link
Member Author

dims commented Mar 30, 2018

This commit ties up one loose end, so let's get it in. let's work on if uuid is a good idea on another issue/pr. @FengyunPan2 @NickrenREN does that sound good?

@dims dims force-pushed the better-specify-dhcp-domain-for-hostname branch from 824c3cb to da5ccf7 Compare March 30, 2018 01:30
In 9a8c6db, we looked at the hostname
in the metadata service and used '.' as the delimiter to chop off the
dhcp_domain (specified in nova.conf). However administrators need to
better control the dhcp domain better as there may be a '.' in the host
name itself. So let's introduce a config option that we can use and
default it to what nova uses when dhcp_domain is not specified which is
"novalocal"
@FengyunPan2
Copy link
Contributor

/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 30, 2018
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: dims, FengyunPan2

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

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@dims
Copy link
Member Author

dims commented Mar 30, 2018

since we dont have another issue yet. leaving my notes here - the code responsible for sanitizing host names in nova is:
https://github.com/openstack/nova/blame/master/nova/utils.py#L543-L580

looks like it has not been touched for a few years. which is a good thing for us :)

@dims
Copy link
Member Author

dims commented Mar 30, 2018

/test pull-kubernetes-e2e-kops-aws

@k8s-github-robot
Copy link

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

@k8s-github-robot
Copy link

Automatic merge from submit-queue (batch tested with PRs 61871, 61890, 61786). If you want to cherry-pick this change to another branch, please follow the instructions here.

k8s-github-robot pushed a commit that referenced this pull request Apr 10, 2018
…pstream-release-1.10

Automatic merge from submit-queue.

Automated cherry pick of #61890: Specify DHCP domain for hostname

Cherry pick of #61890 on release-1.10.

#61890: Specify DHCP domain for hostname

```release-note
Fixing bug in openstack cloud provider when picking up hostname from metadata service or config drive. If the hostname has a custom domain, we should remove the domain before we use the hostname as the node name in kubernetes.
```
rfranzke added a commit to gardener/gardener that referenced this pull request Apr 16, 2018
k8s-github-robot pushed a commit that referenced this pull request May 16, 2018
Automatic merge from submit-queue. If you want to cherry-pick this change to another branch, please follow the instructions <a href="https://github.com/kubernetes/community/blob/master/contributors/devel/cherry-picks.md">here</a>.

Restore pre-1.10 openstack instance naming behavior

As noted in #61890 (comment) and #62295 (comment), the 1.10 changes to the openstack cloud provider node name computation (in #58502, #61000, and #61890) broke existing deployments that provisioned instances with credentials matching their instance names. It also did not account for version skewed kubelets, which can run 1.8 and 1.9 versions against a 1.10 master, and still register based on instance name.

This PR reverts the incompatible changes to restore pre-1.10 behavior.

Further improvements to handle instances with names that cannot be used as node names are tracked in #62295

/assign @dims
/sig openstack
/kind bug

```release-note
Restores the pre-1.10 behavior of the openstack cloud provider which uses the instance name as the Kubernetes Node name. This requires instances be named with RFC-1123 compatible names.
```
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. 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 Denotes a PR that will be considered when it comes time to generate release notes. size/XS Denotes a PR that changes 0-9 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants