Skip to content

Commit

Permalink
improvement(k8s): make 'scylla_operator_chart_version' attr be public
Browse files Browse the repository at this point in the history
We use the 'scylla_operator_chart_version' attr in lots of places,
not only the K8S class instance itself.
So, make it be of the 'public' type removing the need to disable
the 'protected-access' pylint rule.
  • Loading branch information
vponomaryov authored and fruch committed Nov 22, 2023
1 parent f6e1627 commit e366ebb
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 19 deletions.
3 changes: 1 addition & 2 deletions functional_tests/scylla_operator/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -224,9 +224,8 @@ def skip_if_not_supported_scylla_version(request: pytest.FixtureRequest,

@pytest.fixture(autouse=True)
def skip_based_on_operator_version(request: pytest.FixtureRequest, tester: ScyllaOperatorFunctionalClusterTester):
# pylint: disable=protected-access
if required_operator := request.node.get_closest_marker('required_operator'):
current_version = tester.k8s_clusters[0]._scylla_operator_chart_version.split("-")[0]
current_version = tester.k8s_clusters[0].scylla_operator_chart_version.split("-")[0]
required_version = required_operator.args[0]
if version_utils.ComparableScyllaOperatorVersion(current_version) < required_version:
pytest.skip(f"require operator version: {required_version}, current version: {current_version}")
Expand Down
2 changes: 1 addition & 1 deletion functional_tests/scylla_operator/libs/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ def reinstall_scylla_manager(db_cluster: ScyllaPodCluster, manager_version: str)
log.debug(db_cluster.k8s_cluster.helm_install(
target_chart_name="scylla-manager",
source_chart_name="scylla-operator/scylla-manager",
version=db_cluster.k8s_cluster._scylla_operator_chart_version, # pylint: disable=protected-access
version=db_cluster.k8s_cluster.scylla_operator_chart_version,
use_devel=True,
values=values,
namespace=SCYLLA_MANAGER_NAMESPACE,
Expand Down
6 changes: 3 additions & 3 deletions functional_tests/scylla_operator/test_functional.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ def test_deploy_quasi_multidc_db_cluster(db_cluster: ScyllaPodCluster): # pylin
target_chart_name2, namespace2 = (f"{cluster_name}-2", ) * 2
dc_name, dc_name2 = (f"quasi-dc-{i}" for i in range(1, 3))
k8s_cluster, kubectl = db_cluster.k8s_cluster, db_cluster.k8s_cluster.kubectl
operator_version = k8s_cluster._scylla_operator_chart_version # pylint: disable=protected-access
operator_version = k8s_cluster.scylla_operator_chart_version
need_to_collect_logs = True
logdir = f"{os.path.join(k8s_cluster.logdir, 'test_deploy_quasi_multidc_db_cluster')}"
values = HelmValues({
Expand Down Expand Up @@ -537,7 +537,7 @@ def test_check_operator_operability_when_scylla_crd_is_incorrect(db_cluster):
db_cluster.k8s_cluster.helm_install(
target_chart_name=target_chart_name,
source_chart_name="scylla-operator/scylla",
version=db_cluster.k8s_cluster._scylla_operator_chart_version, # pylint: disable=protected-access
version=db_cluster.k8s_cluster.scylla_operator_chart_version,
use_devel=True,
values=values,
namespace=namespace)
Expand Down Expand Up @@ -766,7 +766,7 @@ def test_deploy_helm_with_default_values(db_cluster: ScyllaPodCluster):
log.debug(db_cluster.k8s_cluster.helm_install(
target_chart_name=target_chart_name,
source_chart_name="scylla-operator/scylla",
version=db_cluster.k8s_cluster._scylla_operator_chart_version, # pylint: disable=protected-access
version=db_cluster.k8s_cluster.scylla_operator_chart_version,
use_devel=True,
namespace=namespace,
))
Expand Down
24 changes: 12 additions & 12 deletions sdcm/cluster_k8s/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -562,7 +562,7 @@ def get_latest_chart_version(self, local_chart_path: str) -> str:
return current_newest_version_str

@cached_property
def _scylla_operator_chart_version(self):
def scylla_operator_chart_version(self):
self.log.debug(self.helm(
f"repo add scylla-operator {self.params.get('k8s_scylla_operator_helm_repo')}"))

Expand All @@ -586,7 +586,7 @@ def get_operator_image(self, repo: str = '', chart_version: str = '') -> str:
# Get 'appVersion' field from the Helm chart which stores image's tag
repo = repo or self.params.get('k8s_scylla_operator_helm_repo')
chart_name = "scylla-operator"
chart_version = chart_version or self._scylla_operator_chart_version
chart_version = chart_version or self.scylla_operator_chart_version
chart_info = self.helm(
f"show chart {chart_name} --devel --repo {repo} --version {chart_version}")
for line in chart_info.split("\n"):
Expand Down Expand Up @@ -663,7 +663,7 @@ def deploy_scylla_manager(self, pool_name: str = None) -> None:
self.log.debug(self.helm_install(
target_chart_name="scylla-manager",
source_chart_name="scylla-operator/scylla-manager",
version=self._scylla_operator_chart_version,
version=self.scylla_operator_chart_version,
use_devel=True,
values=values,
namespace=SCYLLA_MANAGER_NAMESPACE,
Expand Down Expand Up @@ -721,7 +721,7 @@ def deploy_scylla_operator(self, pool_name: str = None) -> None:
affinity_rules["affinity"]["nodeAffinity"])
values = HelmValues(**affinity_rules)
if ComparableScyllaOperatorVersion(
self._scylla_operator_chart_version.split("-")[0]) > "1.3.0":
self.scylla_operator_chart_version.split("-")[0]) > "1.3.0":
# NOTE: following is supported starting with operator-1.4
values.set("logLevel", 4)

Expand All @@ -746,20 +746,20 @@ def deploy_scylla_operator(self, pool_name: str = None) -> None:
self.log.debug(self.helm_install(
target_chart_name="scylla-operator",
source_chart_name="scylla-operator/scylla-operator",
version=self._scylla_operator_chart_version,
version=self.scylla_operator_chart_version,
use_devel=True,
namespace=SCYLLA_OPERATOR_NAMESPACE,
values=values
))
if self.params.get('k8s_enable_tls') and ComparableScyllaOperatorVersion(
self._scylla_operator_chart_version.split("-")[0]) >= "1.8.0":
self.scylla_operator_chart_version.split("-")[0]) >= "1.8.0":
patch_cmd = ('patch deployment scylla-operator --type=json -p=\'[{"op": "add",'
'"path": "/spec/template/spec/containers/0/args/-", '
'"value": "--feature-gates=AutomaticTLSCertificates=true" }]\' ')
self.kubectl(patch_cmd, namespace=SCYLLA_OPERATOR_NAMESPACE)

if self.params.get('k8s_enable_tls') and ComparableScyllaOperatorVersion(
self._scylla_operator_chart_version.split("-")[0]) >= "1.9.0":
self.scylla_operator_chart_version.split("-")[0]) >= "1.9.0":
# around 10 keys that need to be cached per cluster
crypto_key_buffer_size = self.params.get('k8s_tenants_num') * 10
for flag in (f"--crypto-key-buffer-size-min={crypto_key_buffer_size}",
Expand Down Expand Up @@ -850,7 +850,7 @@ def upgrade_scylla_operator(self, new_helm_repo: str,
values=values,
))
if self.params.get('k8s_enable_tls') and ComparableScyllaOperatorVersion(
self._scylla_operator_chart_version.split("-")[0]) >= "1.8.0":
self.scylla_operator_chart_version.split("-")[0]) >= "1.8.0":
patch_cmd = ('patch deployment scylla-operator --type=json -p=\'[{"op": "add",'
'"path": "/spec/template/spec/containers/0/args/-", '
'"value": "--feature-gates=AutomaticTLSCertificates=true" }]\' ')
Expand Down Expand Up @@ -925,7 +925,7 @@ def get_scylla_cluster_helm_values(self, cpu_limit, memory_limit, pool_name: str

dns_domains = []
expose_options = {}
if ComparableScyllaOperatorVersion(self._scylla_operator_chart_version.split("-")[0]) >= "1.11.0":
if ComparableScyllaOperatorVersion(self.scylla_operator_chart_version.split("-")[0]) >= "1.11.0":
if k8s_db_node_service_type := self.params.get("k8s_db_node_service_type"):
expose_options["nodeService"] = {"type": k8s_db_node_service_type}
for broadcast_direction_type in ("node", "client"):
Expand All @@ -934,7 +934,7 @@ def get_scylla_cluster_helm_values(self, cpu_limit, memory_limit, pool_name: str
expose_options["broadcastOptions"] = {}
expose_options["broadcastOptions"][f"{broadcast_direction_type}s"] = {"type": ip_type}
if self.params.get('k8s_enable_tls') and ComparableScyllaOperatorVersion(
self._scylla_operator_chart_version.split("-")[0]) >= "1.8.0":
self.scylla_operator_chart_version.split("-")[0]) >= "1.8.0":
dns_domains = [f"{cluster_name}.sct.scylladb.com"]
expose_options = {"cql": {"ingress": {
"annotations": {
Expand Down Expand Up @@ -1134,7 +1134,7 @@ def prepare_k8s_scylla_nodes(

self.log.info("Install DaemonSets required by scylla nodes")
scylla_machine_image_args = '--all'
if ComparableScyllaOperatorVersion(self._scylla_operator_chart_version) > "1.5.0":
if ComparableScyllaOperatorVersion(self.scylla_operator_chart_version) > "1.5.0":
# NOTE: operator versions newer than v1.5.0 have it's own perf tuning,
# so, we should not do anything else than disk setup in such a case.
scylla_machine_image_args = '--setup-disks'
Expand Down Expand Up @@ -1301,7 +1301,7 @@ def deploy_scylla_cluster(self, node_pool_name: str, namespace: str = SCYLLA_NAM
self.log.debug(self.helm_install(
target_chart_name="scylla",
source_chart_name="scylla-operator/scylla",
version=self._scylla_operator_chart_version,
version=self.scylla_operator_chart_version,
use_devel=True,
values=self.get_scylla_cluster_helm_values(
cpu_limit=self.scylla_cpu_limit,
Expand Down
2 changes: 1 addition & 1 deletion sdcm/tester.py
Original file line number Diff line number Diff line change
Expand Up @@ -484,7 +484,7 @@ def argus_collect_packages(self):
def generate_operator_packages(self) -> list[Package]:
operator_packages = []
if self.k8s_clusters:
operator_helm_chart_version = self.k8s_clusters[0]._scylla_operator_chart_version # pylint: disable=protected-access
operator_helm_chart_version = self.k8s_clusters[0].scylla_operator_chart_version
operator_packages.append(Package(name="operator-chart", date="",
version=operator_helm_chart_version,
revision_id="", build_id=""))
Expand Down

0 comments on commit e366ebb

Please sign in to comment.