Skip to content
This repository was archived by the owner on Jun 2, 2021. It is now read-only.

Commit d4d891c

Browse files
MerricdeLauneyJenGoldstrich
authored andcommitted
Do not populate resource cache when resource_matching is disabled
Previously the `resource_matching` feature flag would only guard against returning resource matches to users who queried the `/v3/resource_matches` endpoint. However, it would not prevent packages from being uploaded to the resource cache, causing blobstores to bloat unnecessarily. This commit updates the behavior and only uploads package bits to the resource cache blobstore when the feature flag is enabled. [#172640608](https://www.pivotaltracker.com/story/show/172640608)
1 parent 5780ec6 commit d4d891c

2 files changed

Lines changed: 13 additions & 1 deletion

File tree

lib/cloud_controller/packager/shared_bits_packer.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ def match_resources_and_validate_package(root_path, uploaded_package_zip, cached
5555
if package_zip_exists?(uploaded_package_zip)
5656
copy_uploaded_package(uploaded_package_zip, app_packager)
5757
validate_size!(app_packager)
58-
populate_resource_cache(app_packager, app_contents_path)
58+
populate_resource_cache(app_packager, app_contents_path) unless VCAP::CloudController::FeatureFlag.disabled?(:resource_matching)
5959
end
6060

6161
append_matched_resources(app_packager, cached_files_fingerprints, root_path)

spec/unit/lib/cloud_controller/packager/local_bits_packer_spec.rb

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,18 @@ module CloudController::Packager
176176
packer.send_package_to_blobstore(blobstore_key, uploaded_files_path, cached_files_fingerprints)
177177
end
178178

179+
context 'when the resource_matching feature flag is disabled' do
180+
before do
181+
VCAP::CloudController::FeatureFlag.make(name: 'resource_matching', enabled: false)
182+
end
183+
184+
it 'does not upload any app bits to the app bit cache' do
185+
packer.send_package_to_blobstore(blobstore_key, uploaded_files_path, cached_files_fingerprints)
186+
sha_of_bye_file_in_good_zip = 'ee9e51458f4642f48efe956962058245ee7127b1'
187+
expect(global_app_bits_cache.exists?(sha_of_bye_file_in_good_zip)).to be false
188+
end
189+
end
190+
179191
context 'when there is an unreadable directory in the zip' do
180192
let(:input_zip) { File.join(Paths::FIXTURES, 'app_packager_zips', 'unreadable_dir.zip') }
181193
let(:input_zip_file_path) { File.join(local_tmp_dir, 'unreadable_dir.zip') }

0 commit comments

Comments
 (0)