Skip to content

Add ReleaseTools::DockerHub::Verifier class

Dat Tang requested to merge dattang/add-check-docker-tags into master

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 uses GitlabReleases.active_version, which returns only the minor version (e.g. 17.1), instead of the whole patch version (e.g. 17.1.0) (ref)

Note that:

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:

Screenshot 2024-06-21 at 14.06.17.png

  • 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:

Screenshot 2024-06-21 at 14.06.29.png

Edited by Dat Tang

Merge request reports