TritonDataCenter / smartos-live

For more information, please see http://smartos.org/ For any questions that aren't answered there, please join the SmartOS discussion list: https://smartos.topicbox.com/groups/smartos-discuss
1.57k stars 246 forks source link

Bad /etc/hosts entry when zone's IP is set to "dhcp" #121

Open kreutter opened 12 years ago

kreutter commented 12 years ago

The zone's primary nic is set up to request an iP address using DHCP, when the zone is running it can't resolve its hostname and /etc/hosts looks funny:

::1        localhost
127.0.0.1  localhost loghost
        2a28be29-755d-43e8-b0c0-87e35621a5e1.local
        ...
        2a28be29-755d-43e8-b0c0-87e35621a5e1.local

After every zone start there is an additional line with 2a28be29-755d-43e8-b0c0-87e35621a5e1.local without an IP address. This of course causes other services like apache to fail an remain in maintenance mode. Any ideas besides not using DHCP? (Running SmartOS joyent_20120906T221231Z)

MerlinDMC commented 12 years ago

The duplication in /etc/hosts on reboot does not happen with the latest base dataset 55330ab4-066f-11e2-bd0f-434f2462fada - sdc:sdc:base:1.8.1 but the /etc/hosts entry is missing the ip as well.

Maybe there can be a 5-10 seconds delay in /opt/local/lib/zoneinit/includes/03-ips.sh if one of the interfaces is set to dhcp - or just omit the /etc/hosts entry in that case.

If I start the scripts after the dhcp client got the ip everything seems to run fine.

To determine if the interface is set to dhcp data-get works at least on SmartOS hosts mdata-get sdc:nics.0.ip

@kreutter as a workaround i would suggest to recreate the zone with a newer base dataset and after initial setup just edit /etc/hosts manually

skull-squadron commented 12 years ago

Manual edits are for people that don't understand the need for idempotent changes.

The offending script should follow a standard grep sed echo pattern to prevent this.

joshwilsdon commented 11 years ago

I think this should have been fixed in a newer dataset, can you please try base-1.8.4 and see if this still happens?

kreutter commented 11 years ago

@joshwilsdon /etc/hosts doesn't get messed up with base-1.8.4 but there is no entry for the hostname (dhcp configured IP). I would at least expect . to show up there. A reverse DNS lookup would also be fine.

I noticed that the above mentioned 03-ips.sh script is missing in /opt/local/lib/zoneinit/includes.

kreutter commented 11 years ago

@joshwilsdon it also seems that with base-1.8.4 the resolvers entry in the vmadm configuration is not used to set up /etc/resolv.conf. I get the default: nameserver 8.8.8.8 nameserver 8.8.4.4 I would also expect to have a domain entry there.

Maybe it is because mdata-get sdc:resolvers returns an error: Error getting metadata for key sdc:resolvers: FAILURE. sdc:uuid and sdc:dns_domain return the correct values.

Guess I should open a new issue for this one?

mamash commented 11 years ago

03-ips.sh is deprecated (all configuration logic now takes place in 02-config.sh). It makes no sense for provisioner to put the DHCP provided IP into /etc/hosts, because the IP could change on a subsequent reboot. However, we can consider adding a functionality to update /etc/hosts appropriately (based on ipconfig parsed).

Retrieving sdc:resolvers never worked because of a platform bug that Josh fixed last week. I'll need to confirm this with a recent platform first.