facebook / taste-tester

Software to manage a chef-zero instance and use it to test changes on production servers.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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

rb2k opened this issue · comments

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

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.

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.

ahh tt-in-provisioning, of course.