Skip to content

Undefined method 'logger' after update to elasticsearch gem v7.14.0 #998

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

Closed
edariedl opened this issue Aug 5, 2021 · 1 comment · Fixed by #999
Closed

Undefined method 'logger' after update to elasticsearch gem v7.14.0 #998

edariedl opened this issue Aug 5, 2021 · 1 comment · Fixed by #999

Comments

@edariedl
Copy link

edariedl commented Aug 5, 2021

Hi, after upgrading to elasticsearch gem 7.14.0, I started to get errors when creating and deleting indexes in test setups. I suppose it is caused by changes in elasticsearch-transport https://github.com/elastic/elasticsearch-ruby/releases/tag/v7.14.0

Here is the stack trace:

Error:
MyTest#test_should_send_email:
NoMethodError: undefined method `logger' for #<Elasticsearch::Transport::Client:0x000055ba65120a50>
    /home/circleci/project/vendor/bundle/ruby/2.6.0/gems/elasticsearch-model-7.1.1/lib/elasticsearch/model/indexing.rb:293:in `rescue in delete_index!'
    /home/circleci/project/vendor/bundle/ruby/2.6.0/gems/elasticsearch-model-7.1.1/lib/elasticsearch/model/indexing.rb:289:in `delete_index!'
    /home/circleci/project/vendor/bundle/ruby/2.6.0/gems/elasticsearch-model-7.1.1/lib/elasticsearch/model/indexing.rb:248:in `create_index!'
    /home/circleci/project/test/test_helper.rb:49:in `block (2 levels) in <class:TestCase>'
    /home/circleci/project/test/test_helper.rb:47:in `each'
    /home/circleci/project/test/test_helper.rb:47:in `block in <class:TestCase>'
    /home/circleci/project/vendor/bundle/ruby/2.6.0/gems/activesupport-6.1.4/lib/active_support/test_case.rb:111:in `block in parallelize_setup'
    /home/circleci/project/vendor/bundle/ruby/2.6.0/gems/activesupport-6.1.4/lib/active_support/testing/parallelization/worker.rb:79:in `block in after_fork'
    /home/circleci/project/vendor/bundle/ruby/2.6.0/gems/activesupport-6.1.4/lib/active_support/testing/parallelization/worker.rb:78:in `each'
    /home/circleci/project/vendor/bundle/ruby/2.6.0/gems/activesupport-6.1.4/lib/active_support/testing/parallelization/worker.rb:78:in `after_fork'
    /home/circleci/project/vendor/bundle/ruby/2.6.0/gems/activesupport-6.1.4/lib/active_support/testing/parallelization/worker.rb:24:in `block in start'
    /home/circleci/project/vendor/bundle/ruby/2.6.0/gems/activesupport-6.1.4/lib/active_support/fork_tracker.rb:10:in `block in fork'
    /home/circleci/project/vendor/bundle/ruby/2.6.0/gems/activesupport-6.1.4/lib/active_support/fork_tracker.rb:8:in `fork'
    /home/circleci/project/vendor/bundle/ruby/2.6.0/gems/activesupport-6.1.4/lib/active_support/fork_tracker.rb:8:in `fork'
    /home/circleci/project/vendor/bundle/ruby/2.6.0/gems/activesupport-6.1.4/lib/active_support/fork_tracker.rb:27:in `fork'
    /home/circleci/project/vendor/bundle/ruby/2.6.0/gems/activesupport-6.1.4/lib/active_support/testing/parallelization/worker.rb:15:in `start'
    /home/circleci/project/vendor/bundle/ruby/2.6.0/gems/activesupport-6.1.4/lib/active_support/testing/parallelization.rb:37:in `block in start'
    /home/circleci/project/vendor/bundle/ruby/2.6.0/gems/activesupport-6.1.4/lib/active_support/testing/parallelization.rb:36:in `times'
    /home/circleci/project/vendor/bundle/ruby/2.6.0/gems/activesupport-6.1.4/lib/active_support/testing/parallelization.rb:36:in `each'
    /home/circleci/project/vendor/bundle/ruby/2.6.0/gems/activesupport-6.1.4/lib/active_support/testing/parallelization.rb:36:in `map'
    /home/circleci/project/vendor/bundle/ruby/2.6.0/gems/activesupport-6.1.4/lib/active_support/testing/parallelization.rb:36:in `start'
@alimac
Copy link

alimac commented Aug 5, 2021

I ran into the same issue. As best as I can tell, the issue is in:

def delete_index!(options={})
target_index = options.delete(:index) || self.index_name
begin
self.client.indices.delete index: target_index
rescue Exception => e
if e.class.to_s =~ /NotFound/ && options[:force]
client.transport.logger.debug("[!!!] Index does not exist (#{e.class})") if client.transport.logger
nil
else
raise e
end
end
end

and

def refresh_index!(options={})
target_index = options.delete(:index) || self.index_name
begin
self.client.indices.refresh index: target_index
rescue Exception => e
if e.class.to_s =~ /NotFound/ && options[:force]
client.transport.logger.debug("[!!!] Index does not exist (#{e.class})") if client.transport.logger
nil
else
raise e
end
end
end
end

Specifically, client.transport.logger should now be client.transport.transport.logger.

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

Successfully merging a pull request may close this issue.

2 participants