Skip to content

Added RPM package push and pull event tracking

Maksym Shabelnyk requested to merge 371808-rpm-push-pull-event-tracking into master

What does this MR do and why?

Added push/pull event tracking for RPM packages, epic &5128

Screenshots or screen recordings

Screenshots are required for UI changes, and strongly recommended for all other merge requests.

How to set up and validate locally

  1. Have GDK ready with snowplow micro.
  2. Enable the feature flag in a rails console:
    Feature.enable(:rpm_packages)

Setup is ready. We still need a project, a user and a PAT.

Pull

  1. Interact with the pull package endpoint
    $ curl --user <username>:<pat> "http://gdk.test:8000/api/v4/projects/<project id>/packages/rpm/12/bananas.txt"
    {"message":"404 Not Found"}%  
  2. The 404 Not Found is really expected as both endpoints are not implemented (yet).
  3. Time to check the snowplow dashboards:
  4. We can see both the event

Push

For the upload, we need some changes are we're not going to really upload a file and this endpoint is handled by workhorse first.

Needed changes to disable the workhorse accelerated upload
diff --git a/lib/api/rpm_project_packages.rb b/lib/api/rpm_project_packages.rb
index 1eb7361d3564..851b1f4411b3 100644
--- a/lib/api/rpm_project_packages.rb
+++ b/lib/api/rpm_project_packages.rb
@@ -53,9 +53,9 @@ class RpmProjectPackages < ::API::Base
         post do
           authorize_create_package!(authorized_user_project)
 
-          if authorized_user_project.actual_limits.exceeded?(:rpm_max_file_size, params[:file].size)
-            bad_request!('File is too large')
-          end
+          # if authorized_user_project.actual_limits.exceeded?(:rpm_max_file_size, params[:file].size)
+          #   bad_request!('File is too large')
+          # end
 
           track_package_event(
             'push_package',
diff --git a/workhorse/internal/upstream/routes.go b/workhorse/internal/upstream/routes.go
index 08e3ef8c9f10..a4b5e19efb57 100644
--- a/workhorse/internal/upstream/routes.go
+++ b/workhorse/internal/upstream/routes.go
@@ -288,7 +288,7 @@ func configureRoutes(u *upstream) {
                u.route("PUT", apiProjectPattern+`/packages/debian/`, requestBodyUploader),
 
                // RPM Artifact Repository
-               u.route("POST", apiProjectPattern+`/packages/rpm/`, requestBodyUploader),
+               // u.route("POST", apiProjectPattern+`/packages/rpm/`, requestBodyUploader),
 
                // Gem Artifact Repository
                u.route("POST", apiProjectPattern+`/packages/rubygems/`, requestBodyUploader),

Once the above changes, don't forget to compile and restart workhorse. In the gitlab folder:

$ cd workhorse
$ make
$ gdk restart gitlab-workhorse

Alright, everything is ready.

  1. Interact with the push package endpoint:
    $ curl --request POST --user <username>:<pat> "http://gdk.test:8000/api/v4/projects/<project id>/packages/rpm" 
    {"message":"404 Not Found"}%  
  2. Time to check the snowplow dashboards:
  3. We can see both the event

MR acceptance checklist

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

Edited by David Fernandez

Merge request reports