summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLamont Granquist <lamont@scriptkiddie.org>2021-10-20 15:29:23 -0700
committerTim Smith <tsmith84@gmail.com>2021-10-20 17:58:25 -0700
commit69d7ebac17965b58cfc9d51bf5237ed33a45895c (patch)
tree8c913a26e95ed73028f3b03235fc52cde757cde9
parentd71522cafb5bc1e1025d7c78f9ca8aa5f9a9ce0e (diff)
downloadohai-69d7ebac17965b58cfc9d51bf5237ed33a45895c.tar.gz
revert back to prior behavior
if DNS fails after 3 tries we should probably leave this unset so we do not silently fall back to the short hostname. Signed-off-by: Lamont Granquist <lamont@scriptkiddie.org>
-rw-r--r--lib/ohai/mixin/network_helper.rb2
-rw-r--r--spec/unit/plugins/hostname_spec.rb6
-rw-r--r--spec/unit/plugins/linux/hostname_spec.rb2
3 files changed, 4 insertions, 6 deletions
diff --git a/lib/ohai/mixin/network_helper.rb b/lib/ohai/mixin/network_helper.rb
index 134d274b..71ea0bdd 100644
--- a/lib/ohai/mixin/network_helper.rb
+++ b/lib/ohai/mixin/network_helper.rb
@@ -47,7 +47,7 @@ module Ohai
rescue
retries -= 1
retry if retries > 0
- hostname
+ nil
end
end
end
diff --git a/spec/unit/plugins/hostname_spec.rb b/spec/unit/plugins/hostname_spec.rb
index 0390ddac..bf37ef1a 100644
--- a/spec/unit/plugins/hostname_spec.rb
+++ b/spec/unit/plugins/hostname_spec.rb
@@ -72,7 +72,7 @@ describe Ohai::System, "hostname plugin" do
it "is called twice" do
@plugin.run
- expect(@plugin[:fqdn]).to eq("katie.local")
+ expect(@plugin[:fqdn]).to eq(nil)
end
end
@@ -82,9 +82,7 @@ describe Ohai::System, "hostname plugin" do
allow(@plugin).to receive(:shell_out).with("hostname -s").and_return(
mock_shell_out(0, "katie", "")
)
- allow(@plugin).to receive(:shell_out).with("hostname --fqdn").and_return(
- mock_shell_out(0, "katie.local", "")
- )
+ expect(@plugin).to receive(:canonicalize_hostname).with("katie.local").and_return("katie.local")
end
it "is not be called twice" do
diff --git a/spec/unit/plugins/linux/hostname_spec.rb b/spec/unit/plugins/linux/hostname_spec.rb
index 400a48d1..72ec6139 100644
--- a/spec/unit/plugins/linux/hostname_spec.rb
+++ b/spec/unit/plugins/linux/hostname_spec.rb
@@ -44,7 +44,7 @@ describe Ohai::System, "Linux hostname plugin" do
it "does not set fqdn" do
@plugin.run
- expect(@plugin.fqdn).to eq("katie.local")
+ expect(@plugin.fqdn).to eq(nil)
end
end