Accept and log missing release tag when sync maven metadata
Context
We have the maven sync worker in place in order to sync maven-metadata.xml
which is a kind of manifest file for maven client.
Currently, the maven sync worker gets triggered upon package deletion.
It was noticed in the logs that maven-metadata.xml
file might not have expected release
tag.
What does this MR do and why?
- Suppress the error and accept the case when
release
tag is missing. - Log a message when
release
tag is missing.
How to set up and validate locally
-
Create two packages
def fixture_file_upload(*args, **kwargs) Rack::Test::UploadedFile.new(*args, **kwargs) end ["3.0", nil].each do |version| FactoryBot.create(:maven_package, project: Project.first, name: "my/company/app/my-app", version: version) end
-
Prepare necessary data
versionless_package = Packages::Package.with_version(nil).last metadata_content = Nokogiri::XML::Builder.new do |xml| xml.metadata do xml.versioning do xml.lastUpdated("20210113130531") xml.versions do xml.version("1.1-SNAPSHOT") end end end end.to_xml
Important:
metadata_content
shouldn't containrelease
tag. -
Trigger the service
Packages::Maven::Metadata::CreateVersionsXmlService.new(metadata_content: metadata_content, package: versionless_package).execute
-
Check result from the service executed in the previous step
The result should be similar to
=> #<ServiceResponse:0x000000012a307160 @http_status=:ok, @message=nil, @payload= {:changes_exist=>true, :empty_versions=>false, :metadata_content=> "<?xml version=\"1.0\"?>\n<metadata>\n <versioning>\n <lastUpdated>20221018155045</lastUpdated>\n <versions>\n <version>1.1- SNAPSHOT</version>\n <version>3.0</version>\n </versions>\n </versioning>\n</metadata>\n"}, @reason=nil, @status=:success>
Important:
-
http_status
should be:ok
-
status
should be:success
-
payload[:metadata_content]
should contain<version>3.0</version>
-
-
Check logs
cat log/application_json.log | grep "A malformed metadata file has been encountered"
It should return a log entity similar to
{"severity":"WARN","time":"2022-10-18T15:50:45.356Z","correlation_id":null,"message":"A malformed metadata file has been encountered","reason":"Missing release tag","project_id":1,"package_id":71}
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.
Related to #324801 (closed)