Open clintoncwolfe opened 6 years ago
@djdees , could you tell us a bit more:
/var/chef/cache/data_collector_metadata.json
?Thanks!
C. -
On Mon, Apr 30, 2018 at 11:49 AM, Clinton Wolfe notifications@github.com wrote:
@djdees https://github.com/djdees , could you tell us a bit more:
- Are you using Chef to manage the machine? If so, anything unusual about the path /var/chef/cache/data_collector_metadata.json?
- Are you using SElinux, or any other secondary RBAC system which might result in being able to detect but not read the above path?
- Are you connecting to the machine with sudo enabled?
Thanks!
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/chef/train/issues/292#issuecomment-385458381, or mute the thread https://github.com/notifications/unsubscribe-auth/AIWF7WJySpl2j-d1SYWX-NXSe9_dtu9lks5tt0CogaJpZM4Ts4FT .
djdees@gmail.com
There is no frigate like a book to take us lands away. Nor any Coursers like a page of prancing poetry. This traverse may the poorest take without oppress of toll. How frugal is the chariot that bears the Human Soul? - Emily Dickinson
I am seeing this as well consistently now on centos-69 and latest chefdk 3.0.36. I am using test-kitchen ec2 driver on a hardened centos image. I have verified uuidgen
is installed on centos, but I am unsure why it's failing as there's no debugging info other than:
[2018-06-28T20:46:44-07:00] DEBUG: Loading controls/main.rb into #<Inspec::ProfileContext:0x00007fab1877e370>
[2018-06-28T20:46:44-07:00] DEBUG: Loading <anonymous content> into #<Inspec::ProfileContext:0x00007fab17b1b678>
[2018-06-28T20:46:54-07:00] ERROR: Cannot find a UUID for your node.
I was thinking of adding a debugging print statement in train, but not sure how that would work with my local chefdk install and gems.
What would my nodes be missing to not be able to generate a uuid?
@rojomisin The implementation of that features is located here: https://github.com/inspec/train/blob/16f70fc286455a99a8138349ed5a24839d1f2bf0/lib/train/platforms/detect/helpers/os_common.rb#L91-L121
Essentially we try to read the following files:
/etc/chef/chef_guid
#{ENV['HOME']}/.chef/chef_guid
/etc/machine-id
/var/lib/dbus/machine-id
/var/db/dbus/machine-id
@rojomisin could you help us understand if your system has none of those files? @jquick Can we document how we document how to override the uuid?
This in addition to the issue that the machine-id is not always unique (cloned vms), we may add an easy mechanism to override that?
This is a odd one. This error should not be hurting your setup unless your trying to use the A2 report with a non-chef node. We try to attach a UUID here:
https://github.com/inspec/inspec/blob/master/lib/inspec/formatters/base.rb#L192
but if we cannot find one we set to nil
and continue. The only time its mandatory is when we are reporting up to A2. You can override it for that case using the documentation here: https://www.inspec.io/docs/reference/reporters/
The error message [2018-06-28T20:46:54-07:00] ERROR: Cannot find a UUID for your node.
should not be stopping your run at all. @rojomisin can you share your kitchen stack trace? I am assuming the failure is from something else.
@djdees @clintoncwolfe What I assume is happening is we have a empty "/var/chef/cache/data_collector_metadata.json" file from the chef startup. We should add a check in train to make sure the file has data before we try to parse it.
hi @chris-rock @jquick thanks for info.
I'm using test-kitchen + chef-zero so those files are not there. That being said if I do a straight chef exec inspec exec ../profile/ -t ssh://user@<kitchen ip> --sudo --attrs ../attrs.yml
it works. But in test kitchen it is reporting the error.
Could it be that the test-kitchen method of generating the uuid on my workstation (os x el cap 10.11.6 ... kinda old)?
https://github.com/inspec/train/blob/de3ec8047f9a5eb159394f51aa8f31283bbe8682/lib/train/platforms/detect/specifications/os.rb#L439-L496
I've been querying this issue in the test-kitchen slack channel a bit too, because it doesn't seem to be inspec.
will post debug output in a bit
the test-kitchen -D
does not show any info really
-----> Verifying <default-centos-69>...
Detected alternative framework tests for `inspec`
Loaded tests from {:path=>"*"}
Loaded config_oss
[2018-06-29T11:06:46-07:00] ERROR: Cannot find a UUID for your node.
Profile: tests from {:path=>"*"} (tests from {:path=>"*"})
Version: (not specified)
Target: ssh://ec2-user@10.197.41.46:22
No tests executed.
Profile: InSpec Profile (config_oss)
Version: 0.1.9
Target: ssh://ec2-user@10.197.41.46:22
No tests executed.
Profile: InSpec Java in system (java)
Version: 0.0.1
Target: ssh://ec2-user@10.197.41.46:22
No tests executed.
Test Summary: 0 successful, 0 failures, 0 skipped
Finished verifying <default-centos-69> (0m24.16s).
-----> Kitchen is finished. (8m5.29s)
Description
Reported on https://github.com/chef/inspec/issues/2985 by @djdees
When trying to read a Chef-generated UUID, the file content detection logic fails and passes a
nil
to the JSON parser, throwing an exception.Looks like it's this line: (https://github.com/chef/train/blame/master/lib/train/platforms/detect/helpers/os_common.rb#L102)
Offhand that seems fine; perhaps there are SELinux constraints preventing us from reading the file?
Train and Platform Version
1.4.1 targeting RHEL 7.3
Introduced on #270
Unknown SELinux status
Replication Case
See https://github.com/chef/inspec/issues/2985
Possible Solutions
Could check
nil?
on the file contentCheck to verify that the file is really a file (not a dir)
Stacktrace