-
Notifications
You must be signed in to change notification settings - Fork 77
MCOL-5861 cmapi read only nodes #3432
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: stable-23.10
Are you sure you want to change the base?
MCOL-5861 cmapi read only nodes #3432
Conversation
bbd12b4
to
728d94d
Compare
e698ef4
to
a74b938
Compare
Name branch as a feature/MCOL-..... Short description is better than just JIRA link. Even summary from commit\s message. |
And one thing about NEW readonly node naming - Seems should be discussed together with @drrtuy or @mariadb-LeonidFedorov or both. |
a74b938
to
220f03f
Compare
3ca8a6f
to
2bd07e4
Compare
481d491
to
44ae561
Compare
4ce4e78
to
1833abc
Compare
* feat(cmapi): add read_only param for API add node endpoint * style(cmapi): fixes for string length and quotes
db91612
to
5359c98
Compare
a73579a
to
e7fd6fc
Compare
@@ -104,7 +104,8 @@ def enable_console_logging(logger: logging.Logger) -> None: | |||
def config_cmapi_server_logging(): | |||
# add custom level TRACE only for develop purposes | |||
# could be activated using API endpoints or cli tool without relaunching | |||
add_logging_level('TRACE', 5) | |||
if not hasattr(logging, 'TRACE'): | |||
add_logging_level('TRACE', 5) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
JFYI I think to remove or rewrite this dev function.
@@ -89,7 +98,8 @@ def _detect_processes(cls) -> None: | |||
if cls.mcs_progs: | |||
logging.warning('Mcs ProcessHandler already detected processes.') | |||
|
|||
for prog_name, prog_info in ALL_MCS_PROGS.items(): | |||
for prog, prog_info in ALL_MCS_PROGS.items(): | |||
prog_name = prog.value |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
JFYI It's what I mentioned before here about naming and access names. prog.value == prog_name. It's somehow confusing.
CMAPI_CONF_PATH, | ||
CMAPI_SINGLE_NODE_XML, | ||
DEFAULT_MCS_CONF_PATH, | ||
LOCALHOSTS, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we need it on a separate lines?
|
||
def update_dbroots_of_readonly_nodes(root: etree.Element) -> None: | ||
"""Read-only nodes do not have their own dbroots, but they must have all the dbroots of the other nodes | ||
So this function sets list of dbroots of each read-only node to the list of all the dbroots in the cluster |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems to be vice versa.
sets list of all the dbroots in the cluster to the list of dbroots of each read-only node
) | ||
dbroot_id_node.text = str(dbroot_id) | ||
|
||
logging.info("Added %d dbroots to read-only node %d: %s", len(existing_dbroots), module_num, sorted(existing_dbroots)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pls f-string notation.
logging.basicConfig(level='DEBUG') | ||
|
||
SINGLE_NODE_XML = "./cmapi_server/SingleNode.xml" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
JFYI I'm not sure that default Columnstore.xml is fully equal to SingleNode.xml
) | ||
|
||
with patch('cmapi_server.node_manipulation.update_dbroots_of_readonly_nodes') as mock_update_dbroots_of_readonly_nodes: | ||
node_manipulation.add_node( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
With this mock test name is not fully valid. Here we test add\remove node and mocked function call once.
May be better to move it in separate test?
self.NEW_NODE_NAME, self.tmp_files[1], self.tmp_files[2], | ||
test_mode=True | ||
) | ||
mock_update_dbroots_of_readonly_nodes.assert_called_once() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's not clear to me what we trying to test here several times. Several times test that we call the mocked function once?
@@ -137,6 +138,26 @@ def write_config(self, tree, filename=DEFAULT_MCS_CONF_PATH): | |||
f.write(self.to_string(tree)) | |||
replace(tmp_filename, filename) # atomic replacement | |||
|
|||
@contextmanager |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd like to move it in separate PR and integrate in other places tho.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we need this file?
https://jira.mariadb.org/browse/MCOL-5861
Read-only nodes don't start WriteEngineServer and do not own dbroots. But as read-only nodes must have RO access to all the data in the cluster, all dbroots in the cluster are assigned all the dbroots.
Read-only nodes are written into ReadOnlyNodes part of the config.
On every change that could add or remove dbroots update_dbroots_of_readonly_nodes is called to assign all existing dbroots to every read-only node.
MCSProgs was added to avoid possible typos in service names (because there is no single naming convention between services and it is very easy to make an error)
Also added NodeConfig.modify_config context manager that reads config from specified path, provides its root and on (only successful exit) writes config to the output path