Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cookbook broken with Chef-15 #368

Closed
lamont-granquist opened this issue May 16, 2019 · 6 comments · Fixed by #371
Closed

Cookbook broken with Chef-15 #368

lamont-granquist opened this issue May 16, 2019 · 6 comments · Fixed by #371

Comments

@lamont-granquist
Copy link
Contributor

@lamont-granquist lamont-granquist commented May 16, 2019

See chef/chef#8557

This mechanism has changed in Chef-15

# Returns the node's uuid
def entity_uuid
if defined?(Chef) &&
defined?(Chef::DataCollector) &&
defined?(Chef::DataCollector::Messages) &&
defined?(Chef::DataCollector::Messages.node_uuid)
Chef::DataCollector::Messages.node_uuid
end
end

node[:chef_guid] is probably the best public API for that now.

@lamont-granquist

This comment has been minimized.

Copy link
Contributor Author

@lamont-granquist lamont-granquist commented May 16, 2019

So the code should look more or less like this:

   # Returns the node's uuid
   def entity_uuid
    # the Chef::DataCollector::Messages API here is Chef < 15.0 backcompat and can be removed when Chef 14.x is no longer supported
    node[:chef_guid] || defined?(Chef::DataCollector::Messages) && Chef::DataCollector::Messages.node_uuid,
   end

The problem is that node may or may not be in the context that these helpers get mixed into

It is also more than a bit weird that there appear to be spec tests for it 'is not sending report when entity_uuid is missing' do which are clearly not working correctly.

there's also lines in the audit reporter that look like this:

./files/default/handler/audit_report.rb:            entity_uuid: run_status.entity_uuid,
./files/default/handler/audit_report.rb:              entity_uuid: run_status.entity_uuid,

if that is the Chef::RunStatus object from core chef the it shouldn't have an entity_uuid method and didn't have on in Chef-14 so now I'm super confused.

@zenspider

This comment has been minimized.

Copy link
Collaborator

@zenspider zenspider commented May 17, 2019

SINGLE SPACE INDENT?!?!? 😛

Thank you for changing it to defined?(Chef::DataCollector::Messages).

@lamont-granquist

This comment has been minimized.

Copy link
Contributor Author

@lamont-granquist lamont-granquist commented May 17, 2019

heh starchy copypasta error...

and yes...

@alexpop

This comment has been minimized.

Copy link
Contributor

@alexpop alexpop commented May 31, 2019

@lamont-granquist thanks for assisting with this change.

I looked into it as well.
I don't see a problem with the is not sending report when entity_uuid is missing spec test. The send_report method is not sending the report if entity_uuid is missing, as I noticed in this output:

Running handlers:
[2019-05-31T09:01:53+00:00] WARN: Overwriting resource apache. To reference a specific version of apache use the resource() method
[2019-05-31T09:02:02+00:00] ERROR: entity_uuid() or run_id(dd3b05e8-b41f-43fa-a80b-c4d2c9385af7) can't be nil, not sending report to Chef Automate
  - Chef::Handler::AuditReport

run_status.entity_uuid in audit_report.rb is calling the entity_uuid helper method.
I opened PR #371 with the fix for this issue.

@lamont-granquist

This comment has been minimized.

Copy link
Contributor Author

@lamont-granquist lamont-granquist commented May 31, 2019

So what Type of object is run_status?

@alexpop

This comment has been minimized.

Copy link
Contributor

@alexpop alexpop commented May 31, 2019

[1] pry(#<Chef::Handler::AuditReport>)> run_status.class
=> Chef::RunStatus
[2] pry(#<Chef::Handler::AuditReport>)> run_status
=> #<Chef::RunStatus:0x0000000003c9e2c8
 @end_time=2019-05-31 18:19:25 +0000,
 @events=
  #<Chef::EventDispatch::Dispatcher:0x0000000003c9e368
   @event_list=[],
   @in_call=false,
...
@alexpop alexpop closed this in #371 May 31, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants
You can’t perform that action at this time.