-
Notifications
You must be signed in to change notification settings - Fork 30
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
Flatcar on EC2 sets a incorrect os hostname #707
Comments
I also enable debug log of networkd https://superuser.com/a/1234599
I can verify, that transient hostname is still set by systemd-networkd, but since the Apr 06 10:46:37 i-08115ab723fbe0417.eu-central-1.compute.internal systemd-networkd[184971]: Setting transient hostname: 'i-08115ab723fbe0417' I guess rollback flatcar/bootengine#21 would resolve the issue. Otherwise, afterburn should correctly set the hostname from IMDS. |
Hi, running hostnamectl set-hostname ""
systemctl restart systemd-networkd Resolve the issue.
This is the current workaround, that I use for now. systemd:
units:
- name: "fix-hostname.service"
enabled: true
# https://superuser.com/a/1005804
contents: |
[Unit]
Description=Fix Hostname
Before=network-pre.target
Wants=network-pre.target
DefaultDependencies=no
Requires=local-fs.target
After=local-fs.target
[Service]
Type=oneshot
ExecStart=/usr/bin/rm /etc/hostname
RemainAfterExit=yes
[Install]
WantedBy=network.target |
Hi, Thanks for raising this issue - I think it should be solved with this commit: coreos/afterburn@860db5c which is about to be merged (see: flatcar-archive/coreos-overlay#1769). The hostname will be truncated to the first dot, so in your case: EDIT: In the meantime, you could maybe try to disable |
How I can disable services that runs inside initramfs? I would expect, that ignition configure only unit files in On a bootet system, there is such no service.
The ability to disable flatcar-metadata-hostname.service would be great. |
Hi @tormath1 i looked into coreos/afterburn@860db5c . As I understand, the hostname is truncated only if the FQDN have more than 64 bytes. This is not the case here. Even on us-east-1, since the FQDN does not include the region. in conclusion, flatcar-archive/coreos-overlay#1769 would not help here, EXCEPT https://github.com/coreos/afterburn/blob/main/dracut/30afterburn/afterburn-hostname.service is used for the flatcar-metadata-hostname service, which is not running on AWS by default. |
Sounds like we should either exclude ec2 again or throw away the existing shell logic and adapt the new afterburn unit to set the hostname? |
The hostname afterburn got from the EC2 metadata was a FQDN and too long. We actually don't need afterburn to set the hostname because it is also set up via DHCP. Also, the upstream afterburn-hostname.service already has conditions to run on the right platforms. We can use these instead of custom shell logic. Align flatcar-metadata-hostname.service with upstream afterburn and don't use it for EC2. Adapt the upstream unit to fit our needs with a different cmdline arg naming and skip the relabling workaround (for now). Fixes flatcar/Flatcar#707
The hostname afterburn got from the EC2 metadata was a FQDN and too long. We actually don't need afterburn to set the hostname because it is also set up via DHCP. Also, the upstream afterburn-hostname.service already has conditions to run on the right platforms. We can use these instead of custom shell logic. Align flatcar-metadata-hostname.service with upstream afterburn and don't use it for EC2. Adapt the upstream unit to fit our needs with a different cmdline arg naming and skip the relabling workaround (for now). Fixes flatcar/Flatcar#707
The hostname afterburn got from the EC2 metadata was a FQDN and too long. We actually don't need afterburn to set the hostname because it is also set up via DHCP. Also, the upstream afterburn-hostname.service already has conditions to run on the right platforms. We can use these instead of custom shell logic. Align flatcar-metadata-hostname.service with upstream afterburn and don't use it for EC2. Adapt the upstream unit to fit our needs with a different cmdline arg naming and skip the relabling workaround (for now). Fixes flatcar/Flatcar#707
PRs ready for review: flatcar/bootengine#43 flatcar-archive/coreos-overlay#1817 |
Description
By default, on flatcar (Alpha?), the hostname contains dots and systemd-networkd is not set hostname received through DHCP.
Readings the docs at https://www.freedesktop.org/software/systemd/man/hostnamectl.html, a system hostname should not contain any dots and should be a single dns label.
Also Debian follows this pattern.
On Flatcar, the
/etc/hostname
is populated by coreos-metadata. For AWS, the change is introduced in flatcar/bootengine#21, but also mention that systemd-hostname will set the hostname, which does not happen.I also dump a DHCP traffic which confirms that the hostname is delivered by DHCP.
tcpdump DHCP traffic
If systemd-networkd would set the hostname delivered by DHCP, than the hostname would be correctly set.
Impact
After a successful boot, the hostname of the machine contains dots, e.g. is a FQDN hostname.
Since kubelet use this
hostname
as default node name, kubelet will register nodes also as an FQDN.Starting with RBN hostname, AWS related tools in the kubernetes environment (e.g. AWS Cloud Provider) expect the short hostname as node name. See: kubernetes/cloud-provider-aws#335
As workaround, I have to set
--hostname-override
on all kubernetes components, but this should not be the case on a Container optimized linux system.Environment and steps to reproduce
a. cat /etc/hostname
b. run
hostname
Expected behavior
Taken from an Ubuntu instance:
Additional information
I'm running flatcar Alpha
The upstream coreos afterburn will not set the hostname service, if the platform is AWS. See: https://github.com/coreos/afterburn/blob/main/dracut/30afterburn/afterburn-hostname.service#L4
No clue, if systemd will set a transient hostname, if a static hostname is already defined.
The text was updated successfully, but these errors were encountered: