1
0
mirror of https://github.com/mariadb-corporation/mariadb-columnstore-engine.git synced 2025-08-08 14:22:09 +03:00

Review fixes and ruff settings

This commit is contained in:
Alexander Presnyakov
2025-04-18 03:59:40 +00:00
parent 7255340ae5
commit 04015ae414
5 changed files with 30 additions and 19 deletions

View File

@@ -11,7 +11,6 @@ import os
import socket import socket
import time import time
from collections import namedtuple from collections import namedtuple
from functools import partial
from random import random from random import random
from shutil import copyfile from shutil import copyfile
from typing import Tuple, Optional from typing import Tuple, Optional
@@ -603,11 +602,6 @@ def get_dbroots(node, config=DEFAULT_MCS_CONF_PATH):
smc_node.find(f"./ModuleDBRootID{i}-{j}-3").text smc_node.find(f"./ModuleDBRootID{i}-{j}-3").text
) )
if dbroots and nc.is_read_only():
logger = logging.getLogger('dbroots')
logger.warning(f'Config contains dbroots {dbroots} for this read-only node, ignoring')
return []
return dbroots return dbroots

View File

@@ -398,7 +398,7 @@ def _remove_node(root, node):
for n in (root.find("./DesiredNodes"), root.find("./InactiveNodes"), root.find("./ActiveNodes")): for n in (root.find("./DesiredNodes"), root.find("./InactiveNodes"), root.find("./ActiveNodes")):
__remove_helper(n, node) __remove_helper(n, node)
read_only_nodes = root.find("./ReadOnlyNodes") read_only_nodes = root.find('./ReadOnlyNodes')
if read_only_nodes is not None: if read_only_nodes is not None:
__remove_helper(read_only_nodes, node) __remove_helper(read_only_nodes, node)
@@ -1015,11 +1015,11 @@ def _add_WES(root, pm_num, node):
etree.SubElement(wes_node, "Port").text = "8630" etree.SubElement(wes_node, "Port").text = "8630"
def _add_read_only_node(root, node) -> None: def _add_read_only_node(root: etree.Element, node: str) -> None:
"""Add node name to ReadOnlyNodes if it's not already there""" '''Add node name to ReadOnlyNodes if it is not already there'''
read_only_nodes = root.find("./ReadOnlyNodes") read_only_nodes = root.find('./ReadOnlyNodes')
if read_only_nodes is None: if read_only_nodes is None:
read_only_nodes = etree.SubElement(root, "ReadOnlyNodes") read_only_nodes = etree.SubElement(root, 'ReadOnlyNodes')
else: else:
for n in read_only_nodes.findall("./Node"): for n in read_only_nodes.findall("./Node"):
if n.text == node: if n.text == node:

View File

@@ -1,7 +1,7 @@
import logging import logging
import socket import socket
import unittest import unittest
from unittest.mock import patch from unittest.mock import patch, ANY
from lxml import etree from lxml import etree
from cmapi_server import node_manipulation from cmapi_server import node_manipulation
@@ -97,7 +97,7 @@ class NodeManipTester(BaseNodeManipTestCase):
mock_rebalance_dbroots.assert_not_called() mock_rebalance_dbroots.assert_not_called()
mock_move_primary_node.assert_not_called() mock_move_primary_node.assert_not_called()
mock_add_dbroots_of_other_nodes.assert_called_once_with(root, 2) mock_add_dbroots_of_other_nodes.assert_called_once_with(ANY, 2)
# Test read-only node removal # Test read-only node removal
node_manipulation.remove_node( node_manipulation.remove_node(
@@ -111,7 +111,7 @@ class NodeManipTester(BaseNodeManipTestCase):
mock_rebalance_dbroots.assert_not_called() mock_rebalance_dbroots.assert_not_called()
mock_move_primary_node.assert_not_called() mock_move_primary_node.assert_not_called()
mock_remove_dbroots_of_node.assert_called_once_with(root, 2) mock_remove_dbroots_of_node.assert_called_once_with(ANY, 2)
def test_add_dbroots_nodes_rebalance(self): def test_add_dbroots_nodes_rebalance(self):

View File

@@ -567,11 +567,6 @@ has dbroot {subel.text}')
for j in range(1, int(smc_node.find(f"./ModuleDBRootCount{i}-3").text) + 1): for j in range(1, int(smc_node.find(f"./ModuleDBRootCount{i}-3").text) + 1):
dbroots.append(smc_node.find(f"./ModuleDBRootID{i}-{j}-3").text) dbroots.append(smc_node.find(f"./ModuleDBRootID{i}-{j}-3").text)
# TODO not sure about it
if dbroots and self.is_read_only(root):
module_logger.warning("Config contains dbroots %s for this read-only node, ignoring", dbroots)
return []
return dbroots return dbroots
def is_read_only(self, root=None) -> bool: def is_read_only(self, root=None) -> bool:

22
cmapi/pyproject.toml Normal file
View File

@@ -0,0 +1,22 @@
[tool.ruff]
line-length = 80
target-version = "py39"
# Enable common rule sets
select = [
"E", # pycodestyle errors
"F", # pyflakes: undefined names, unused imports, etc.
"I", # isort: import sorting
"B", # flake8-bugbear: common bugs and anti-patterns
"UP", # pyupgrade: use modern Python syntax
"N", # pep8-naming: naming conventions
]
ignore = []
# Exclude cache and temporary directories
exclude = [
"__pycache__",
]
[tool.ruff.format]
quote-style = "single"