Commit 3a14d340 authored by Stan Hu's avatar Stan Hu

Introduce ci_live_trace_use_fog_attributes feature flag

This commit reverts some of the previous commit to be more amenable for
adding a feature feature flag to avoid introducing a bug in the CI live
trace functionality.
parent 71c61c33
...@@ -4,7 +4,7 @@ module Ci ...@@ -4,7 +4,7 @@ module Ci
module BuildTraceChunks module BuildTraceChunks
class Fog class Fog
def available? def available?
object_store_config.enabled? object_store.enabled
end end
def data(model) def data(model)
...@@ -14,7 +14,15 @@ module Ci ...@@ -14,7 +14,15 @@ module Ci
end end
def set_data(model, new_data) def set_data(model, new_data)
files.create(create_attributes(model, new_data)) if Feature.enabled?(:ci_live_trace_use_fog_attributes)
files.create(create_attributes(model, new_data))
else
# TODO: Support AWS S3 server side encryption
files.create({
key: key(model),
body: new_data
})
end
end end
def append_data(model, new_data, offset) def append_data(model, new_data, offset)
...@@ -67,13 +75,13 @@ module Ci ...@@ -67,13 +75,13 @@ module Ci
def bucket_name def bucket_name
return unless available? return unless available?
object_store_config.bucket object_store.remote_directory
end end
def connection def connection
return unless available? return unless available?
@connection ||= ::Fog::Storage.new(object_store_config.credentials) @connection ||= ::Fog::Storage.new(object_store.connection.to_hash.deep_symbolize_keys)
end end
def fog_directory def fog_directory
...@@ -84,10 +92,14 @@ module Ci ...@@ -84,10 +92,14 @@ module Ci
@files ||= fog_directory.files @files ||= fog_directory.files
end end
def object_store_raw_config def object_store
Gitlab.config.artifacts.object_store Gitlab.config.artifacts.object_store
end end
def object_store_raw_config
object_store
end
def object_store_config def object_store_config
@object_store_config ||= ::ObjectStorage::Config.new(object_store_raw_config) @object_store_config ||= ::ObjectStorage::Config.new(object_store_raw_config)
end end
......
---
name: ci_live_trace_use_fog_attributes
introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/47536
rollout_issue_url: https://gitlab.com/gitlab-org/gitlab/-/issues/285079
milestone: '13.6'
type: development
group: group::testing
default_enabled: false
...@@ -98,6 +98,27 @@ RSpec.describe Ci::BuildTraceChunks::Fog do ...@@ -98,6 +98,27 @@ RSpec.describe Ci::BuildTraceChunks::Fog do
expect(data_store.data(model)).to eq new_data expect(data_store.data(model)).to eq new_data
end end
context 'when ci_live_trace_use_fog_attributes flag is disabled' do
before do
stub_feature_flags(ci_live_trace_use_fog_attributes: false)
end
it 'does not pass along Fog attributes' do
expect_next_instance_of(Fog::AWS::Storage::Files) do |files|
expect(files).to receive(:create).with(
key: anything,
body: new_data
).and_call_original
end
expect(data_store.data(model)).to be_nil
data_store.set_data(model, new_data)
expect(data_store.data(model)).to eq new_data
end
end
end end
end end
end end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment