Skip to content

Draft: Update maven sync worker to accept no user id

David Fernandez requested to merge 342437-sync-maven-metadata-without-user into master

🌳 Context

In Sync the maven metadata file upon package deletion (!55207 - merged), we fixed a typebug around maven packages for the Package Registry.

Long story short, when a maven package is uploaded, an additional file is uploaded: maven-metadata.xml. This file contains the list of all available versions for a given package. In a sense, this is the file used by $ mvn or $ gradle to discover the state (eg. which packages + versions) are available within a registry.

The bug was that when a user destroy a package using the UI or the API, that file was not updated. Package Manager clients would still believe that those versions existed 💥.

We fixed the bug by enqueuing a job (Packages::Maven::Metadata::SyncWorker) that will list all the versions known by the registry and update the file. Among other parameters, this job accepts a user id.

That's all correctly working. Now, we are working on adding a service that will delete packages in bulk. This service will be used by APIs. There, we do have a current user that we can pass to the background job when enqueued. However, this service is going to be used by cleanup policies for packages. There the context is that a background job will remove packages automatically for cleanup purposes. For that usage, we don't have a current_user. As such, we're going to use the sync job for maven packages without a user.

This MRs updates the sync maven package so that the user id is optional.

🔍 What does this MR do and why?

  • Make the user (id) optional in the maven package sync worker class and service.
  • Update the related specs.

📺 Screenshots or screen recordings

How to set up and validate locally

Numbered steps to set up and validate the change are strongly suggested.

🚥 MR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

Related to #342437 (closed)

Edited by David Fernandez

Merge request reports