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

feat(cmapi): MCOL-6006 Disable failover when shared storage not detected

add Base api client
add NodeController api client
fix ClusterController Api client
add NodeController in endpoints.py
add 2 new endpoints to dispatcher: cluster/check-shared-storage and node/check-shared-file
add check_shared_storage method into ClusterHandler class
add set_shared_storage to node_manipulation t
add reading shared_storage in failover/config.py
fix is_shared_storage method in failover/config.py
add check_shared_storage in NodeMonitor class
fix some minor styling
This commit is contained in:
mariadb-AlanMologorsky
2025-07-18 16:00:34 +03:00
parent 7dca1da8f2
commit 48148b1e6e
10 changed files with 361 additions and 80 deletions

View File

@@ -1,9 +1,8 @@
import logging
import hashlib
import socket
import subprocess
import time
from copy import deepcopy
from datetime import datetime
from pathlib import Path
@@ -1106,6 +1105,26 @@ class ClusterController:
module_logger.debug(f'{func_name} returns {str(response)}')
return response
@cherrypy.tools.timeit()
@cherrypy.tools.json_in()
@cherrypy.tools.json_out()
@cherrypy.tools.validate_api_key() # pylint: disable=no-member
def check_shared_storage(self):
"""Handler for /cluster/check-shared-storage/ (PUT) endpoint."""
func_name = 'check_shared_storage'
log_begin(module_logger, func_name)
try:
response = ClusterHandler.check_shared_storage()
except CMAPIBasicError as err:
raise_422_error(module_logger, func_name, err.message)
except Exception:
raise_422_error(
module_logger, func_name,
'Undefined error happened while checking shared storage.'
)
module_logger.debug(f'{func_name} returns {str(response)}')
return response
class ApiKeyController:
@cherrypy.tools.timeit()
@@ -1261,3 +1280,36 @@ class NodeProcessController():
}
module_logger.debug(f'{func_name} returns {str(response)}')
return response
class NodeController:
@cherrypy.tools.timeit()
@cherrypy.tools.json_out()
@cherrypy.tools.validate_api_key() # pylint: disable=no-member
def check_shared_file(self, file_path, check_sum):
func_name = 'check_shared_file'
log_begin(module_logger, func_name)
ACCEPTED_PATHS = (
'/var/lib/columnstore/data1/x',
'/var/lib/columnstore/storagemanager/metadata/data1/x'
)
if not file_path.startswith(ACCEPTED_PATHS):
raise_422_error('Not acceptable file_path.')
success = True
file_path_obj = Path(file_path)
if not file_path_obj.exists():
success = False
else:
with file_path_obj.open(mode='rb') as file_to_check:
data = file_to_check.read()
calculated_md5 = hashlib.md5(data).hexdigest()
if calculated_md5 != check_sum:
success = False
response = {
'timestamp': str(datetime.now()),
'success': success
}
return response