From 383a69fedacc0a10b62ca812cea9342cbe8bb778 Mon Sep 17 00:00:00 2001 From: Tom Viehman Date: Tue, 25 Jan 2022 23:42:43 +0000 Subject: [PATCH] Fix test failures caused by fog-aws upgrade - Bumps fog-core to 2.1.2 instead of 2.2.4 because the latest version of fog-google is incompatible with fog-core > 2.1.0 - Pin fog-google to 1.7.1 based [a recommendation](https://github.com/fog/fog-google/pull/422#issuecomment-423393039) from one of the fog-google maintainers. - Temporarily disables fog deprecation warnings when loading in the various fog gems because several of them haven't updated all their modules/classes to use the new Fog:::: structure. [#180880562] Co-authored-by: Tom Viehman Co-authored-by: Seth Boyles --- Gemfile | 3 ++- Gemfile.lock | 27 ++++++++++--------- .../blobstore/fog/fog_client.rb | 4 +-- .../blobstore/fog/providers.rb | 13 +++++++++ .../blobstore/fog/fog_client_spec.rb | 6 ++--- 5 files changed, 34 insertions(+), 19 deletions(-) diff --git a/Gemfile b/Gemfile index d670188b192..b39fa9a5d7a 100644 --- a/Gemfile +++ b/Gemfile @@ -58,9 +58,10 @@ gem 'bits_service_client', '~> 3.3', '>= 3.3.0' gem 'fog-aliyun' gem 'fog-aws' gem 'fog-azure-rm', git: 'https://github.com/fog/fog-azure-rm.git', branch: 'fog-arm-cf' -gem 'fog-google' +gem 'fog-google', '~> 1.7.1' gem 'fog-local' gem 'fog-openstack' +gem 'fog-core', '~> 2.1.2' gem 'cf-uaa-lib', '~> 4.0.0' gem 'vcap-concurrency', git: 'https://github.com/cloudfoundry/vcap-concurrency.git', ref: '2a5b0179' diff --git a/Gemfile.lock b/Gemfile.lock index a7eed47cc83..b3f0148338f 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -132,8 +132,7 @@ GEM debase (0.2.5.beta2) debase-ruby_core_source (>= 0.10.12) debase-ruby_core_source (0.10.12) - declarative (0.0.10) - declarative-option (0.1.0) + declarative (0.0.20) delayed_job (4.1.9) activesupport (>= 3.0, < 6.2) diff-lcs (1.5.0) @@ -176,9 +175,9 @@ GEM fog-json (~> 1.1) fog-xml (~> 0.1) ipaddress (~> 0.8) - fog-core (2.2.4) + fog-core (2.1.2) builder - excon (~> 0.71) + excon (~> 0.58) formatador (~> 0.2) mime-types fog-google (1.7.1) @@ -259,7 +258,7 @@ GEM json_pure (2.6.1) jsonpath (1.1.0) multi_json - jwt (2.2.1) + jwt (2.3.0) kramdown (2.3.1) rexml kramdown-parser-gfm (1.1.0) @@ -283,7 +282,7 @@ GEM nokogiri (>= 1.5.9) machinist (1.0.6) membrane (1.1.0) - memoist (0.16.0) + memoist (0.16.2) method_source (1.0.0) middleware (0.1.0) mime-types (3.4.1) @@ -320,7 +319,7 @@ GEM nokogiri (1.13.1-x86_64-linux) racc (~> 1.4) oj (3.13.11) - os (1.0.1) + os (1.1.4) palm_civet (1.1.0) parallel (1.21.0) parallel_tests (3.7.3) @@ -365,9 +364,9 @@ GEM ffi (~> 1.0) recursive-open-struct (1.1.3) regexp_parser (2.2.0) - representable (3.0.4) + representable (3.1.1) declarative (< 0.1.0) - declarative-option (< 0.2.0) + trailblazer-option (>= 0.1.1, < 0.2.0) uber (< 0.2.0) rest-client (2.1.0) http-accept (>= 1.7.0, < 2.0) @@ -439,9 +438,9 @@ GEM pg (>= 0.18.0, != 1.2.0) sequel (>= 4.38.0) sexp_processor (4.7.0) - signet (0.11.0) - addressable (~> 2.3) - faraday (~> 0.9) + signet (0.16.0) + addressable (~> 2.8) + faraday (>= 0.17.3, < 2.0) jwt (>= 1.5, < 3.0) multi_json (~> 1.10) simplecov (0.13.0) @@ -496,6 +495,7 @@ GEM tilt (2.0.10) timecop (0.9.4) timeliness (0.4.4) + trailblazer-option (0.1.2) tzinfo (2.0.4) concurrent-ruby (~> 1.0) uber (0.1.0) @@ -546,7 +546,8 @@ DEPENDENCIES fog-aliyun fog-aws fog-azure-rm! - fog-google + fog-core (~> 2.1.2) + fog-google (~> 1.7.1) fog-local fog-openstack googleapis-common-protos (>= 1.3.12) diff --git a/lib/cloud_controller/blobstore/fog/fog_client.rb b/lib/cloud_controller/blobstore/fog/fog_client.rb index 894ce624f81..d2fdfe04e86 100644 --- a/lib/cloud_controller/blobstore/fog/fog_client.rb +++ b/lib/cloud_controller/blobstore/fog/fog_client.rb @@ -114,7 +114,7 @@ def blob(key) end def files_for(prefix, _ignored_directory_prefixes=[]) - if connection.is_a? Fog::Storage::Local::Real + if connection.is_a? Fog::Local::Storage::Real directory = connection.directories.get(File.join(dir.key, prefix || '')) directory ? directory.files : [] else @@ -126,7 +126,7 @@ def ensure_bucket_exists return if local? options = { max_keys: 1 } - options['limit'] = 1 if connection.service == Fog::Storage::OpenStack + options['limit'] = 1 if connection.service == Fog::OpenStack::Storage connection.directories.get(@directory_key, options) || connection.directories.create(key: @directory_key, public: false) end diff --git a/lib/cloud_controller/blobstore/fog/providers.rb b/lib/cloud_controller/blobstore/fog/providers.rb index ad21e49b0ad..a6b23fecd12 100644 --- a/lib/cloud_controller/blobstore/fog/providers.rb +++ b/lib/cloud_controller/blobstore/fog/providers.rb @@ -1,6 +1,19 @@ +require 'fog/core' + +# This can be removed once fog-google fixes +# https://github.com/fog/fog-google/issues/421, which will allow us to upgrade +# fog-core to 2.2.4. +original = Fog::Logger[:deprecation] +Fog::Logger[:deprecation] = nil + require 'fog/aliyun' +# Hack until https://github.com/fog/fog-aliyun/pull/155 is merged and released +Fog::Aliyun::Compute = Fog::Compute::Aliyun + require 'fog/aws' require 'fog/local' require 'fog/google' require 'fog/azurerm' require 'fog/openstack' + +Fog::Logger[:deprecation] = original diff --git a/spec/unit/lib/cloud_controller/blobstore/fog/fog_client_spec.rb b/spec/unit/lib/cloud_controller/blobstore/fog/fog_client_spec.rb index 82272304887..82398dbd4af 100644 --- a/spec/unit/lib/cloud_controller/blobstore/fog/fog_client_spec.rb +++ b/spec/unit/lib/cloud_controller/blobstore/fog/fog_client_spec.rb @@ -729,21 +729,21 @@ def upload_tmpfile(client, key='abcdef') end it 'gets the bucket' do - expect_any_instance_of(Fog::Storage::AWS::Directories).to receive(:get).with(directory_key, max_keys: 1) + expect_any_instance_of(Fog::AWS::Storage::Directories).to receive(:get).with(directory_key, max_keys: 1) subject.ensure_bucket_exists end context 'the bucket exists' do it 'does not create the bucket' do subject.ensure_bucket_exists - expect_any_instance_of(Fog::Storage::AWS::Directories).not_to receive(:create).with(key: directory_key, public: false) + expect_any_instance_of(Fog::AWS::Storage::Directories).not_to receive(:create).with(key: directory_key, public: false) subject.ensure_bucket_exists end end context 'the bucket does not exist' do it 'creates the bucket' do - expect_any_instance_of(Fog::Storage::AWS::Directories).to receive(:create).with(key: directory_key, public: false) + expect_any_instance_of(Fog::AWS::Storage::Directories).to receive(:create).with(key: directory_key, public: false) subject.ensure_bucket_exists end end