Skip to content

Commit fac8eab

Browse files
committed
Switch from Docker Registry v1 API to v2 API in CI
On September 5, 2022 Docker Hub deprecated and disabled their Docker Registry v1 API endpoint. We used this endpoint as a simple way to fetch a list of Scylla OSS and Scylla Enterprise tags in order to determine the latest versions of released Scylla images to test against. This change caused our CI to fail to test Scylla versions as it was unable to determine the latest release version numbers. To solve this problem, ci/version_fetch.py script is updated to use the Docker Registry v2 API endpoint. The new API is paginated, necessitating performing multiple HTTP requests in fetch_docker_hub_tags() function.
1 parent d184387 commit fac8eab

File tree

1 file changed

+29
-14
lines changed

1 file changed

+29
-14
lines changed

ci/version_fetch.py

Lines changed: 29 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,14 @@
1818
from itertools import groupby, islice
1919
import sys
2020

21-
DOCKER_HUB_TAGS_ENDPOINT = 'https://registry.hub.docker.com/v1/repositories/%s/tags'
22-
DOCKER_HUB_SCYLLA_ORG = 'scylladb/'
21+
DOCKER_HUB_TAGS_ENDPOINT = 'https://hub.docker.com/v2/namespaces/%s/repositories/%s/tags?page_size=1000'
22+
DOCKER_HUB_SCYLLA_NAMESPACE = 'scylladb'
2323

24-
SCYLLA_OSS = DOCKER_HUB_SCYLLA_ORG + 'scylla'
24+
SCYLLA_OSS = (DOCKER_HUB_SCYLLA_NAMESPACE, 'scylla')
2525
SCYLLA_OSS_RELEASED_VERSION_REGEX = re.compile(r'(\d+)\.(\d+)\.(\d+)')
2626
SCYLLA_OSS_RC_VERSION_REGEX = re.compile(r'(\d+)\.(\d+)\.rc(\d+)')
2727

28-
SCYLLA_ENTERPRISE = DOCKER_HUB_SCYLLA_ORG + 'scylla-enterprise'
28+
SCYLLA_ENTERPRISE = (DOCKER_HUB_SCYLLA_NAMESPACE, 'scylla-enterprise')
2929
SCYLLA_ENTERPRISE_RELEASED_VERSION_REGEX = re.compile(r'(\d{4})\.(\d+)\.(\d+)')
3030
SCYLLA_ENTERPRISE_RC_VERSION_REGEX = re.compile(r'(\d{4})\.(\d+)\.rc(\d+)')
3131

@@ -38,10 +38,30 @@
3838
r'((?:(scylla-oss-stable):(\d+))|(?:(scylla-enterprise-stable):(\d+))|(?:(cassandra3-stable):(\d+))|(?:(cassandra4-stable):(\d+))|(?:(scylla-oss-rc))|(?:(scylla-enterprise-rc)))')
3939

4040

41+
def fetch_docker_hub_tags(namespace, repository):
42+
tags = []
43+
44+
# Fetch all pages of tags for a given repository
45+
current_page_endpoint = DOCKER_HUB_TAGS_ENDPOINT % (namespace, repository)
46+
while True:
47+
# Fetch a page
48+
tags_data = requests.get(current_page_endpoint).json()
49+
50+
# Extract all tags from the response
51+
tags.extend(map(lambda e: e['name'], tags_data['results']))
52+
53+
# Move to the next page if it's needed
54+
if tags_data['next'] is not None:
55+
current_page_endpoint = tags_data['next']
56+
else:
57+
break
58+
59+
return tags
60+
61+
4162
def fetch_last_scylla_oss_minor_versions(count):
4263
# Download Docker tags for repository
43-
tags_data = requests.get(DOCKER_HUB_TAGS_ENDPOINT % (SCYLLA_OSS)).json()
44-
tags_data = map(lambda e: e['name'], tags_data)
64+
tags_data = fetch_docker_hub_tags(*SCYLLA_OSS)
4565

4666
# Parse only those tags which match 'NUM.NUM.NUM'
4767
# into tuple (NUM, NUM, NUM)
@@ -64,8 +84,7 @@ def fetch_last_scylla_oss_minor_versions(count):
6484

6585
def fetch_all_scylla_oss_rc_versions():
6686
# Download Docker tags for repository
67-
tags_data = requests.get(DOCKER_HUB_TAGS_ENDPOINT % (SCYLLA_OSS)).json()
68-
tags_data = list(map(lambda e: e['name'], tags_data))
87+
tags_data = fetch_docker_hub_tags(*SCYLLA_OSS)
6988

7089
# Parse only those tags which match 'NUM.NUM.rcNUM'
7190
# into tuple (NUM, NUM, NUM)
@@ -98,9 +117,7 @@ def fetch_all_scylla_oss_rc_versions():
98117

99118
def fetch_last_scylla_enterprise_minor_versions(count):
100119
# Download Docker tags for repository
101-
tags_data = requests.get(DOCKER_HUB_TAGS_ENDPOINT %
102-
(SCYLLA_ENTERPRISE)).json()
103-
tags_data = map(lambda e: e['name'], tags_data)
120+
tags_data = fetch_docker_hub_tags(*SCYLLA_ENTERPRISE)
104121

105122
# Parse only those tags which match 'YEAR.NUM.NUM'
106123
# into tuple (YEAR, NUM, NUM)
@@ -124,9 +141,7 @@ def fetch_last_scylla_enterprise_minor_versions(count):
124141

125142
def fetch_all_scylla_enterprise_rc_versions():
126143
# Download Docker tags for repository
127-
tags_data = requests.get(DOCKER_HUB_TAGS_ENDPOINT %
128-
(SCYLLA_ENTERPRISE)).json()
129-
tags_data = list(map(lambda e: e['name'], tags_data))
144+
tags_data = fetch_docker_hub_tags(*SCYLLA_ENTERPRISE)
130145

131146
# Parse only those tags which match 'YEAR.NUM.rcNUM'
132147
# into tuple (YEAR, NUM, NUM)

0 commit comments

Comments
 (0)