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

taste-tester logging crash: undefined local variable or method 'logger' for #<TasteTester::State> #156 #166

Open
rb2k opened this issue May 5, 2021 · 3 comments

Comments

@rb2k
Copy link

rb2k commented May 5, 2021

I had already reported this in #156 , but we were on an ancient taste-tester version.

Now we upgraded and it turns out: still an issue.

It seems to be failing to call 'logger' when the initialize method tanks:
https://github.com/facebook/taste-tester/blob/master/lib/taste_tester/state.rb#L38

DEBUG: ERR: /opt/chefdk/embedded/lib/ruby/gems/2.5.0/gems/taste_tester-0.0.19/lib/taste_tester/state.rb:38:in `rescue in initialize': undefined local variable or method `logger' for #<TasteTester::State:0x00007fac3644cfc0> (NameError)
DEBUG: ERR: Did you mean?  @@logger
DEBUG: ERR:     from /opt/chefdk/embedded/lib/ruby/gems/2.5.0/gems/taste_tester-0.0.19/lib/taste_tester/state.rb:35:in `initialize'
DEBUG: ERR:     from /opt/chefdk/embedded/lib/ruby/gems/2.5.0/gems/taste_tester-0.0.19/lib/taste_tester/server.rb:35:in `new'
DEBUG: ERR:     from /opt/chefdk/embedded/lib/ruby/gems/2.5.0/gems/taste_tester-0.0.19/lib/taste_tester/server.rb:35:in `initialize'
DEBUG: ERR:     from /opt/chefdk/embedded/lib/ruby/gems/2.5.0/gems/taste_tester-0.0.19/lib/taste_tester/commands.rb:85:in `new'
DEBUG: ERR:     from /opt/chefdk/embedded/lib/ruby/gems/2.5.0/gems/taste_tester-0.0.19/lib/taste_tester/commands.rb:85:in `test'
DEBUG: ERR:     from /opt/chefdk/embedded/lib/ruby/gems/2.5.0/gems/taste_tester-0.0.19/bin/taste-tester:450:in `<module:TasteTester>'
DEBUG: ERR:     from /opt/chefdk/embedded/lib/ruby/gems/2.5.0/gems/taste_tester-0.0.19/bin/taste-tester:32:in `<top (required)>'
DEBUG: ERR:     from /opt/chefdk/embedded/bin/taste-tester:23:in `load'
DEBUG: ERR:     from /opt/chefdk/embedded/bin/taste-tester:23:in `<main>'

I think the problem is that the ref_file it tries to create by default is:

ref_file "#{ENV['HOME']}/.chef/taste-tester-ref.json"

and since we run this on macs as part of a launch daemon, "HOME" is not set.
So it fails, tries to log, can't. I think it might have to do with the order of events from 'initialize a class" and "execute the inheritance / extend code".

I guess the right thing would be:

  1. Don't use logger in the initializer, it's not available
  2. Possibly check if HOME is even set. But I think that's more of a macOS + launch daemon problem rather than a taste tester problem.

As to why we never noticed: up until recently, our root volume was writable. so writing to /.chef/ was not an issue. As of Big Sur, the root volume is mounted read only.

/cc @ttmgraham since he ran into this

@jaymzh
Copy link
Collaborator

jaymzh commented May 5, 2021

So that's two separate things.

First, I'm not quite sure what it means to run TT as a service... is it like downloading stuff to test on some sort of schedule?

Either way if you're going to run it in an environment with no $HOME, then you need to not have $HOME in your config :) So that one is local-user-error.

As to the logging bug, it looks like the issue is TasteTester::State is doing extend TasteTester::Logging, but should be doing include TasteTester::Logging.

@rb2k
Copy link
Author

rb2k commented May 5, 2021

As far as "TT as a service" goes:

We just use that to bootstrap the system. it's not a cron style service. It's similar to saying @reboot in crontab
Injecting that kind of a launchd plist is a way to convince macOS to run something on the first boot of the system after installation. This is used to taste-tester systems in provisioning.

We'll add HOME= to our arguments to get that working. I guess the logging is still broken.

@jaymzh
Copy link
Collaborator

jaymzh commented May 5, 2021

ahh tt-in-provisioning, of course.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants