Add ReleaseTools::DockerHub::Verifier class
What does this MR do and why?
Describe in detail what your merge request does and why.
Content
- This is a split from !3177 (merged)
- Add
ReleaseTools::DockerHub::Verifier
class and its specs. This class checks if both the CE and EE images exist on DockerHub. - Remove
active_version
method (comparing to the implementation in !3177 (merged)) because of two reasons:- Let the class that use
ReleaseTools::DockerHub::Verifier
decides which version to check -
active_version
does not fit here, since it usesGitlabReleases.active_version
, which returns only the minor version (e.g. 17.1), instead of the whole patch version (e.g. 17.1.0) (ref)
- Let the class that use
Note that:
- This class utilizes !3141 (merged) and !3211 (merged)
- Both monthly ( gitlab-com/gl-infra/delivery#20194 (closed)) and patch releases ( gitlab-com/gl-infra/delivery#20237 (closed)) can use this class. Their implementations will be done separately.
Testing
- Check an existing version
pry(main)> ReleaseTools::DockerHub::Verifier.new(release_type: :patch, version: '16.10.1').execute
2024-06-21 14:04:47.466092 I ReleaseTools::DockerHub::Verifier -- Checking Docker Hub tags with version number -- {:release_type=>:patch, :version=>"16.10.1"}
2024-06-21 14:04:48.579492 I ReleaseTools::DockerHub::Verifier -- Tags exist on Docker Hub
2024-06-21 14:04:48.579513 I ReleaseTools::Slack::ReleaseJobEndNotifier -- Posting slack message -- {:job_type=>"Verify docker tags", :status=>:success}
=> {"ok"=>true,
"channel"=>"C047XHV7PQQ",
"ts"=>"1718971488.954709",
"message"=>
{"user"=>"U038VKHEWDN",
"type"=>"message",
"ts"=>"1718971488.954709",
"bot_id"=>"B037Z751MNJ",
"app_id"=>"A0385PGTMSQ",
"text"=>"Verify docker tags job successfully executed - <http://test.com/>",
"team"=>"T02592416",
"bot_profile"=>
{"id"=>"B037Z751MNJ",
"app_id"=>"A0385PGTMSQ",
"name"=>"Release-Tools",
"icons"=>
{"image_36"=>"https://avatars.slack-edge.com/2022-04-07/3381895602368_6f294b6e6a7bde5dcd73_36.png",
"image_48"=>"https://avatars.slack-edge.com/2022-04-07/3381895602368_6f294b6e6a7bde5dcd73_48.png",
"image_72"=>"https://avatars.slack-edge.com/2022-04-07/3381895602368_6f294b6e6a7bde5dcd73_72.png"},
"deleted"=>false,
"updated"=>1649332946,
"team_id"=>"T02592416"},
"blocks"=>
[{"type"=>"section", "block_id"=>"Pe8Gb", "text"=>{"type"=>"mrkdwn", "text"=>":security-tanuki: :ci_passing: *Verify docker tags job <http://test.com/|successfully> executed*", "verbatim"=>false}},
{"type"=>"section", "block_id"=>"vCUmT", "text"=>{"type"=>"mrkdwn", "text"=>"GitLab version: 16.10.1", "verbatim"=>false}},
{"type"=>"context", "block_id"=>"8MKbt", "elements"=>[{"type"=>"mrkdwn", "text"=>":clock1: 2024-06-21 12:04 UTC", "verbatim"=>false}]}]}}
Slack notification:
- Check a non-existing version
[8] pry(main)> ReleaseTools::DockerHub::Verifier.new(release_type: :patch, version: '16.10.100').execute
2024-06-21 14:05:22.908650 I ReleaseTools::DockerHub::Verifier -- Checking Docker Hub tags with version number -- {:release_type=>:patch, :version=>"16.10.100"}
2024-06-21 14:05:23.637930 F ReleaseTools::DockerHub::Client -- Request to docker hub failed -- 404 Not Found
2024-06-21 14:05:23.638576 F ReleaseTools::DockerHub::Verifier -- The tags don't exist on Docker Hub yet, retry this job. If the failure persists, then check the publish job and make sure images are published on Docker Hub"
-- {:error=>#<RuntimeError: Tag 16.10.100-ee.0 does not exist on Docker Hub>}
2024-06-21 14:05:23.638630 I ReleaseTools::Slack::ReleaseJobEndNotifier -- Posting slack message -- {:job_type=>"Verify docker tags", :status=>:failed}
RuntimeError: Tag 16.10.100-ee.0 does not exist on Docker Hub
from /Users/dattang/git/gitlab-org/release-tools/lib/release_tools/docker_hub/verifier.rb:52:in `check_tag'
Slack notification:
Edited by Dat Tang