summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordanielsdeleo <dan@chef.io>2016-10-28 13:49:46 -0700
committerdanielsdeleo <dan@chef.io>2016-11-02 08:06:38 -0700
commitc9739381fc9956b7e94b9687c14be6742afb3b93 (patch)
tree4e529d746af08ad4e09a3e280a98b5c56d620e96
parent274fffd1a7f6a2e3e4b9867ac7481a686c9c7fc4 (diff)
downloadchef-c9739381fc9956b7e94b9687c14be6742afb3b93.tar.gz
Update default data collector URL to correct value
Additionally, add info and debug logging for the auto-detection of whether to enable the data collector. Signed-off-by: Daniel DeLeo <dan@chef.io>
-rw-r--r--chef-config/lib/chef-config/config.rb2
-rw-r--r--chef-config/spec/unit/config_spec.rb2
-rw-r--r--lib/chef/data_collector.rb28
3 files changed, 24 insertions, 8 deletions
diff --git a/chef-config/lib/chef-config/config.rb b/chef-config/lib/chef-config/config.rb
index df14c81bc3..2c1fcf21c0 100644
--- a/chef-config/lib/chef-config/config.rb
+++ b/chef-config/lib/chef-config/config.rb
@@ -857,7 +857,7 @@ module ChefConfig
# Full URL to the endpoint that will receive our data. If nil, the
# data collector will not run.
# Ex: http://my-data-collector.mycompany.com/ingest
- default(:server_url) { File.join(config_parent.chef_server_url, "/data_collector") }
+ default(:server_url) { File.join(config_parent.chef_server_url, "/data-collector") }
# An optional pre-shared token to pass as an HTTP header (x-data-collector-token)
# that can be used to determine whether or not the poster of this
diff --git a/chef-config/spec/unit/config_spec.rb b/chef-config/spec/unit/config_spec.rb
index e15a5a6023..e6070adb5a 100644
--- a/chef-config/spec/unit/config_spec.rb
+++ b/chef-config/spec/unit/config_spec.rb
@@ -1133,7 +1133,7 @@ RSpec.describe ChefConfig::Config do
it "configures the data collector URL as a relative path to the Chef Server URL" do
ChefConfig::Config[:chef_server_url] = "https://chef.example/organizations/myorg"
- expect(ChefConfig::Config[:data_collector][:server_url]).to eq("https://chef.example/organizations/myorg/data_collector")
+ expect(ChefConfig::Config[:data_collector][:server_url]).to eq("https://chef.example/organizations/myorg/data-collector")
end
diff --git a/lib/chef/data_collector.rb b/lib/chef/data_collector.rb
index e377e4ae12..4365497bab 100644
--- a/lib/chef/data_collector.rb
+++ b/lib/chef/data_collector.rb
@@ -41,13 +41,29 @@ class Chef
# * disabled if `Chef::Config[:data_collector][:server_url]` is set to a
# falsey value
def self.register_reporter?
- return false if why_run?
- return false unless reporter_enabled_for_current_mode?
- if solo?
- data_collector_url_configured? && token_auth_configured?
- else
- data_collector_url_configured?
+ if why_run?
+ Chef::Log.debug("data collector is disabled for why run mode")
+ return false
+ end
+ unless reporter_enabled_for_current_mode?
+ Chef::Log.debug("data collector is configured to only run in " \
+ "#{Chef::Config[:data_collector][:mode].inspect} modes, disabling it")
+ return false
+ end
+ unless data_collector_url_configured?
+ Chef::Log.debug("data collector URL is not configured, disabling data collector")
+ return false
+ end
+ if solo? && !token_auth_configured?
+ Chef::Log.debug("Data collector token must be configured in solo mode, disabling data collector")
+ return false
+ end
+ if !solo? && token_auth_configured?
+ Chef::Log.warn("Data collector token authentication is not recommended for client-server mode" \
+ "Please upgrade Chef Server to 12.9.2+ and remove the token from your config file " \
+ "to use key based authentication instead")
end
+ true
end
def self.data_collector_url_configured?