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

An unexpected error occurred! {:error=>#<ArgumentError: wrong number of arguments (given 3, expected 1..2)> #13777

Closed
skywalkerisnull opened this issue Feb 16, 2022 · 36 comments · Fixed by #14446

Comments

@skywalkerisnull
Copy link

  1. Logstash version: 8.0.0
  2. Logstash installation source: Docker
  3. How is Logstash being run: Docker Compose

Plugins installed:
logstash-filter-json
logstash-filter-bytes
logstash-filter-extractnumbers
logstash-input-http_poller
logstash-input-http
logstash-input-redis
logstash-input-imap
logstash-input-tcp
logstash-input-udp
logstash-input-redis
logstash-input-syslog
logstash-input-snmp

Installation is based on this repo: https://github.com/deviantony/docker-elk

Description of the problem including expected versus actual behavior:

Steps to reproduce:

  1. Existing 7.17 cluster that was up to date (no issues in the migration assistant identified)
  2. Build 8.0.0 and docker-compose up
  3. Allow the migration to occur, crash at some point:

Log of the crash:

ubuntu@elk:~/docker-elk$ docker logs 12c16e63d535
Using bundled JDK: /usr/share/logstash/jdk
OpenJDK 64-Bit Server VM warning: Option UseConcMarkSweepGC was deprecated in version 9.0 and will likely be removed in a future release.
Sending Logstash logs to /usr/share/logstash/logs which is now configured via log4j2.properties
[2022-02-16T00:25:38,907][INFO ][logstash.runner          ] Log4j configuration path used is: /usr/share/logstash/config/log4j2.properties
[2022-02-16T00:25:38,925][INFO ][logstash.runner          ] Starting Logstash {"logstash.version"=>"8.0.0", "jruby.version"=>"jruby 9.2.20.1 (2.5.8) 2021-11-30 2a2962fbd1 OpenJDK 64-Bit Server VM 11.0.13+8 on 11.0.13+8 +indy +jit [linux-x86_64]"}
[2022-02-16T00:25:38,929][INFO ][logstash.runner          ] JVM bootstrap flags: [-Xms1g, -Xmx1g, -XX:+UseConcMarkSweepGC, -XX:CMSInitiatingOccupancyFraction=75, -XX:+UseCMSInitiatingOccupancyOnly, -Djava.awt.headless=true, -Dfile.encoding=UTF-8, -Djruby.compile.invokedynamic=true, -Djruby.jit.threshold=0, -Djruby.regexp.interruptible=true, -XX:+HeapDumpOnOutOfMemoryError, -Djava.security.egd=file:/dev/urandom, -Dlog4j2.isThreadContextMapInheritable=true, --add-opens=java.base/java.security=ALL-UNNAMED, --add-opens=java.base/java.io=ALL-UNNAMED, --add-opens=java.base/java.nio.channels=ALL-UNNAMED, --add-opens=java.base/sun.nio.ch=ALL-UNNAMED, --add-opens=java.management/sun.management=ALL-UNNAMED, -Dls.cgroup.cpuacct.path.override=/, -Dls.cgroup.cpu.path.override=/, -Xmx8192m, -Xms8192m]
[2022-02-16T00:25:39,205][INFO ][logstash.settings        ] Creating directory {:setting=>"path.queue", :path=>"/usr/share/logstash/data/queue"}
[2022-02-16T00:25:39,235][INFO ][logstash.settings        ] Creating directory {:setting=>"path.dead_letter_queue", :path=>"/usr/share/logstash/data/dead_letter_queue"}
[2022-02-16T00:25:40,057][INFO ][logstash.agent           ] No persistent UUID file found. Generating new UUID {:uuid=>"daf7cd27-955e-4a6d-ab96-bcba62017080", :path=>"/usr/share/logstash/data/uuid"}
[2022-02-16T00:25:40,175][FATAL][logstash.runner          ] An unexpected error occurred! {:error=>#<ArgumentError: wrong number of arguments (given 3, expected 1..2)>, :backtrace=>["/usr/share/logstash/logstash-core/lib/logstash/api/modules/base.rb:43:in `initialize'", "/usr/share/logstash/vendor/bundle/jruby/2.5.0/gems/sinatra-2.2.0/lib/sinatra/base.rb:1537:in `new'", "/usr/share/logstash/logstash-core/lib/logstash/api/rack_app.rb:113:in `block in app'", "org/jruby/RubyBasicObject.java:2622:in `instance_eval'", "/usr/share/logstash/vendor/bundle/jruby/2.5.0/gems/rack-2.2.3/lib/rack/builder.rb:125:in `initialize'", "/usr/share/logstash/logstash-core/lib/logstash/api/rack_app.rb:101:in `app'", "/usr/share/logstash/logstash-core/lib/logstash/webserver.rb:123:in `initialize'", "/usr/share/logstash/logstash-core/lib/logstash/webserver.rb:74:in `from_settings'", "/usr/share/logstash/logstash-core/lib/logstash/agent.rb:69:in `initialize'", "/usr/share/logstash/logstash-core/lib/logstash/runner.rb:508:in `create_agent'", "/usr/share/logstash/logstash-core/lib/logstash/runner.rb:399:in `execute'", "/usr/share/logstash/vendor/bundle/jruby/2.5.0/gems/clamp-1.0.1/lib/clamp/command.rb:68:in `run'", "/usr/share/logstash/logstash-core/lib/logstash/runner.rb:282:in `run'", "/usr/share/logstash/vendor/bundle/jruby/2.5.0/gems/clamp-1.0.1/lib/clamp/command.rb:133:in `run'", "/usr/share/logstash/lib/bootstrap/environment.rb:93:in `<main>'"]}
[2022-02-16T00:25:40,183][FATAL][org.logstash.Logstash    ] Logstash stopped processing because of an error: (SystemExit) exit
org.jruby.exceptions.SystemExit: (SystemExit) exit
        at org.jruby.RubyKernel.exit(org/jruby/RubyKernel.java:747) ~[jruby-complete-9.2.20.1.jar:?]
        at org.jruby.RubyKernel.exit(org/jruby/RubyKernel.java:710) ~[jruby-complete-9.2.20.1.jar:?]
        at usr.share.logstash.lib.bootstrap.environment.<main>(/usr/share/logstash/lib/bootstrap/environment.rb:94) ~[?:?]
Using bundled JDK: /usr/share/logstash/jdk
OpenJDK 64-Bit Server VM warning: Option UseConcMarkSweepGC was deprecated in version 9.0 and will likely be removed in a future release.
@yaauie
Copy link
Member

yaauie commented Feb 16, 2022

At first glance, this looks like either a bug in upstream Sinatra, related to sinatra/sinatra#1670 or in how keyword arguments are un-splatted and re-splatted in Jruby.

I will take a further look at this in the morning.

Are you doing anything special with the http.* or api.* settings in your logstash.yml?

@Will-Johns
Copy link

Will-Johns commented Feb 16, 2022

We are experiencing a similar issue, with no 8.0 upgrade. Everything was running earlier today, and we pushed a change to the SQL query used for our JDBC input triggering a Docker re-build, and now are getting this same error from the LogStash runner as the root issue.

Version: Logstash 7.16.2
JDBC Input Plugin: logstash-integration-jdbc (5.1.8)

@skywalkerisnull
Copy link
Author

@yaauie We don't have any real config in the logstash.yml only the http.host has been set.

@yaauie
Copy link
Member

yaauie commented Feb 16, 2022

@Will-Johns same backtrace? Would you mind sharing your Gemfile.lock in a gist? The backtrace in this issue is from Sinatra 2.2.0, and Logstash 7.16.2 bundles Sinatra 2.0.x, whose implementation is different specifically at the point where the backtrace is raised here.

@yaauie
Copy link
Member

yaauie commented Feb 16, 2022

Workaround: set either http.enabled: false (if using the legacy http.* config) or api.enabled: false (if using the new api.* config) to disable the web API. Depending on your container definition, you may also need to adjust liveness probes that depend on the web API.

@Will-Johns
Copy link

Will-Johns commented Feb 16, 2022

@yaauie Yeah I can get it still if you want, but it is the same back trace ( Sinatra 2.2.0 ). I think our problem may actually be a vendor bundling one. I just checked and the service that reported it is using the OpenSearch tarball of LogStash ( from the Ingest Tools section of this page ) so I'll follow up there instead.

Just knowing the root cause is great though and saved me a big headache, so thank you @yaauie

@skywalkerisnull
Copy link
Author

setting api.enabled: false is not preventing the issue for our problem, still getting the same error:

Sending Logstash logs to /usr/share/logstash/logs which is now configured via log4j2.properties
[2022-02-16T01:39:32,295][INFO ][logstash.runner          ] Log4j configuration path used is: /usr/share/logstash/config/log4j2.properties
[2022-02-16T01:39:32,312][INFO ][logstash.runner          ] Starting Logstash {"logstash.version"=>"8.0.0", "jruby.version"=>"jruby 9.2.20.1 (2.5.8) 2021-11-30 2a2962fbd1 OpenJDK 64-Bit Server VM 11.0.13+8 on 11.0.13+8 +indy +jit [linux-x86_64]"}
[2022-02-16T01:39:32,316][INFO ][logstash.runner          ] JVM bootstrap flags: [-Xms1g, -Xmx1g, -XX:+UseConcMarkSweepGC, -XX:CMSInitiatingOccupancyFraction=75, -XX:+UseCMSInitiatingOccupancyOnly, -Djava.awt.headless=true, -Dfile.encoding=UTF-8, -Djruby.compile.invokedynamic=true, -Djruby.jit.threshold=0, -Djruby.regexp.interruptible=true, -XX:+HeapDumpOnOutOfMemoryError, -Djava.security.egd=file:/dev/urandom, -Dlog4j2.isThreadContextMapInheritable=true, --add-opens=java.base/java.security=ALL-UNNAMED, --add-opens=java.base/java.io=ALL-UNNAMED, --add-opens=java.base/java.nio.channels=ALL-UNNAMED, --add-opens=java.base/sun.nio.ch=ALL-UNNAMED, --add-opens=java.management/sun.management=ALL-UNNAMED, -Dls.cgroup.cpuacct.path.override=/, -Dls.cgroup.cpu.path.override=/, -Xmx8192m, -Xms8192m]
[2022-02-16T01:39:33,128][FATAL][logstash.runner          ] An unexpected error occurred! {:error=>#<ArgumentError: wrong number of arguments (given 3, expected 1..2)>, :backtrace=>["/usr/share/logstash/logstash-core/lib/logstash/api/modules/base.rb:43:in `initialize'", "/usr/share/logstash/vendor/bundle/jruby/2.5.0/gems/sinatra-2.2.0/lib/sinatra/base.rb:1537:in `new'", "/usr/share/logstash/logstash-core/lib/logstash/api/rack_app.rb:113:in `block in app'", "org/jruby/RubyBasicObject.java:2622:in `instance_eval'", "/usr/share/logstash/vendor/bundle/jruby/2.5.0/gems/rack-2.2.3/lib/rack/builder.rb:125:in `initialize'", "/usr/share/logstash/logstash-core/lib/logstash/api/rack_app.rb:101:in `app'", "/usr/share/logstash/logstash-core/lib/logstash/webserver.rb:123:in `initialize'", "/usr/share/logstash/logstash-core/lib/logstash/webserver.rb:74:in `from_settings'", "/usr/share/logstash/logstash-core/lib/logstash/agent.rb:69:in `initialize'", "/usr/share/logstash/logstash-core/lib/logstash/runner.rb:508:in `create_agent'", "/usr/share/logstash/logstash-core/lib/logstash/runner.rb:399:in `execute'", "/usr/share/logstash/vendor/bundle/jruby/2.5.0/gems/clamp-1.0.1/lib/clamp/command.rb:68:in `run'", "/usr/share/logstash/logstash-core/lib/logstash/runner.rb:282:in `run'", "/usr/share/logstash/vendor/bundle/jruby/2.5.0/gems/clamp-1.0.1/lib/clamp/command.rb:133:in `run'", "/usr/share/logstash/lib/bootstrap/environment.rb:93:in `<main>'"]}
[2022-02-16T01:39:33,134][FATAL][org.logstash.Logstash    ] Logstash stopped processing because of an error: (SystemExit) exit
org.jruby.exceptions.SystemExit: (SystemExit) exit
        at org.jruby.RubyKernel.exit(org/jruby/RubyKernel.java:747) ~[jruby-complete-9.2.20.1.jar:?]
        at org.jruby.RubyKernel.exit(org/jruby/RubyKernel.java:710) ~[jruby-complete-9.2.20.1.jar:?]
        at usr.share.logstash.lib.bootstrap.environment.<main>(/usr/share/logstash/lib/bootstrap/environment.rb:94) ~[?:?]
Using bundled JDK: /usr/share/logstash/jdk
OpenJDK 64-Bit Server VM warning: Option UseConcMarkSweepGC was deprecated in version 9.0 and will likely be removed in a future release.

@yaauie
Copy link
Member

yaauie commented Feb 16, 2022

@skywalkerisnull what else are you doing in your setup & preconfigurstion? Logstash 8.0.0 shipped with Sinatra 2.1.0, not the 2.2.0 in your backtrace -> https://github.com/elastic/logstash/tree/v8.0.0/Gemfile.jruby-2.5.lock.release#L743

@skywalkerisnull
Copy link
Author

skywalkerisnull commented Feb 16, 2022

@yaauie I run a docker compose build based on this repo: https://github.com/deviantony/docker-elk

Here are the relevant parts:

docker-compose.yml

version: '3.2'
services:
  logstash:
    build:
      context: logstash/
      args:
        ELK_VERSION: $ELK_VERSION
    volumes:
      - type: bind
        source: ./logstash/config/logstash.yml
        target: /usr/share/logstash/config/logstash.yml
        read_only: true
      - type: bind
        source: ./logstash/pipeline
        target: /usr/share/logstash/pipeline
        read_only: true
    ports:
      - "5044:5044"
      - "5000:5000/tcp"
      - "5000:5000/udp"
      - "9600:9600"
      # HTTP
      - "8080:8080/tcp"
      - "8080:8080/udp"
      # SNMP
      - "161:161"
      - "162:162"
      # Syslog
      - "514:514/tcp"
      - "514:514/udp"
    environment:
      LS_JAVA_OPTS: "-Xmx4096m -Xms4096m"
    restart: always
    networks:
      - elk
    depends_on:
      - elasticsearch

/logstash/Dockerfile

ARG ELK_VERSION

# https://www.docker.elastic.co/
FROM docker.elastic.co/logstash/logstash:${ELK_VERSION}

# Add your logstash plugins setup here
RUN logstash-plugin install \
    logstash-filter-json \
    logstash-filter-bytes \
    logstash-filter-extractnumbers \
    logstash-input-http_poller \
    logstash-input-http \
    logstash-input-redis \    
    logstash-input-imap \
    logstash-input-tcp \
    logstash-input-udp \
    logstash-input-redis \
    logstash-input-syslog \
    logstash-input-snmp

.env

ELK_VERSION=8.0.0

/logstash/config/logstash.yml

---
## Default Logstash configuration from Logstash base image.
## https://github.com/elastic/logstash/blob/master/docker/data/logstash/config/logstash-full.yml
#
http:
  host: "0.0.0.0"
  # enabled: false

api.enabled: false
xpack.monitoring.elasticsearch.hosts: [ "http://elasticsearch:9200" ]

/logstash/pipeline/logstash.conf

input {
	beats {
		port => 5044
	}

	tcp {
		port => 5000
	}
	
	http {
		port => 8080
	}

	syslog {
		port => 514
	}
}

## Add your filters / logstash plugins configuration here

output {
	elasticsearch {
		hosts => "elasticsearch:9200"
		user => "<user name>"
		password => "<password>"
		ecs_compatibility => disabled
	}
}

@yaauie
Copy link
Member

yaauie commented Feb 16, 2022

I would imagine that the invocation of logstash-plugin install is somehow pulling in the updated Sinatra, which isn't behaving well under the JRuby runtime that ships with Logstash.

It appears that all of the plugins referenced in your pipeline are already bundled with Logstash. Is there a particular reason why you are re-installing them and a variety of others?

@Will-Johns
Copy link

Will-Johns commented Feb 16, 2022

@yaauie That seems to line up with what I'm experiencing. I switched to trying to use the Elastic provided tarball for Logstash 7.16.2 and ran into the same issue after running logstash-plugin install ...

Just came back to report the update.

Also, for context we are using the tarball setup, because the way our deployment is setup it's very convenient for us to use the same Dockerfile for a Python web application ( the base image ), and the LogStash runner.

@skywalkerisnull
Copy link
Author

I have commented out all of the installs and it now seems to be running for the past 5 minutes. I was not aware that it shipped with the majority. Or potentially, when we started using it, there was an issue with the inbuilt version and we had to upgrade (I can't recall what the reason was from a few years back)

@yaauie
Copy link
Member

yaauie commented Feb 16, 2022

Great. We will probably need to pin the Sinatra dependency, and to chase down the issue upstream before unpinning. I'll also file a separate issue or follow up on the plugin manager updating irrelevant gems, which I don't think it should be doing.

@matthew-muscat
Copy link

Running into the same issue here — Sinatra v2.2.0 looks to be getting updated when installing a plugin using logstash-plugin — the plugin we're specifically installing is the logstash-plugin-sumologic (not bundled in the default package that ships)

To resolve, i've pinned the version of sinatra to ~> 2.1.0, which avoids the package getting updated to v2.2.0 when installing a new plugin...

I've added the following to my docker-entrypoint script prior to the plugin installation...

    printf "@Workaround: Pinning Sinatra gem to v2.1.0\n"
    sed --in-place "s/gem.add_runtime_dependency \"sinatra\", '~> 2'/gem.add_runtime_dependency \"sinatra\", '~> 2.1.0'/g" /usr/share/logstash/logstash-core/logstash-core.gemspec
    /usr/share/logstash/bin/ruby -S /usr/share/logstash/vendor/bundle/jruby/2.5.0/bin/bundle install

@maederm
Copy link

maederm commented Feb 16, 2022

@matthew-muscat do you know how to fix it if it was already upgraded?
I tried bundle install but then it says

Bundler could not find compatible versions for gem "sinatra":
  In snapshot (Gemfile.lock):
    sinatra (= 2.2.0)

  In Gemfile:
    logstash-core was resolved to 7.17.0, which depends on
      sinatra (~> 2.1.0)

Running `bundle update` will rebuild your snapshot from scratch, using only
the gems in your Gemfile, which may resolve the conflict.

Running bundle update brings an ssl error

--- ERROR REPORT TEMPLATE -------------------------------------------------------

NoMethodError: undefined method `set_params' for #<OpenSSL::SSL::SSLContext:0x40a17708>
  /usr/share/logstash/vendor/jruby/lib/ruby/stdlib/net/http.rb:975:in `connect'
  /usr/share/logstash/vendor/jruby/lib/ruby/stdlib/net/http.rb:924:in `do_start'

Just cleaning the whole /usr/share/logstash folder and reinstalling the rpm works but I hope there is an alternative for rolling out on many servers.

[EDIT] just changing the version in the Gemfile.lock back works because the old version of sinatra is still available on the file system.

@palin
Copy link

palin commented Feb 16, 2022

Thank you @matthew-muscat - that's actually the fix that works for me.

I use logstash within docker container. I added @matthew-muscat 2 lines before logstash-plugin install (...) commands in my Dockerfile:

....

RUN sed --in-place "s/gem.add_runtime_dependency \"sinatra\", '~> 2'/gem.add_runtime_dependency \"sinatra\", '~> 2.1.0'/g" /usr/share/logstash/logstash-core/logstash-core.gemspec

RUN /usr/share/logstash/bin/ruby -S /usr/share/logstash/vendor/bundle/jruby/2.5.0/bin/bundle install

RUN logstash-plugin install .....

The code changes the logstash-core.gemspec - it replaces sinatra ~> 2 entry with sinatra ~> 2.1.0 so the installed version will be 2.1.0. After that we run bundle install that will install Sinatra 2.1.0.
Thank you once again

@kares
Copy link
Contributor

kares commented Feb 16, 2022

The previous locking will do but it's safer to restore all sinatra related changes directly in the Gemfile.lock :

Safe this patch into a sinatra.patch file:

diff --git Gemfile.lock Gemfile.lock
index 96b42c8..289508d 100644
--- Gemfile.lock
+++ Gemfile.lock
@@ -709,7 +709,7 @@ GEM
       nio4r (~> 2.0)
     racc (1.5.2-java)
     rack (2.2.3)
-    rack-protection (2.2.0)
+    rack-protection (2.1.0)
       rack
     rack-test (1.1.0)
       rack (>= 1.0, < 3)
@@ -744,10 +744,10 @@ GEM
       concurrent-ruby (~> 1.0)
     sequel (5.52.0)
     simple_oauth (0.3.1)
-    sinatra (2.2.0)
+    sinatra (2.1.0)
       mustermann (~> 1.0)
       rack (~> 2.2)
-      rack-protection (= 2.2.0)
+      rack-protection (= 2.1.0)
       tilt (~> 2.0)
     snappy (0.0.12-java)
       snappy-jars (~> 1.1.0)
  1. cd $LOGSTASH_HOME (there should be a Gemfile.lock in the directory listing)
  2. apply the above patch: patch < sinatra.patch
  3. verify bin/logstash -e "" is working again

One will need to remember to restore Sinatra (until 7.17.1 and 8.0.1 are released #13784),

optionally one could also avoid bumping into the next time using:

  1. echo "gem 'sinatra', '2.1.0'" >> Gemfile
  2. bin/logstash --enable-local-plugin-development -e ""
  3. run business (Logstash) as usual ...

p.s. Please note that this issue also affects LS 7.17 and likely older as well (e.g. when installing a plugin).

@nosnilmot
Copy link

Sinatra claims to follow Semantic Versioning, so the 2.2.0 minor release should be backwards compatible. If it is not, shouldn't that be reported to Sinatra to fix?

@andy812
Copy link

andy812 commented Feb 17, 2022

Workaround for non-docker installation:

sed --in-place "s/gem.add_runtime_dependency \"sinatra\", '~> 2'/gem.add_runtime_dependency \"sinatra\", '~> 2.1.0'/g" /usr/share/logstash/logstash-core/logstash-core.gemspec

cd /usr/share/logstash/

/usr/share/logstash/bin/ruby -S /usr/share/logstash/vendor/bundle/jruby/2.5.0/bin/bundle install

/usr/share/logstash/bin/logstash-plugin install .....

@mvenukadasula
Copy link

Solved the same error on 7.16.3 per suggestion from another thread by adding --preserve.

RUN ${LS_HOME}/bin/logstash-plugin install --preserve logstash-input-kinesis

Do you see any problem with this approach? Shall I use alternate solution from @matthew-muscat and update my Dockerfile?

@yaauie
Copy link
Member

yaauie commented Feb 17, 2022

Digging into the history of the --preserve flag (#5224), it looks like this is in fact its intended use, and I have validated that when installing a plugin that does not list sinatra as a dependency this flag causes sinatra to not be updated.

TIL.

@liza-mae
Copy link

Thanks @yaauie the snapshot I had did not contain the fix, today's build passes.

@Aranjan21
Copy link

Aranjan21 commented Feb 23, 2022

I was getting similar kind of error while installing logstash 1:7.16.1

[2022-02-17T04:45:10,663][FATAL][logstash.runner ] An unexpected error occurred! {:error=>#<ArgumentError: wrong number of arguments (given 3, expected 1..2)>, :backtrace=>["/usr/share/logstash/logstash-core/lib/logstash/api/modules/base.rb:43:in initialize'", "/usr/share/logstash/vendor/bundle/jruby/2.5.0/gems/sinatra-2.2.0/lib/sinatra/base.rb:1537:in new'", "/usr/share/logstash/logstash-core/lib/logstash/api/rack_app.rb:113:in block in app'", "org/jruby/RubyBasicObject.java:2622:in instance_eval'", "/usr/share/logstash/vendor/bundle/jruby/2.5.0/gems/rack-2.2.3/lib/rack/builder.rb:125:in initialize'", "/usr/share/logstash/logstash-core/lib/logstash/api/rack_app.rb:101:in app'", "/usr/share/logstash/logstash-core/lib/logstash/webserver.rb:123:in initialize'", "/usr/share/logstash/logstash-core/lib/logstash/webserver.rb:74:in from_settings'", "/usr/share/logstash/logstash-core/lib/logstash/agent.rb:76:in initialize'", "/usr/share/logstash/logstash-core/lib/logstash/runner.rb:533:in create_agent'", "/usr/share/logstash/logstash-core/lib/logstash/runner.rb:424:in execute'", "/usr/share/logstash/vendor/bundle/jruby/2.5.0/gems/clamp-1.0.1/lib/clamp/command.rb:68:in run'", "/usr/share/logstash/logstash-core/lib/logstash/runner.rb:291:in run'", "/usr/share/logstash/vendor/bundle/jruby/2.5.0/gems/clamp-1.0.1/lib/clamp/command.rb:133:in run'", "/usr/share/logstash/lib/bootstrap/environment.rb:93:in `

'"]}
[2022-02-17T04:45:10,667][FATAL][org.logstash.Logstash ] Logstash stopped processing because of an error: (SystemExit) exit
org.jruby.exceptions.SystemExit: (SystemExit) exit
at org.jruby.RubyKernel.exit(org/jruby/RubyKernel.java:747) ~[jruby-complete-9.2.20.1.jar:?]
at org.jruby.RubyKernel.exit(org/jruby/RubyKernel.java:710) ~[jruby-complete-9.2.20.1.jar:?]
at usr.share.logstash.lib.bootstrap.environment.(/usr/share/logstash/lib/bootstrap/environment.rb:94) ~[?:?]

So in our installation script where we are adding plugins while installing logstash added --preserve , we are using ansible to install .
One thing is not known why we need to add this switch all of sudden .

  • name: Add translate plugin to logstash
    command: /usr/share/logstash/bin/logstash-plugin install --preserve logstash-filter-translate

@toivonen1979
Copy link

Is there an expected release date for v7.17.1 ?

@kares
Copy link
Contributor

kares commented Feb 23, 2022

I was getting similar kind of error while installing logstash 1:7.16.1

  1. installed LS 7.16.1
  2. run bin/logstash-plugin install --preserve logstash-filter-translate
Installation successful

But I do not see any changes to the Gemfile.lock with regards to sinatra, cat Gemfile.lock | grep sinatra

      sinatra (~> 2)
    sinatra (2.1.0)

... and Logtash boots up just fine.
Maybe there's another plugin install/update that was run, anyhow the work-around already presented should work e.g.

  1. install LS - whatever (ansible) command you run
  2. sed --in-place "s/gem.add_runtime_dependency \"sinatra\", '~> 2'/gem.add_runtime_dependency \"sinatra\", '~> 2.1.0'/g" /usr/share/logstash/logstash-core/logstash-core.gemspec
  3. than /usr/share/logstash/bin/logstash-plugin install --preserve logstash-filter-translate

Is there an expected release date for v7.17.1 ?

7.17.1, which includes a the sinatra pin, MIGHT be out next week (if nothing unexpected comes up)

Also planning to further improve the plugin install/update process in 7.17.2 with regards to any dependency updates that might happen while installing/updating plugins.

@reedflinch
Copy link

I mistakenly thought @kares solution was working for me, only to find the following error:

sed --in-place "s/gem.add_runtime_dependency \"sinatra\", '~> 2'/gem.add_runtime_dependency \"sinatra\", '~> 2.1.0'/g" /usr/share/logstash/logstash-core/logstash-core.gemspec

/usr/share/logstash/bin/logstash-plugin install logstash-output-amazon_es

Using bundled JDK: /usr/share/logstash/jdk
OpenJDK 64-Bit Server VM warning: Option UseConcMarkSweepGC was deprecated in version 9.0 and will likely be removed in a future release.
Validating logstash-output-amazon_es
Installing logstash-output-amazon_es

Plugin version conflict, aborting
ERROR: Installation Aborted, message: Bundler could not find compatible versions for gem "sinatra":
In snapshot (Gemfile.lock):
sinatra (= 2.2.0)
In Gemfile:
logstash-core was resolved to 7.16.1, which depends on
sinatra (~> 2.1.0)
Running `bundle update` will rebuild your snapshot from scratch, using only
the gems in your Gemfile, which may resolve the conflict.

Apologize that I'm a bit ignorant with bundler but I've tried the recommended bundle update and bundle install from above with no luck.

@nosnilmot
Copy link

Apologize that I'm a bit ignorant with bundler but I've tried the recommended bundle update and bundle install from above with no luck.

@reedflinch this is going to be the blind leading the blind, but a couple of guesses:
I think you already got the unwanted update to sinatra installed before you pinned version 2.1.0, judging from earlier comments you want to do this to (re)install the correct versions from that gemfile (note the cd first):

cd /usr/share/logstash
/usr/share/logstash/bin/ruby -S /usr/share/logstash/vendor/bundle/jruby/2.5.0/bin/bundle install

and then when installing the plugin it might be best to use --preserve option (although with sinatra version pinned that probably should not be necessary):

/usr/share/logstash/bin/logstash-plugin install --preserve logstash-output-amazon_es

@kares
Copy link
Contributor

kares commented Feb 25, 2022

I mistakenly thought @kares solution was working for me, only to find the following error:

Sorry to hear that, maybe the best action is to simply re-install Logstash and start over.
There's also an option of starting with a "restored" Gemfile.lock for 7.16.1 but that will likely by out of sync with the Gemfile (which contains the newly installed plugins that do not ship with Logstash), so it's only a viable option if only plugin updates where done.

Also, whenever doing bundle commands directly it's might end up in a non-usable state as LS also runs some additional commands after the plain bundle install and bundle update, it's really for the best to not experiment too much.

@reedflinch
Copy link

Appreciate everyone's help, thank you 🙏

The best solution for me, until a patched Logstash version is released, was to simply roll back our AMI to the last version. I could never get the gem/bundle changes to play nicely.

Also, whenever doing bundle commands directly it's might end up in a non-usable state as LS also runs some additional commands after the plain bundle install and bundle update, it's really for the best to not experiment too much.

I suspect this might line up with what I was seeing.

@kasumiru
Copy link

kasumiru commented Apr 2, 2022

some trouble. this workaround (#13777 (comment)) does't help me. Automaticaly fixed after update from logstash-7.16.2-1.x86_64 to logstash-7.17.1-1.x86_64

@kares
Copy link
Contributor

kares commented May 10, 2022

going to close the issue - it's still going to potentially affect older LS versions but since 7.17.2 and 8.1.1 LS does conservative plugin updates by default which is expected to minimize the updates on transitive dependencies.

@kares kares closed this as completed May 10, 2022
@kares
Copy link
Contributor

kares commented May 10, 2022

and just for the record sinatra still hasn't released an updated version (after 2.2.0 released in Feb/2022) that would unbreak JRuby

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

Successfully merging a pull request may close this issue.