Cloud-init can't generate fqdn when use host settings.

bingsin

Member
Dec 9, 2021
29
2
8
29
I created a cloud-init vm . Set the dns and domain options to empty. I think it will use host settings.

1673271877570.png


I have set the host domain.


1673271898476.png

When I checked user-data, I didn't find fqdn

1673271929004.png


If there is no FQDN, this will cause the rhel linux unable to use cloud-init to set the hostname.

https://forum.proxmox.com/threads/h...udinit-with-cicustom-and-ubuntu-22-04.110446/
https://forum.proxmox.com/threads/c...as-expected-rhel8-rocky-linux-centos-8.95172/



Code:
proxmox-ve: 7.3-1 (running kernel: 5.15.83-1-pve)
pve-manager: 7.3-4 (running version: 7.3-4/d69b70d4)
pve-kernel-5.15: 7.3-1
pve-kernel-helper: 7.3-1
pve-kernel-5.15.83-1-pve: 5.15.83-1
pve-kernel-5.15.74-1-pve: 5.15.74-1
pve-kernel-5.15.30-2-pve: 5.15.30-3
ceph-fuse: 15.2.16-pve1
corosync: 3.1.7-pve1
criu: 3.15-1+pve-1
glusterfs-client: 9.2-1
ifupdown2: 3.1.0-1+pmx3
ksm-control-daemon: 1.4-1
libjs-extjs: 7.0.0-1
libknet1: 1.24-pve2
libproxmox-acme-perl: 1.4.3
libproxmox-backup-qemu0: 1.3.1-1
libpve-access-control: 7.3-1
libpve-apiclient-perl: 3.2-1
libpve-common-perl: 7.3-1
libpve-guest-common-perl: 4.2-3
libpve-http-server-perl: 4.1-5
libpve-storage-perl: 7.3-1
libspice-server1: 0.14.3-2.1
lvm2: 2.03.11-2.1
lxc-pve: 5.0.0-3
lxcfs: 4.0.12-pve1
novnc-pve: 1.3.0-3
proxmox-backup-client: 2.3.1-1
proxmox-backup-file-restore: 2.3.1-1
proxmox-mini-journalreader: 1.3-1
proxmox-offline-mirror-helper: 0.5.0-1
proxmox-widget-toolkit: 3.5.3
pve-cluster: 7.3-1
pve-container: 4.4-2
pve-docs: 7.3-1
pve-edk2-firmware: 3.20220526-1
pve-firewall: 4.2-7
pve-firmware: 3.6-2
pve-ha-manager: 3.5.1
pve-i18n: 2.8-1
pve-qemu-kvm: 7.1.0-4
pve-xtermjs: 4.16.0-1
qemu-server: 7.3-2
smartmontools: 7.2-pve3
spiceterm: 3.2-2
swtpm: 0.8.0~bpo11+2
vncterm: 1.7-1
zfsutils-linux: 2.1.7-pve1
 
what does "qm cloudinit dump 117 network" show?


Blockbridge : Ultra low latency all-NVME shared storage for Proxmox - https://www.blockbridge.com/proxmox
Thanks for reply.
Code:
root@pve1:~# qm cloudinit dump 117 network
version: 1
config:
    - type: nameserver
      address:
      - '223.5.5.5'
      search:
      - 'bingsin.com'

I manually set dns and domian on the web. "dns=bingsin1.com,dns=223.5.5.5 "
it seems ok.

Code:
root@pve1:~# qm cloudinit dump 117 user
#cloud-config
hostname: pxeserver
manage_etc_hosts: true
fqdn: pxeserver.bingsin1.com
user: root
disable_root: False
password: bingsin
chpasswd:
  expire: False
package_upgrade: true

Code:
root@pve1:~# qm config 117
bios: ovmf
boot: order=scsi0;ide0
cipassword: **********
ciuser: root
cores: 2
ide0: nfs:iso/proxmox-ve_7.3-1.iso,media=cdrom,size=1082874K
ide2: ssd3:117/vm-117-cloudinit.qcow2,media=cdrom
machine: q35
memory: 4096
meta: creation-qemu=7.1.0,ctime=1670725427
name: pxeserver
nameserver: 223.6.6.6
net0: virtio=AC:BD:EF:FF:6A:1F,bridge=vmbr0,firewall=1
ostype: l26
scsi0: ssd3:117/vm-117-disk-1.qcow2,size=70G
scsi1: ssd3:117/vm-117-disk-0.raw,size=62G
scsi2: ssd3:117/vm-117-disk-2.qcow2,size=80G
scsihw: virtio-scsi-pci
searchdomain: bingsin1.com
serial0: socket
smbios1: uuid=ce2ac38f-f80a-4dfa-87d4-e98110cf6293
vmgenid: b4e57dde-f978-49c2-b615-084e694c0de3

The problem now is that PVE doesn't seem to configure the fqdn if the option is empty
 
The problem now is that PVE doesn't seem to configure the fqdn if the option is empty
If you can articulate why this is a problem and what the behavior should be, then you should do it in a bug here https://bugzilla.proxmox.com/.
If PVE devs agree, they might change things. As it stands now, the behavior you are seeing is exactly what the code is supposed to do:

hostname is set here:
https://github.com/proxmox/qemu-server/blob/master/PVE/QemuServer/Cloudinit.pm#L117

its done with the help of this function:
https://github.com/proxmox/qemu-server/blob/master/PVE/QemuServer/Cloudinit.pm#L81

Only if searchdomain config variable is set, then the fqdn will be set to vmid.domain:
https://github.com/proxmox/qemu-server/blob/master/PVE/QemuServer/Cloudinit.pm#L88

If you leave it as "use host settings", then arguably its not set. However you have a solution that works with appropriate settings, so I am not sure things should be changed, as they can break functionality for someone who counts on config to be the way it is now.


Blockbridge : Ultra low latency all-NVME shared storage for Proxmox - https://www.blockbridge.com/proxmox
 
If you can articulate why this is a problem and what the behavior should be, then you should do it in a bug here https://bugzilla.proxmox.com/.
If PVE devs agree, they might change things. As it stands now, the behavior you are seeing is exactly what the code is supposed to do:

hostname is set here:
https://github.com/proxmox/qemu-server/blob/master/PVE/QemuServer/Cloudinit.pm#L117

its done with the help of this function:
https://github.com/proxmox/qemu-server/blob/master/PVE/QemuServer/Cloudinit.pm#L81

Only if searchdomain config variable is set, then the fqdn will be set to vmid.domain:
https://github.com/proxmox/qemu-server/blob/master/PVE/QemuServer/Cloudinit.pm#L88

If you leave it as "use host settings", then arguably its not set. However you have a solution that works with appropriate settings, so I am not sure things should be changed, as they can break functionality for someone who counts on config to be the way it is now.


Blockbridge : Ultra low latency all-NVME shared storage for Proxmox - https://www.blockbridge.com/proxmox
Thank you for your patience.
 
If you leave it as "use host settings", then arguably its not set. However you have a solution that works with appropriate settings, so I am not sure things should be changed, as they can break functionality for someone who counts on config to be the way it is now.


Blockbridge : Ultra low latency all-NVME shared storage for Proxmox - https://www.blockbridge.com/proxmox
Hrm, interesting... this makes very little sense to me.

If you choose "use host settings", it should use them if set on the host, as set under System -> DNS -> Search domain

Code aside, that's how I read how those options should work... "use the host settings, if they are set".
 
What @lingfish said! This is how I read the docs as well:
Code:
searchdomain   string  <string>   cloud-init: Sets DNS search domains for a container. Create will automatically use the setting from the host if neither searchdomain nor nameserver are set.

If one would want to keep the current functionality/code as it is, it should not read "use host settings" but something like "unset" as a default value.

Then one could add/implement an extra functionality to actually use the "host settings" or set the actual domain. So the "DNS domain" should allow for 3 values:
- unset; leave it empty (=current default),
- use host settings; get it from node->dns->search_domain,
- domain.tld; set it to specified value.
 
Last edited:

About

The Proxmox community has been around for many years and offers help and support for Proxmox VE, Proxmox Backup Server, and Proxmox Mail Gateway.
We think our community is one of the best thanks to people like you!

Get your subscription!

The Proxmox team works very hard to make sure you are running the best software and getting stable updates and security enhancements, as well as quick enterprise support. Tens of thousands of happy customers have a Proxmox subscription. Get yours easily in our online shop.

Buy now!