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

Support Uniform Bucket Level Access on GCP #3454

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions config/cloud_controller.yml
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,7 @@ resource_pool:
blobstore_timeout: 5
provider: "Local"
fog_aws_storage_options: {}
fog_gcp_storage_options: {}

packages:
app_package_directory_key: "cc-packages"
Expand All @@ -185,6 +186,7 @@ packages:
blobstore_timeout: 5
provider: "Local"
fog_aws_storage_options: {}
fog_gcp_storage_options: {}

droplets:
droplet_directory_key: cc-droplets
Expand All @@ -193,13 +195,15 @@ droplets:
blobstore_timeout: 5
provider: "Local"
fog_aws_storage_options: {}
fog_gcp_storage_options: {}

buildpacks:
buildpack_directory_key: cc-buildpacks
fog_connection:
blobstore_timeout: 5
provider: "Local"
fog_aws_storage_options: {}
fog_gcp_storage_options: {}

registry_buddy:
host: "127.0.0.1"
Expand Down
2 changes: 1 addition & 1 deletion lib/cloud_controller/blobstore/client_provider.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def provide_fog(options, directory_key, root_dir)
root_dir: root_dir,
min_size: options[:minimum_size],
max_size: options[:maximum_size],
storage_options: options[:fog_aws_storage_options]
storage_options: (options[:fog_aws_storage_options].presence || options[:fog_gcp_storage_options])
)

logger = Steno.logger('cc.blobstore')
Expand Down
13 changes: 8 additions & 5 deletions lib/cloud_controller/blobstore/fog/fog_client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -136,12 +136,15 @@ def files
end

def formatted_storage_options
return {} unless @storage_options && @storage_options[:encryption]
return {} unless @storage_options && !(@storage_options[:encryption].nil? && @storage_options[:uniform].nil?)

opts = @storage_options.dup
encrypt_opt = opts.delete(:encryption)
opts['x-amz-server-side-encryption'] = encrypt_opt
opts
if @storage_options[:encryption]
opts = @storage_options.dup
opts['x-amz-server-side-encryption'] = opts.delete(:encryption)
return opts
end

@storage_options
end

def delete_file(file)
Expand Down
10 changes: 7 additions & 3 deletions lib/cloud_controller/config_schemas/base/api_schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -144,13 +144,15 @@ class ApiSchema < VCAP::Config
minimum_size: Integer,
resource_directory_key: String,
fog_connection: Hash,
fog_aws_storage_options: Hash
fog_aws_storage_options: Hash,
fog_gcp_storage_options: Hash
},

buildpacks: {
buildpack_directory_key: String,
fog_connection: Hash,
fog_aws_storage_options: Hash
fog_aws_storage_options: Hash,
fog_gcp_storage_options: Hash
},

packages: {
Expand All @@ -159,6 +161,7 @@ class ApiSchema < VCAP::Config
app_package_directory_key: String,
fog_connection: Hash,
fog_aws_storage_options: Hash,
fog_gcp_storage_options: Hash,
optional(:image_registry) => {
base_path: String
}
Expand All @@ -168,7 +171,8 @@ class ApiSchema < VCAP::Config
droplet_directory_key: String,
max_staged_droplets_stored: Integer,
fog_connection: Hash,
fog_aws_storage_options: Hash
fog_aws_storage_options: Hash,
fog_gcp_storage_options: Hash
},

optional(:registry_buddy) => {
Expand Down
10 changes: 7 additions & 3 deletions lib/cloud_controller/config_schemas/base/clock_schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -77,20 +77,23 @@ class ClockSchema < VCAP::Config
minimum_size: Integer,
resource_directory_key: String,
fog_connection: Hash,
fog_aws_storage_options: Hash
fog_aws_storage_options: Hash,
fog_gcp_storage_options: Hash
},

buildpacks: {
buildpack_directory_key: String,
fog_connection: Hash,
fog_aws_storage_options: Hash
fog_aws_storage_options: Hash,
fog_gcp_storage_options: Hash
},

packages: {
max_package_size: Integer,
app_package_directory_key: String,
fog_connection: Hash,
fog_aws_storage_options: Hash,
fog_gcp_storage_options: Hash,
optional(:image_registry) => {
base_path: String
}
Expand All @@ -99,7 +102,8 @@ class ClockSchema < VCAP::Config
droplets: {
droplet_directory_key: String,
fog_connection: Hash,
fog_aws_storage_options: Hash
fog_aws_storage_options: Hash,
fog_gcp_storage_options: Hash
},

db_encryption_key: enum(String, NilClass),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,20 +80,23 @@ class DeploymentUpdaterSchema < VCAP::Config
minimum_size: Integer,
resource_directory_key: String,
fog_connection: Hash,
fog_aws_storage_options: Hash
fog_aws_storage_options: Hash,
fog_gcp_storage_options: Hash
},

buildpacks: {
buildpack_directory_key: String,
fog_connection: Hash,
fog_aws_storage_options: Hash
fog_aws_storage_options: Hash,
fog_gcp_storage_options: Hash
},

packages: {
max_package_size: Integer,
app_package_directory_key: String,
fog_connection: Hash,
fog_aws_storage_options: Hash,
fog_gcp_storage_options: Hash,
optional(:image_registry) => {
base_path: String
}
Expand All @@ -102,7 +105,8 @@ class DeploymentUpdaterSchema < VCAP::Config
droplets: {
droplet_directory_key: String,
fog_connection: Hash,
fog_aws_storage_options: Hash
fog_aws_storage_options: Hash,
fog_gcp_storage_options: Hash
},

stacks_file: String,
Expand Down
10 changes: 7 additions & 3 deletions lib/cloud_controller/config_schemas/base/worker_schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -68,20 +68,23 @@ class WorkerSchema < VCAP::Config
minimum_size: Integer,
resource_directory_key: String,
fog_connection: Hash,
fog_aws_storage_options: Hash
fog_aws_storage_options: Hash,
fog_gcp_storage_options: Hash
},

buildpacks: {
buildpack_directory_key: String,
fog_connection: Hash,
fog_aws_storage_options: Hash
fog_aws_storage_options: Hash,
fog_gcp_storage_options: Hash
},

packages: {
max_package_size: Integer,
app_package_directory_key: String,
fog_connection: Hash,
fog_aws_storage_options: Hash,
fog_gcp_storage_options: Hash,
optional(:image_registry) => {
base_path: String
}
Expand All @@ -90,7 +93,8 @@ class WorkerSchema < VCAP::Config
droplets: {
droplet_directory_key: String,
fog_connection: Hash,
fog_aws_storage_options: Hash
fog_aws_storage_options: Hash,
fog_gcp_storage_options: Hash
},

optional(:registry_buddy) => {
Expand Down
8 changes: 8 additions & 0 deletions spec/fixtures/config/port_8181_config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -140,18 +140,22 @@ resource_pool:
maximum_size: 42
minimum_size: 1
fog_aws_storage_options: {}
fog_gcp_storage_options: {}

buildpacks:
fog_aws_storage_options: {}
fog_gcp_storage_options: {}

packages:
max_package_size: 42
max_valid_packages_stored: 42
fog_aws_storage_options: {}
fog_gcp_storage_options: {}

droplets:
max_staged_droplets_stored: 42
fog_aws_storage_options: {}
fog_gcp_storage_options: {}

request_timeout_in_seconds: 600
skip_cert_verify: true
Expand All @@ -175,24 +179,28 @@ resource_pool:
minimum_size: 1
fog_connection: {}
fog_aws_storage_options: {}
fog_gcp_storage_options: {}

buildpacks:
buildpack_directory_key: ''
fog_connection: {}
fog_aws_storage_options: {}
fog_gcp_storage_options: {}

packages:
app_package_directory_key: ''
max_package_size: 42
max_valid_packages_stored: 42
fog_connection: {}
fog_aws_storage_options: {}
fog_gcp_storage_options: {}

droplets:
droplet_directory_key: ''
max_staged_droplets_stored: 42
fog_connection: {}
fog_aws_storage_options: {}
fog_gcp_storage_options: {}



Expand Down
18 changes: 18 additions & 0 deletions spec/unit/lib/cloud_controller/blobstore/client_provider_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,24 @@ module Blobstore
end
end

context 'when a gcp uniform option is requested' do
before do
options.merge!(fog_gcp_storage_options: { uniform: false })
end

it 'passes the specified uniform option to the fog client' do
allow(FogClient).to receive(:new).and_call_original
ClientProvider.provide(options: options, directory_key: 'key')
expect(FogClient).to have_received(:new).with(connection_config: anything,
directory_key: anything,
cdn: anything,
root_dir: anything,
min_size: anything,
max_size: anything,
storage_options: { uniform: false })
end
end

context 'when a cdn is requested in the options' do
before do
options.merge!(cdn: { uri: 'http://cdn.com' })
Expand Down
Loading