Skip to content
This repository has been archived by the owner on Jul 13, 2023. It is now read-only.

Added support for aws-sdk-s3 gem which is now preferred way to intera… #2481

Merged
merged 3 commits into from
Mar 9, 2018
Merged

Added support for aws-sdk-s3 gem which is now preferred way to intera… #2481

merged 3 commits into from
Mar 9, 2018

Conversation

morgoth
Copy link
Contributor

@morgoth morgoth commented Aug 31, 2017

…ct with s3.

Reference: https://github.com/aws/aws-sdk-ruby/blob/master/V3_UPGRADING_GUIDE.md#library-maintainer

It still should work with aws-sdk fine

@@ -1,5 +1,5 @@
require 'spec_helper'
require 'aws-sdk'
require 'aws-sdk-s3'

Choose a reason for hiding this comment

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

Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.

e.message << " (You may need to install the aws-sdk gem)"
raise e
begin
require 'aws-sdk' # Fallback to outdated gem

Choose a reason for hiding this comment

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

Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.


module S3
def self.extended base
begin
require 'aws-sdk'
require 'aws-sdk-s3'

Choose a reason for hiding this comment

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

Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping.

@virgoproz
Copy link

+1 on this Pull Request to be merged!

@olivierbuffon
Copy link

+1

@morgoth
Copy link
Contributor Author

morgoth commented Sep 5, 2017

@tute Can we merge it and have a new version release, please?

@tute
Copy link
Contributor

tute commented Sep 5, 2017

We could also open up the spec version without changing the gem name, as it says in the linked doc: spec.add_dependency('aws-sdk', '>= 2.0', '< 4').

I don't work on paperclip now. Maybe @jyurek can point us in the right direction.

@morgoth
Copy link
Contributor Author

morgoth commented Sep 6, 2017

Version 3.x depends almost on the whole internet ;-) as you can see in https://rubygems.org/gems/aws-sdk-resources
The proper solution, that allows moving forward is to use standalone gem.
There is still fallback to aws-sdk so it won't break existing apps.

@morgoth morgoth mentioned this pull request Sep 8, 2017
Closed
@bitsapien
Copy link

+1

@virgoproz
Copy link

any updates?

@leogiertz
Copy link

@jyurek Would be fantastic if you could take a look at this. 🎩

@geoffharcourt
Copy link
Contributor

geoffharcourt commented Sep 15, 2017

Hi, I had some test failures while I was reviewing, so I'm looking into what might be wrong:

Testing against version 5.1.4

An error occurred while loading ./spec/paperclip/storage/s3_spec.rb.
Failure/Error: (Gem::Version.new(Aws::VERSION) >= Gem::Version.new("2.3.0"))

NameError:
  uninitialized constant Aws::VERSION
# ./spec/support/conditional_filter_helper.rb:3:in `aws_accelerate_available?'
# ./spec/paperclip/storage/s3_spec.rb:285:in `block in <top (required)>'
# ./spec/paperclip/storage/s3_spec.rb:4:in `<top (required)>'

Randomized with seed 785

@geoffharcourt
Copy link
Contributor

geoffharcourt commented Sep 15, 2017

This looks like it's a little more complicated than it appears at first glance. With the new aws-sdk-s3 gem we can drop a bunch of conditional checking for accelerated S3 transport capability (it's now always available with the new gem), but the old gem dropping the Aws::VERSION constant means that we can't reliably check that version number to confirm compatibility or the presence of that capability.

I think we should drop the fallback to the aws-sdk gem and remove the conditional.

@geoffharcourt
Copy link
Contributor

Related: #2484

@geoffharcourt
Copy link
Contributor

Hi @morgoth we're going to nip this in the bud and drop support for the aws-sdk gem and cut a new major release, so please do remove the fallback code.

@morgoth
Copy link
Contributor Author

morgoth commented Sep 15, 2017

@geoffharcourt I removed it. Not sure why tests are now failing (they pass locally).
Also not sure why they were passing before...

@geoffharcourt
Copy link
Contributor

@morgoth I think before the reason was that the aws-sdk gem had a breaking change from the missing constant that was done in a tiny version update (I am guessing they didn't think anyone would depend on that constant). Not sure why the tests are failing, I had a bunch of trouble getting the suite to pass today.

I'll take a look at the Travis failures.

@morgoth
Copy link
Contributor Author

morgoth commented Sep 28, 2017

@geoffharcourt CI failures are not related to this changes and are fixed in https://github.com/thoughtbot/paperclip/pull/2488/files
Can we move it forward, please?

@pjg
Copy link

pjg commented Oct 1, 2017

Could we move this forward, please?

@pjg
Copy link

pjg commented Oct 1, 2017

@morgoth after bundling the version from this PR, I'm presented with the following message:

##################################################
#  NOTE FOR UPGRADING FROM 4.3.0 OR EARLIER       #
##################################################

Paperclip is now compatible with aws-sdk >= 2.0.0.

If you are using S3 storage, aws-sdk >= 2.0.0 requires you to make a few small
changes:

* You must set the `s3_region`
* If you are explicitly setting permissions anywhere, such as in an initializer,
  note that the format of the permissions changed from using an underscore to
  using a hyphen. For example, `:public_read` needs to be changed to
  `public-read`.

For a walkthrough of upgrading from 4 to 5 and aws-sdk >= 2.0 you can watch
http://rubythursday.com/episodes/ruby-snack-27-upgrade-paperclip-and-aws-sdk-in-prep-for-rails-5

I think this needs to be updated too, to mention aws-sdk-s3 v3.

@morgoth
Copy link
Contributor Author

morgoth commented Oct 1, 2017

@pjg yes, but I'm not sure if I should do this here.
@geoffharcourt said that he wants to release a major version, so he will have a better overview what will be included there and might adjust it before release himself.

@morgoth
Copy link
Contributor Author

morgoth commented Oct 6, 2017

I rebased with master, but looks like there is new build error

/home/travis/.rvm/rubies/ruby-2.3.4/bin/ruby -S bundle exec cucumber --format progress
F----------------No such file or directory - getcwd (Errno::ENOENT)

😞

@geoffharcourt
Copy link
Contributor

@morgoth I'm not sure what happened, your prior PR (#2488) passed on Travis and then the same commit failed after it was merged.

@morgoth
Copy link
Contributor Author

morgoth commented Oct 6, 2017

@geoffharcourt Maybe some gem updated in the meantime, thus having a different environment to run the tests as Gemfile.lock is git ignored.

@morgoth
Copy link
Contributor Author

morgoth commented Oct 19, 2017

Rebased with master, so it's green now

@morgoth
Copy link
Contributor Author

morgoth commented Nov 6, 2017

Any news on this one? :-)

@Empact
Copy link

Empact commented Nov 9, 2017

@morgoth Would you be up for adjusting the PR to make it backwards compatible with aws-sdk < 3 as well as aws-sdk-s3? That would make maintenance and upgrading more forgiving by easing discontinuities.

@morgoth
Copy link
Contributor Author

morgoth commented Nov 10, 2017

@Empact It was like this at the beginning but then I was asked to remove backward compatibility in #2481 (comment)

@Empact
Copy link

Empact commented Nov 10, 2017

@morgoth Fair enough if the maintainers want it that way. I generally like to leave backwards compatibility for at least one release so that users can upgrade the dependency in isolation - i.e. they can upgrade Paperclip without needing to also upgrade aws-sdk; but since the dependency is a different library altogether that doesn't really apply here.

@kawikathomas
Copy link

Any idea when this will get merged?

@collimarco
Copy link

Yes, it would be really useful if you could merge this now

@nateemerson
Copy link

@morgoth THANK YOU for your work on this. Looks fantastic!
@geoffharcourt THANK YOU for your work on reviewing and getting this moved through. I greatly appreciate your efforts.

That being said...

Can we please move forward on this? I have a project that is currently stuck in a vulnerable state due to https://nvd.nist.gov/vuln/detail/CVE-2017-0889. I can't upgrade Paperclip due to a newly discovered type of dependency hell enabled by Amazon's bizarre architectural changes from aws-sdk 1.x to 3.x :|

@bmulholland
Copy link

@nateemerson Similar issue here. We upgraded to aws-sdk 2.x which enabled a Paperclip upgrade. Does that work for you in the interim?

@nateemerson
Copy link

@bmulholland No because my project has a feature dependent on a service gem from aws-sdk v3...v1 and v3 could surprisingly coexist due to the architecture overhaul (paperclip depending on v1 of aws-sdk and this other component depending on a specific service lib from v3) which is why the project is in the current state. Unfortunately, v2 and v3 cannot coexist because the architecture is more similar so there are dependency clashes between the current Paperclip version and this other service gem.

@nateemerson
Copy link

nateemerson commented Feb 2, 2018

If anyone else is experiencing the issue I am having, I forked the repo and cut a tag here that you can feel free to use in the short term. @morgoth's code merged cleanly with the v5.2.1 branch. Thanks again for your work @morgoth!

@quentindemetz
Copy link

please merge this

@morgoth morgoth mentioned this pull request Feb 14, 2018
@michal-samluk
Copy link

Is there any chance that this will be merged soon? :)

@zhitongLIU
Copy link

Please merge this, we don't need aws-iot in our projet....

@woodhull
Copy link

woodhull commented Mar 1, 2018

@geoffharcourt 👋 old friend, any chance you could either accept or reject with a reason so I can fix it?

@geoffharcourt
Copy link
Contributor

Hi @woodhull! I'm no longer at thoughtbot, so I'm not in a position to accept or reject.

@bmulholland
Copy link

Looks like it's @sidraval that's maintaining this repo now. Sid, could this be merged?

@sidraval
Copy link
Contributor

sidraval commented Mar 9, 2018

Thanks so much for the PR @morgoth 😄

@sidraval sidraval merged commit 572bba0 into thoughtbot:master Mar 9, 2018
@xtagon
Copy link

xtagon commented Mar 9, 2018

@sidraval Thanks for merging! 👍

yskkin added a commit to yskkin/paperclip that referenced this pull request Mar 16, 2018
@yskkin yskkin mentioned this pull request Mar 16, 2018
sidraval pushed a commit that referenced this pull request May 7, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet