ohai icon indicating copy to clipboard operation
ohai copied to clipboard

Getting null domain for Solaris nodes upgraded from Ohai 6.18 to Ohai 7.x

Open scotthain opened this issue 12 years ago • 19 comments

Moving issue from Chef repo to Ohai repo: https://github.com/opscode/chef/issues/2139

Original:

We are seeing domain results of "null" when running Ohai 7.4.0. This is happening on the Solaris 10 nodes that we are attempting to upgrade from an older version of the Chef client. Here are some relevant snippets from running Ohai before and after the upgrade:

BEFORE: (using Ohai 6.18.0)

"hostname": "abc", "fqdn": "abc.def.gh", "domain": "def.gh", "network": { "interfaces": { "lo0": {

AFTER: (Upgraded to the 11.16 client with Ohai 7.4.0) Notice that the “domain” value is null.

"machinename": "abc", "hostname": "abc", "fqdn": "abc", "domain": null, "keys": { "ssh": {

Here is the error we see when we run "ohai domain" on a Solaris node with Ohai 7.4.0:

-bash-3.2$ ohai domain /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/ohai-7.4.0/lib/ohai/system.rb:191:in attributes_print': I cannot find an attribute named domain! (ArgumentError) from /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/ohai-7.4.0/lib/ohai/application.rb:94:inblock in run_application' from /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/ohai-7.4.0/lib/ohai/application.rb:93:in each' from /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/ohai-7.4.0/lib/ohai/application.rb:93:inrun_application' from /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/ohai-7.4.0/lib/ohai/application.rb:70:in run' from /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/ohai-7.4.0/bin/ohai:42:in' from /usr/bin/ohai:23:in load' from /usr/bin/ohai:23:in

This behavior produces an incomplete FQDN value consisting of just the host name and no domain. The behavior may have changed due to a recent mod to the hostname plugin for Ohai?

opscode/ohai@7e129dc

Hoping this can be corrected soon so that we can upgrade the Client and Ohai across our enterprise. Thanks!

scotthain avatar Sep 30 '14 20:09 scotthain

@Doug-MacDowell

scotthain avatar Sep 30 '14 20:09 scotthain

7e129dc shouldn't be in Ohai 7.4.0.

juliandunn avatar Oct 01 '14 05:10 juliandunn

@juliandunn this is actually a different issue in the Hostname plugin, I verified the issue. The fix you linked and this issue both are required for it to work correctly.

scotthain avatar Oct 01 '14 16:10 scotthain

So here's my notes from the commit that probably broke this:

commit 0d586377d7ec535ff87f657cc70e7023ebd75781
Author: Lamont Granquist <[email protected]>
Date:   Thu Jan 9 13:40:38 2014 -0800

    remove shitty solaris logic

    - it assumes hostname is short and it may not be (e.g. smartos)
    - it uses the NIS domainname as the DNS domainname which is both
      unlikely to be used these days and not guaranteed to match anyway
    - its unlikely this worked correctly for just about anyone
    - in the event that the domainanme was blank you got a trailing dot
      which screwed everything up.

In Ohai 8 we standardized that the fqdn would be derived from DNS lookups (like hostname -f on linux) across all platforms and that the domain would be resolved as the trailing part of the fqdn. This cleaned up a considerable amount of mess across what those attributes meant across all the platforms, this also fixed bugs that were caused by the mangling that the old hostname code did on Solaris.

So, the first thing that we should try is to fix the broken DNS domain resolution. This is probably caused by /etc/hosts overriding DNS and having the short hostname first for the IP address of the host. If this can be dropped and/or reversed so that the FQDN comes first and DNS lookups aren't broken then that's the best solution.

After that an unacceptable solution would be to treat this as a regression and 'fix' it back to the old behavior. It was broken on purpose and it is correctly reflecting their environment based on the way they have their servers configured. So a "just make domain work" approach is flawed. It works correctly now.

An acceptable solution would be to introduce another attribute which pulled in the NIS domainname and exposed that as a different attribute.

lamont-granquist avatar Feb 04 '15 18:02 lamont-granquist

@lamont-granquist In the Solaris environment which is the context of this issue (a host having an NIS domainname set), this results in the fqdn (which the chef-client depends on Ohai to properly provide) being incorrect, and a chef-client which uses Ohai 7 no longer converges due to this issue. In my opinion, characterizing this as 'correctly reflecting the environment based on the way they have their servers configured) is thus overstated.

When 'domainname' doesn't return "(none)", there's more legwork to do in this case.

Knowing the fully qualified name isn't a requirement unique to Chef: sendmail needs it for example. On Solaris 10, the 'check-hostname' script returns a string containing the proper fqhn which for your purposes is the fqdn, emulating what sendmail does to ascertain this.

I don't wish you to reintroduce a solution via regression either: Having the domainname as ohai data would be helpful, yet it wouldn't address the fqdn misset issue here, and that's the show-stopper which resulted in this issue's existence.

SolverDude avatar Feb 09 '15 17:02 SolverDude

Yes, but we've defined node[:fqdn] as hostname -f behavior for consistency across platforms. Constructing node[:fqdn] from the NIS domainname isn't the same thing, and the mess we had before where different operating systems had entirely different definitions of node[:hostname], node[:fqdn] and node[:domain] and did whatever they felt like to create those attributes was a huge mess.

lamont-granquist avatar Feb 10 '15 20:02 lamont-granquist

I'm wondering if adding a secondary check would be acceptable for everyone. Seems like we already do this for linux as seen here

Since Solaris doesn't have a 'hostname -f' command, what if we added a check here that falls back to running /usr/sbin/check-hostname, much like described in this s-e link

Am I missing the point here @lamont-granquist?

scotthain avatar Feb 20 '15 23:02 scotthain

I think that's just kind of a retry loop isn't it? I think what I'd like to see is an RFC standard for this.

And the problem to me seems to be that people rely on fqdn, but the algorithm is buggy (hence the retry loop which is probably due to a DNS burp). When I tried to standardize on behavior in ohai 7 dan was concerned that existing cookbooks (djbdns I think) may have a hard requirement for doing the DNS lookup dance, even though its unreliable. So it feels like we need to break someone one way or the other.

I would have liked to see the behavior that if the hostname has dots in it that we just return hostname assuming that its the FQDN (which should not transiently fail). If the hostname does not have dots we could then fallback to NIS domain (which also should not transiently fail). Then hostname -f could be the final fallback (which may transiently fail, but its the third strike, so you're out). I don't like the hostname -f check in general since it depends on an external network-based source of truth that may fail. We could then move hostname -f behavior to some other node attribute and cookbooks that really needed that exact behavior could get it from a consistent node attribute.

Thats probably the right course of action, but its a breaking change/RFC process kind of thing.

lamont-granquist avatar Feb 21 '15 04:02 lamont-granquist

We need to make sure that we keep this algorithm in mind in the process:

https://github.com/chef/chef/blob/master/lib/chef/client.rb#L280

lamont-granquist avatar Feb 21 '15 04:02 lamont-granquist

After talking to @lamont-granquist a bit about the best way to resolve this, I think this is what I'd propose we do -

  1. Revert this change to fix the (sorta?) regression in the short term, knowing that it is not the 'correct' way.
  2. Put in an RFC to make a breaking change that would in this order - derive from hostname, if not - use nis, if not - use dns. This should allow @SolverDude and company time to discuss and make any accommodations needed to take this change.

scotthain avatar Feb 23 '15 21:02 scotthain

From what I can tell, the change @scotthain recommended sounds like it meets everyones needs. I'm :+1: on it.

andrewelizondo avatar Mar 10 '15 22:03 andrewelizondo

:+1: as well.

charlesjohnson avatar Mar 17 '15 23:03 charlesjohnson

I've talked to people and there doesn't appear to be consensus around reverting this fqdn behavior, although it looked like there was. I'm going to step back and look at the best way to override this behavior for those who are blocked by it and personally work toward a plan within the next couple of weeks.

btm avatar Mar 23 '15 21:03 btm

Wrote up an RFC:

https://github.com/chef/chef-rfc/pull/108

lamont-granquist avatar Mar 23 '15 23:03 lamont-granquist

@adamedx for now I think we write a different hostname.rb plugin, similar to my #508, and then create a custom bootstrap template that overwrites that file after Chef install but before the first run.

btm avatar Mar 26 '15 17:03 btm

Can we just grab the old hostname plugin @btm? Then just do the custom bootstrap template. It could either overwrite the file, or just be a plugin that gets loaded last and overrides (i.e. monkeypatches) the "real" hostname plugin.

adamedx avatar Mar 26 '15 18:03 adamedx

https://github.com/chef/chef/pull/3689#issuecomment-151556066

SolverDude commented 22 hours ago

OK. Thanks for providing the clarification @btm. We can continue to patch the hostname.rb plugin for the moment (which otherwise breaks our use of Chef on Solaris).

https://github.com/chef/chef/pull/3689#issuecomment-151558070

adamedx commented 22 hours ago

@btm, can you suggest something we can do now so @SolverDude can move forward? It's good to see things move through the RFC process, but I feel there's enough there in Ohai / Chef Client where there should be a solution on top of those that could potentially be deployed via tricky methods like client.rb. If you don't have idea, let's get a f2f with @SolverDude can get something repeatable and reliable worked out.

The only thing we could do differently post-#3689 is to patch hostname.rb to take a configuration value. If @SolverDude is currently patching hostname.rb and that's working, that's the thing to continue doing. @lamont-granquist's RFC draft will provide the permanent patch here. Once this issue is solved with a RFC53 configuration option, then there will be a simple workaround by placing that option in client.rb. Simpler than patching ohai at least.

btm avatar Oct 28 '15 14:10 btm

@SolverDude here's a way to use the old hostname plugin if you aren't already. This downloads the old plugin as part of the bootstrap process and configures it.

https://gist.github.com/btm/48340a276e4214103a5e

btm avatar Nov 09 '15 22:11 btm

We've made some significant changes to falling back to proper domain discovery so I suspect this may no longer be an issue at this point. I chatted with @scotthain who no longer has access to the infrastructure where he saw this issue. I'm going to close this out at this point unless someone is still seeing the issue. Feel free to open it up again.

tas50 avatar Jan 24 '17 19:01 tas50