From: Israel Fruchter <
fr...@scylladb.com>
Committer: Israel Fruchter <
israel....@gmail.com>
Branch: master
fix(c-s): remove lookups in dockerhub for scylla docker images
since now from scylla 6.0 and up, the docker image doesn't have c-s
install in it, there's no point to lookup the docker image.
also the default in that code of `scylladb/scylla:latest` also
doesn't have c-s, so leaving this code is only gonna cause confusion
and we should start hard coding c-s as needed in each release branch
---
diff --git a/sdcm/stress_thread.py b/sdcm/stress_thread.py
--- a/sdcm/stress_thread.py
+++ b/sdcm/stress_thread.py
@@ -33,7 +33,6 @@
from sdcm.sct_events.loaders import CassandraStressEvent, CS_ERROR_EVENTS_PATTERNS, CS_NORMAL_EVENTS_PATTERNS
from sdcm.stress.base import DockerBasedStressThread
from sdcm.utils.docker_remote import RemoteDocker
-from sdcm.utils.version_utils import get_docker_image_by_version
from sdcm.utils.remote_logger import SSHLoggerBase
@@ -250,13 +249,6 @@ def _build_log_file_id(loader_idx, cpu_idx, keyspace_idx):
def _run_stress(self, loader, loader_idx, cpu_idx):
pass
- @cached_property
- def docker_image_name(self):
- if cassandra_stress_image := super().docker_image_name:
- return cassandra_stress_image
- else:
- return get_docker_image_by_version(self.node_list[0].get_scylla_binary_version())
-
def _run_cs_stress(self, loader, loader_idx, cpu_idx, keyspace_idx): # pylint: disable=too-many-locals,too-many-branches,too-many-statements
cleanup_context = contextlib.nullcontext()
os.makedirs(loader.logdir, exist_ok=True)
diff --git a/sdcm/utils/version_utils.py b/sdcm/utils/version_utils.py
--- a/sdcm/utils/version_utils.py
+++ b/sdcm/utils/version_utils.py
@@ -20,7 +20,6 @@
from collections import namedtuple, defaultdict
from urllib.parse import urlparse
from functools import lru_cache, wraps
-from itertools import count
import yaml
import boto3
@@ -486,41 +485,6 @@ def get_scylla_docker_repo_from_version(scylla_version: str):
return 'scylladb/scylla'
-def get_docker_image_by_version(scylla_version: str):
- # get shorter version, for getting releases, and check if it's enterprise.
- short_scylla_version = SCYLLA_VERSION_RE.match(scylla_version)
- assert short_scylla_version, f"'{scylla_version}' isn't acceptable version string"
- short_scylla_version = short_scylla_version.group().replace('~', '-')
-
- # select the repo to use, and the scylla_versio to match
- docker_repo = 'scylladb/scylla'
- if is_enterprise(short_scylla_version):
- docker_repo += '-enterprise'
-
- default_image = f"{docker_repo}:latest"
-
- if 'dev' in scylla_version:
- docker_repo += '-nightly'
- scylla_version = scylla_version.replace('~', '-')
- else:
- scylla_version = short_scylla_version
-
- for page_number in count(start=1):
- try:
- all_tags = requests.get(url=f'
https://hub.docker.com/v2/repositories/{docker_repo}/'
- f'tags?page_size=50&page={page_number}').json()
- except requests.RequestException:
- break
- for image in all_tags.get('results', []):
- image_name = image.get('name')
- if image_name and scylla_version == image_name:
- return f"{docker_repo}:{image_name}"
- if not all_tags.get('next'):
- break
- # if image wasn't found, default to the latest releases
- return default_image
-
-
def _list_repo_file_etag(s3_client: S3Client, prefix: str) -> Optional[dict]:
repo_file = s3_client.list_objects_v2(Bucket=SCYLLA_REPO_BUCKET, Prefix=prefix)
if repo_file["KeyCount"] != 1:
diff --git a/unit_tests/test_version_utils.py b/unit_tests/test_version_utils.py
--- a/unit_tests/test_version_utils.py
+++ b/unit_tests/test_version_utils.py
@@ -13,7 +13,6 @@
get_all_versions,
get_branch_version,
get_branch_version_for_multiple_repositories,
- get_docker_image_by_version,
get_git_tag_from_helm_chart_version,
get_scylla_urls_from_repository,
get_specific_tag_of_docker_image,
@@ -415,50 +414,6 @@ def test_scylla_version_for_argus_regexp(full_version, short, date, commit_id):
assert parsed_version.group("commit") == commit_id
-...@pytest.mark.integration
-...@pytest.mark.need_network
-...@pytest.mark.parametrize("version, expected", (
- ("4.6.rc2-20220102.e8a1cfb6f", "scylladb/scylla:4.6.rc2"),
- ("5.0.1-0.20220719.b177dacd3", "scylladb/scylla:5.0.1"),
- ("5.1", "scylladb/scylla:5.1"),
- ("5.1.0~rc1", "scylladb/scylla:5.1.0-rc1"),
- ("5.0.1", "scylladb/scylla:5.0.1"),
- ("5.2.0~dev-0.20220824.6ce5e9079c1e", "scylladb/scylla-nightly:5.2.0-dev-0.20220824.6ce5e9079c1e"),
- ("5.1.0~dev-0.20220726.29c28dcb0c33", "scylladb/scylla-nightly:5.1.0-dev-0.20220726.29c28dcb0c33"),
- ("2022.2.dev-20220515.no_such_sha", "scylladb/scylla-enterprise:latest"),
- ("5.2.0~dev-20220515.no_such_sha", "scylladb/scylla:latest"),
-))
-def test_get_docker_image_by_version(version, expected):
- assert get_docker_image_by_version(scylla_version=version) == expected
-
-
-def test_get_docker_image_by_version_broken_string_version():
- with pytest.raises(AssertionError):
- get_docker_image_by_version(scylla_version="broken_version")
-
-
-def test_get_docker_image_by_version_fallback_on_errors():
- def mock_requests_factory(response_stub):
- return mock.Mock(**{
- 'json.return_value': response_stub,
- })
-
- def raise_request_error(**kwargs):
- raise requests.HTTPError()
-
- non_existing_version = '5.2.0~dev-0.20221124.999b7f5d9b77'
- expected_fallback = 'scylladb/scylla:latest'
- with unittest.mock.patch("requests.get") as get_mock:
- get_mock.side_effect = lambda **_: mock_requests_factory({})
- assert get_docker_image_by_version(scylla_version=non_existing_version) == expected_fallback
-
- get_mock.side_effect = lambda **_: mock_requests_factory({"results": [{'name': ''}, {}]})
- assert get_docker_image_by_version(scylla_version=non_existing_version) == expected_fallback
-
- get_mock.side_effect = raise_request_error
- assert get_docker_image_by_version(scylla_version=non_existing_version) == expected_fallback
-
-
@pytest.mark.parametrize("version_string, expected", (
("5.1", (5, 1, 0, '', '')),
("5.1.0", (5, 1, 0, '', '')),