Added RPM package push and pull event tracking
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
- Have GDK ready with snowplow micro.
- 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
- 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"}%
- The
404 Not Found
is really expected as both endpoints are not implemented (yet). - Time to check the snowplow dashboards:
- 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.
- 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"}%
- Time to check the snowplow dashboards:
- 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.
-
I have evaluated the MR acceptance checklist for this MR.
Edited by David Fernandez