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

remove forced dependency on old bundler #9395

Merged
merged 2 commits into from Nov 30, 2018
Merged

Conversation

jsvd
Copy link
Member

@jsvd jsvd commented Apr 17, 2018

This is a byproduct of the closed PR #9362

We no longer need to pin bundler to an old version. Newer versions did break the internal Bundler.settings, also updated here.

@jsvd jsvd added the bundler label Apr 17, 2018
@@ -1,7 +1,7 @@

namespace "dependency" do
task "bundler" do
Rake::Task["gem:require"].invoke("bundler", "~> 1.9.4")
Rake::Task["gem:require"].invoke("bundler", "~> 1")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jsvd maybe just make this 1.16.0 exactly like we have in the integration tests? This isn't really a dependency that must be free floating (imo) ( ~> 1 seems wrong because we now changed the API calls in a way that will only work with newer Bundler?).

@original-brownbear
Copy link
Member

LGTM if it goes green :)

@jsvd
Copy link
Member Author

jsvd commented Apr 18, 2018

As with most things bundler..a simple change always turns out to not be so simple...this seems to be breaking other parts of the bundler setup. checking.

@andrewvc
Copy link
Contributor

Thanks for this Joao! We really should move off that ancient version of bundler. LMK if you'd like one of us on core to take over this patch, I understand if you don't have the bandwidth.

I'm glad to do it myself.

@andrewvc
Copy link
Contributor

andrewvc commented May 1, 2018

jenkins, please test this

@jsvd jsvd force-pushed the update_bundler branch 2 times, most recently from 07a6c4a to 8937474 Compare November 21, 2018 10:59
@jsvd jsvd force-pushed the update_bundler branch 2 times, most recently from e3d44ee to c49b03c Compare November 23, 2018 18:15
@jsvd
Copy link
Member Author

jsvd commented Nov 23, 2018

Still broken. I've reduced the differences between a broken build and a good one to just bundler versions and a method alias (since []= doesn't exist in newer bundlers:

% diff --brief -r logstash-7.0.0-SNAPSHOT.broken/ logstash-7.0.0-SNAPSHOT.good/
Files logstash-7.0.0-SNAPSHOT.broken/lib/bootstrap/bundler.rb and logstash-7.0.0-SNAPSHOT.good/lib/bootstrap/bundler.rb differ
Only in logstash-7.0.0-SNAPSHOT.broken/vendor/bundle/jruby/2.3.0/gems: bundler-1.17.1
Only in logstash-7.0.0-SNAPSHOT.good/vendor/bundle/jruby/2.3.0/gems: bundler-1.9.10
Only in logstash-7.0.0-SNAPSHOT.broken/vendor/bundle/jruby/2.3.0/specifications: bundler-1.17.1.gemspec
Only in logstash-7.0.0-SNAPSHOT.good/vendor/bundle/jruby/2.3.0/specifications: bundler-1.9.10.gemspec
% diff logstash-7.0.0-SNAPSHOT.broken/lib/bootstrap/bundler.rb  logstash-7.0.0-SNAPSHOT.good/lib/bootstrap/bundler.rb 
13d12
<         alias :[]= :set_local
% cd logstash-7.0.0-SNAPSHOT.broken
% bin/logstash -e ""
[ERROR] 2018-11-23 18:03:00.748 [main] Logstash - java.lang.IllegalStateException: Logstash stopped processing because of an error: (GemspecError) 
[!] There was an error while loading `logstash-core-plugin-api.gemspec`: No such file or directory - /Users/joaoduarte/new_bundler/logstash-7.0.0-SNAPSHOT.broken/logstash-core-plugin-api/versions-gem-copy.yml. Bundler cannot continue.

 #  from /Users/joaoduarte/new_bundler/logstash-7.0.0-SNAPSHOT.broken/logstash-core-plugin-api/logstash-core-plugin-api.gemspec:1
 #  -------------------------------------------
 >  # -*- encoding: utf-8 -*-
 #  lib = File.expand_path('../lib', __FILE__)
 #  -------------------------------------------

% cd ../logstash-7.0.0-SNAPSHOT.good
% bin/logstash -e ""
[2018-11-23T18:03:20,872][INFO ][logstash.setting.writabledirectory] Creating directory {:setting=>"path.queue", :path=>"/Users/joaoduarte/new_bundler/logstash-7.0.0-SNAPSHOT.good/data/queue"}
[2018-11-23T18:03:20,879][INFO ][logstash.setting.writabledirectory] Creating directory {:setting=>"path.dead_letter_queue", :path=>"/Users/joaoduarte/new_bundler/logstash-7.0.0-SNAPSHOT.good/data/dead_letter_queue"}
[2018-11-23T18:03:20,974][WARN ][logstash.config.source.multilocal] Ignoring the 'pipelines.yml' file because modules or command line options are specified
[2018-11-23T18:03:20,993][INFO ][logstash.runner          ] Starting Logstash {"logstash.version"=>"7.0.0"}
[2018-11-23T18:03:21,012][INFO ][logstash.agent           ] No persistent UUID file found. Generating new UUID {:uuid=>"6bac4229-1c88-4cc8-8994-7fb2aff8caf7", :path=>"/Users/joaoduarte/new_bundler/logstash-7.0.0-SNAPSHOT.good/data/uuid"}
[2018-11-23T18:03:23,046][INFO ][logstash.javapipeline    ] Starting pipeline {:pipeline_id=>"main", "pipeline.workers"=>8, "pipeline.batch.size"=>125, "pipeline.batch.delay"=>50, "pipeline.max_inflight"=>1000, :thread=>"#<Thread:0x7439bb3f run>"}
[2018-11-23T18:03:23,103][INFO ][logstash.javapipeline    ] Pipeline started {"pipeline.id"=>"main"}
The stdin plugin is now waiting for input:
[2018-11-23T18:03:23,157][INFO ][logstash.agent           ] Pipelines running {:count=>1, :running_pipelines=>[:main], :non_running_pipelines=>[]}
[2018-11-23T18:03:23,383][INFO ][logstash.agent           ] Successfully started Logstash API endpoint {:port=>9600}
^C[2018-11-23T18:03:25,126][WARN ][logstash.runner          ] SIGINT received. Shutting down.
[2018-11-23T18:03:25,365][INFO ][logstash.javapipeline    ] Pipeline terminated {"pipeline.id"=>"main"}

@jsvd
Copy link
Member Author

jsvd commented Nov 25, 2018

all tests are now passing. Looking at the produced artifacts (like tar.gz) I noticed the development gems are being included (and weren't included before), I will investigate.

Example:

/tmp % tar -zxf logstash-7.0.0-SNAPSHOT.tar.gz
/tmp/logstash-7.0.0-SNAPSHOT % grep tins Gemfile
gem "tins", "1.6", :group => :development
/tmp/logstash-7.0.0-SNAPSHOT % find . -name *tins*
./vendor/bundle/jruby/2.3.0/specifications/tins-1.6.0.gemspec
./vendor/bundle/jruby/2.3.0/gems/tins-1.6.0
./vendor/bundle/jruby/2.3.0/gems/tins-1.6.0/tins.gemspec
./vendor/bundle/jruby/2.3.0/gems/tins-1.6.0/lib/tins
./vendor/bundle/jruby/2.3.0/gems/tins-1.6.0/lib/tins.rb

@jsvd
Copy link
Member Author

jsvd commented Nov 26, 2018

I believe all edge cases have been fixed. I can no longer find situations where the newer bundler breaks the development or production mode, so this PR is now ready for review.

@@ -67,7 +67,7 @@ def inject(gemfile_path, lockfile_path, dependencies)
gemfile = LogStash::Gemfile.new(File.new(gemfile_path, "r+")).load

begin
@new_deps.each do |dependency|
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is simply due to a change in the name of the variable in recent bundlers:

@original-brownbear
Copy link
Member

@jsvd 🎉 🎉

LGTM :)

This commit required some tweaking of how we setup Bundler
due to changes in reset behaviour, an internal variable name change,
and the Bundler::Settings api changing.
Copy link
Member

@yaauie yaauie left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In general, this looks sensible.

I left a comment about a potential change that isn't really called out in this PR. We change both the implementation and a spec for the :without setting, but we don't change any callers. Does the new bundler accept an array value here where the old one required a colon-concatenated string?

Otherwise, LGTM

lib/bootstrap/bundler.rb Show resolved Hide resolved
@jsvd
Copy link
Member Author

jsvd commented Nov 28, 2018

Jenkins test this please

@jsvd jsvd merged commit ab20b40 into elastic:master Nov 30, 2018
@jsvd jsvd deleted the update_bundler branch November 30, 2018 09:25
yaauie added a commit to yaauie/logstash that referenced this pull request Jan 8, 2019
yaauie added a commit that referenced this pull request Jan 9, 2019
* Revert "Revert "remove forced dependency on old bundler (#9395)""

This reverts commit bef9841.

* plugin management: update internal bundler to 1.17.x APIs

* deps: update dev dependency webmock to version compatible with JRuby 9.2

* spec: update Pack fixture to include manticore version that doesn't conflict
yaauie added a commit to yaauie/logstash that referenced this pull request Jan 20, 2019
* Revert "Revert "remove forced dependency on old bundler (elastic#9395)""

This reverts commit bef9841.

* plugin management: update internal bundler to 1.17.x APIs

* deps: update dev dependency webmock to version compatible with JRuby 9.2

* spec: update Pack fixture to include manticore version that doesn't conflict
yaauie added a commit to yaauie/logstash that referenced this pull request Jan 22, 2019
* Revert "Revert "remove forced dependency on old bundler (elastic#9395)""

This reverts commit bef9841.

* plugin management: update internal bundler to 1.17.x APIs

* deps: update dev dependency webmock to version compatible with JRuby 9.2

* spec: update Pack fixture to include manticore version that doesn't conflict
jsvd pushed a commit to jsvd/logstash that referenced this pull request Jan 22, 2019
* Revert "Revert "remove forced dependency on old bundler (elastic#9395)""

This reverts commit bef9841.

* plugin management: update internal bundler to 1.17.x APIs

* deps: update dev dependency webmock to version compatible with JRuby 9.2

* spec: update Pack fixture to include manticore version that doesn't conflict
yaauie added a commit to yaauie/logstash that referenced this pull request Feb 4, 2019
* Revert "Revert "remove forced dependency on old bundler (elastic#9395)""

This reverts commit bef9841.

* plugin management: update internal bundler to 1.17.x APIs

* deps: update dev dependency webmock to version compatible with JRuby 9.2

* spec: update Pack fixture to include manticore version that doesn't conflict
yaauie added a commit that referenced this pull request Feb 5, 2019
* bump jruby to 9.2

* don't rely on logstash-base docker image

* work around webmock ruby 2.5 support

* ensure data folder exists in docker

* change fixnum and bignum to integer

* FileUtils.rmdir to rm_rf

this is because from 2.3 to 2.5 FileUtils.rmdir will throw an exception
if the directory isn't empty. On 2.3 the operation will just not delete
the directory silently.

* bump jruby to 9.2.5.0 and fix test

* make rake default task since prepare pack needs it

* Resolve compiler warnings (#10247)

There are 3 types of compiler warnings that are either resolved or suppressed:

1. Rawtypes: In JRuby 9.2, `RubyArray` is a generic, so references throughout
   our codebase to the now "raw" type trigger warnings. In most cases we cannot
   actually resolve the issue, since the JRuby-provided methods for creating
   `RubyArray`s still return the raw type, so these have been suppressed.

2. Deprecations:
   - `RubyString#intern19()` -> `RubyString#intern()`
   - `RubyString#downcase19(ThreadContext)` -> `RubyString#downcase(ThreadContext)`
   - `NativeException`: remove import & reference directly; suppress usage
     warnings
   - `RaiseException()`: migrate to equivalent non-deprecated methods wherever
     possible; in some cases where we are using this in conjunction with the
     also-deprecated `NativeException` to preserve java stacktraces, there
     seems to be no non-deprecated path forward, so these cases have been
     suppressed.

3. Redundant Casts
   - Resolved

* JRuby 9.2 bundler shenanigans (#10266)

* Revert "Revert "remove forced dependency on old bundler (#9395)""

This reverts commit bef9841.

* plugin management: update internal bundler to 1.17.x APIs

* deps: update dev dependency webmock to version compatible with JRuby 9.2

* spec: update Pack fixture to include manticore version that doesn't conflict

* build: update gradle to version that has Java 11 support

* java11: resolve or suppress deprecation warnings

* Remove superfluous flag opting into ParNew GC implementation

When opting into CMS garbage collector with `XX:+UseConcMarkSweepGC`, the
young generation collector ParNew has been the default since Java 8, making
the `XX:+UseParNew` flag redundant; the flag was removed in Java 9, and
should no longer be specified to work with modern Javas.

https://bugs.openjdk.java.net/browse/JDK-8006478
https://openjdk.java.net/jeps/214

* spec: set thread name to example description for easier debugging

* spec: prevent errors in testing specs by checking against skip list before using

* no-op: remove use of `HashMap#computeIfAbsent` on single-threaded code

> This method will, on a best-effort basis, throw a `ConcurrentModificationException`
> if it is detected that the mapping function modifies this map during computation.
>
> -- https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/util/HashMap.html#computeIfAbsent(K,java.util.function.Function)

* qa: by default, run integration against Elastic Stack 6.5.x

To support development on Logstash on top of Java 11, default to testing
against an Elastic Stack that is capable of running on Java 11.

* qa: ignore deprecation warnings when comparing offline pack output

* qa: add Java 9+ support to ChildProcess dev dependency

this can safely be removed when the childprocess gem supports Java9+
enkessler/childprocess#141

* qa: allow connections to localhost in webmock

* bump jrjackson version

* fix filebeat integration tests

* spec: ensure license compliance spec runs first

The license compliance spec that validates the licenses of bundled
plugins appears to not be compatible with the hooks that we inject
into bundler for plugin management, and will fail in obscure ways
when run after those hooks have been added. Since those hooks are
not necessary for validating licenses, the easiest solution was to
ensure that those specs run first, before the VM has been poluted.

Since the gradle/junit/rspec bridge that is currently in place
runs all specs in the same JVM, we also need to make sure that the
rspec "world" is reset before a run, to ensure that it doesn't
retain spec definitions from previous runs.

Also updates the rake invocation, although I'm not sure it is used
any more.
yaauie added a commit to yaauie/logstash that referenced this pull request Feb 5, 2019
* bump jruby to 9.2

* don't rely on logstash-base docker image

* work around webmock ruby 2.5 support

* ensure data folder exists in docker

* change fixnum and bignum to integer

* FileUtils.rmdir to rm_rf

this is because from 2.3 to 2.5 FileUtils.rmdir will throw an exception
if the directory isn't empty. On 2.3 the operation will just not delete
the directory silently.

* bump jruby to 9.2.5.0 and fix test

* make rake default task since prepare pack needs it

* Resolve compiler warnings (elastic#10247)

There are 3 types of compiler warnings that are either resolved or suppressed:

1. Rawtypes: In JRuby 9.2, `RubyArray` is a generic, so references throughout
   our codebase to the now "raw" type trigger warnings. In most cases we cannot
   actually resolve the issue, since the JRuby-provided methods for creating
   `RubyArray`s still return the raw type, so these have been suppressed.

2. Deprecations:
   - `RubyString#intern19()` -> `RubyString#intern()`
   - `RubyString#downcase19(ThreadContext)` -> `RubyString#downcase(ThreadContext)`
   - `NativeException`: remove import & reference directly; suppress usage
     warnings
   - `RaiseException()`: migrate to equivalent non-deprecated methods wherever
     possible; in some cases where we are using this in conjunction with the
     also-deprecated `NativeException` to preserve java stacktraces, there
     seems to be no non-deprecated path forward, so these cases have been
     suppressed.

3. Redundant Casts
   - Resolved

* JRuby 9.2 bundler shenanigans (elastic#10266)

* Revert "Revert "remove forced dependency on old bundler (elastic#9395)""

This reverts commit bef9841.

* plugin management: update internal bundler to 1.17.x APIs

* deps: update dev dependency webmock to version compatible with JRuby 9.2

* spec: update Pack fixture to include manticore version that doesn't conflict

* build: update gradle to version that has Java 11 support

* java11: resolve or suppress deprecation warnings

* Remove superfluous flag opting into ParNew GC implementation

When opting into CMS garbage collector with `XX:+UseConcMarkSweepGC`, the
young generation collector ParNew has been the default since Java 8, making
the `XX:+UseParNew` flag redundant; the flag was removed in Java 9, and
should no longer be specified to work with modern Javas.

https://bugs.openjdk.java.net/browse/JDK-8006478
https://openjdk.java.net/jeps/214

* spec: set thread name to example description for easier debugging

* spec: prevent errors in testing specs by checking against skip list before using

* no-op: remove use of `HashMap#computeIfAbsent` on single-threaded code

> This method will, on a best-effort basis, throw a `ConcurrentModificationException`
> if it is detected that the mapping function modifies this map during computation.
>
> -- https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/util/HashMap.html#computeIfAbsent(K,java.util.function.Function)

* qa: by default, run integration against Elastic Stack 6.5.x

To support development on Logstash on top of Java 11, default to testing
against an Elastic Stack that is capable of running on Java 11.

* qa: ignore deprecation warnings when comparing offline pack output

* qa: add Java 9+ support to ChildProcess dev dependency

this can safely be removed when the childprocess gem supports Java9+
enkessler/childprocess#141

* qa: allow connections to localhost in webmock

* bump jrjackson version

* fix filebeat integration tests

* spec: ensure license compliance spec runs first

The license compliance spec that validates the licenses of bundled
plugins appears to not be compatible with the hooks that we inject
into bundler for plugin management, and will fail in obscure ways
when run after those hooks have been added. Since those hooks are
not necessary for validating licenses, the easiest solution was to
ensure that those specs run first, before the VM has been poluted.

Since the gradle/junit/rspec bridge that is currently in place
runs all specs in the same JVM, we also need to make sure that the
rspec "world" is reset before a run, to ensure that it doesn't
retain spec definitions from previous runs.

Also updates the rake invocation, although I'm not sure it is used
any more.
jsvd pushed a commit that referenced this pull request Feb 5, 2019
backport of  #10279 to 6.x

* bump jruby to 9.2

* don't rely on logstash-base docker image

* work around webmock ruby 2.5 support

* ensure data folder exists in docker

* change fixnum and bignum to integer

* FileUtils.rmdir to rm_rf

this is because from 2.3 to 2.5 FileUtils.rmdir will throw an exception
if the directory isn't empty. On 2.3 the operation will just not delete
the directory silently.

* bump jruby to 9.2.5.0 and fix test

* make rake default task since prepare pack needs it

* Resolve compiler warnings (#10247)

There are 3 types of compiler warnings that are either resolved or suppressed:

1. Rawtypes: In JRuby 9.2, `RubyArray` is a generic, so references throughout
   our codebase to the now "raw" type trigger warnings. In most cases we cannot
   actually resolve the issue, since the JRuby-provided methods for creating
   `RubyArray`s still return the raw type, so these have been suppressed.

2. Deprecations:
   - `RubyString#intern19()` -> `RubyString#intern()`
   - `RubyString#downcase19(ThreadContext)` -> `RubyString#downcase(ThreadContext)`
   - `NativeException`: remove import & reference directly; suppress usage
     warnings
   - `RaiseException()`: migrate to equivalent non-deprecated methods wherever
     possible; in some cases where we are using this in conjunction with the
     also-deprecated `NativeException` to preserve java stacktraces, there
     seems to be no non-deprecated path forward, so these cases have been
     suppressed.

3. Redundant Casts
   - Resolved

* JRuby 9.2 bundler shenanigans (#10266)

* Revert "Revert "remove forced dependency on old bundler (#9395)""

This reverts commit bef9841.

* plugin management: update internal bundler to 1.17.x APIs

* deps: update dev dependency webmock to version compatible with JRuby 9.2

* spec: update Pack fixture to include manticore version that doesn't conflict

* build: update gradle to version that has Java 11 support

* java11: resolve or suppress deprecation warnings

* Remove superfluous flag opting into ParNew GC implementation

When opting into CMS garbage collector with `XX:+UseConcMarkSweepGC`, the
young generation collector ParNew has been the default since Java 8, making
the `XX:+UseParNew` flag redundant; the flag was removed in Java 9, and
should no longer be specified to work with modern Javas.

https://bugs.openjdk.java.net/browse/JDK-8006478
https://openjdk.java.net/jeps/214

* spec: set thread name to example description for easier debugging

* spec: prevent errors in testing specs by checking against skip list before using

* no-op: remove use of `HashMap#computeIfAbsent` on single-threaded code

> This method will, on a best-effort basis, throw a `ConcurrentModificationException`
> if it is detected that the mapping function modifies this map during computation.
>
> -- https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/util/HashMap.html#computeIfAbsent(K,java.util.function.Function)

* qa: by default, run integration against Elastic Stack 6.5.x

To support development on Logstash on top of Java 11, default to testing
against an Elastic Stack that is capable of running on Java 11.

* qa: ignore deprecation warnings when comparing offline pack output

* qa: add Java 9+ support to ChildProcess dev dependency

this can safely be removed when the childprocess gem supports Java9+
enkessler/childprocess#141

* qa: allow connections to localhost in webmock

* bump jrjackson version

* fix filebeat integration tests

* spec: ensure license compliance spec runs first

The license compliance spec that validates the licenses of bundled
plugins appears to not be compatible with the hooks that we inject
into bundler for plugin management, and will fail in obscure ways
when run after those hooks have been added. Since those hooks are
not necessary for validating licenses, the easiest solution was to
ensure that those specs run first, before the VM has been poluted.

Since the gradle/junit/rspec bridge that is currently in place
runs all specs in the same JVM, we also need to make sure that the
rspec "world" is reset before a run, to ensure that it doesn't
retain spec definitions from previous runs.

Also updates the rake invocation, although I'm not sure it is used
any more.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants