Create WorkItem::AgentPlan and its table, with object store for blobs

What does this MR do and why?

Create WorkItem::AgentPlan and its table; use CarrierWave to store the actual work plan content and rendered HTML.

Follow-up MR is at Add agent plan WI widget; expose through GraphQL (!232348 - merged).

  • Added the GitLab::ExternallyStoredField concern, which can be used to store field(s) in CarrierWave on save (after_commit) and retrieve them on access.
    • This concern isn't tied into Markdown at all, and hopefully can be helpful to other teams in need of object storage!
  • Taught CacheMarkdownField's cache_markdown_field what storage: :external means.
    • Causes GitLab::MarkdownCache::ExternalStorage::Extension to be mixed in.
    • That in turn brings in GitLab::ExternallyStoredField, declares field and "#{field}_html" as belonging to external storage, and intercepts CacheMarkdownField callbacks to handle externally-stored fields while letting everything else fall through.
  • Followed WorkItems::Description for the model's set_namespace behaviour.
    • Did the same for the factory's after(:build) work_item init.
  • WorkItems::AgentPlanContentUploader uses hashed paths like most other uploaders so we don't put every single object under the same prefix.
  • Basic assoc/validation/Markdown rendering specs on the model itself.
  • I haven't included a cleanup worker to catch orphaned blobs yet; this MR is already getting unwieldy large.

Tagging as feature flag since this functionality, while currently totally unused, will in future be used exclusively by feature flagged code.

How to set up and validate locally

There's only a model, so you could check out the code and see if the migration runs, but CI will do that anyway! You could also create some work plans associated with any work items (manually, at the console; nothing's wired up on the frontend yet), check that the Markdown is rendered, saved locally, and retrieved!

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

Merge request reports

Loading