Fix ExternallyStoredField with file_store = 2 (REMOTE)
What does this MR do and why?
Fix ExternallyStoredField with file_store = 2 (REMOTE).
Because we're avoiding CarrierWave's on_mount machinery to avoid wasted databased columns, we need to redo some bits carefully ourselves.
References
Closes Agent plan storage doesn't work when file_store... (#600373 - closed).
How to set up and validate locally
We need to use object storage locally to test, so we'll enable it in our GDK. Disable after if you don't want to keep running MinIO.
gdk config set object_store.enabled true && gdk reconfigure && gdk restart- GDK won't create the
agent-plan-contentbucket for you automatically (yet: #600508 (closed)), so create it manually. Go to http://gdk.test:9002/ (loginminio/gdk-minio) and create a new bucket calledagent-plan-content; no other special adjustments necessary. - GDK also doesn't know how to template the config for it, so now we manually edit
config/gitlab.ymland add a block like this (under theproduction:block):agent_plan_content: object_store: enabled: true direct_upload: true remote_directory: agent-plan-content connection: provider: AWS aws_access_key_id: minio aws_secret_access_key: gdk-minio region: gdk endpoint: 'http://gdk.test:9000' path_style: true - Validate with
rails runneror atrails console:user = User.first project = Project.first wi = WorkItems::CreateService.new( container: project, current_user: user, params: { title: 'agent plan host', work_item_type: WorkItems::TypesFramework::Provider.new.find_by_base_type(:issue) } ).execute[:work_item] ap = WorkItems::AgentPlan.create!(work_item: wi, content: 'hello from remote') puts "file_store after save: #{ap.reload[:file_store]} (expect 2)" puts "content after reload: #{ap.content.inspect} (expect 'hello from remote')" - You should see:
You can also look in the MinIO console and see the created object!
file_store after save: 2 (expect 2) content after reload: "hello from remote" (expect 'hello from remote')

MR acceptance checklist
Evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.
Edited by Asherah Connor
