Skip to content

Commit 2537e30

Browse files
committed
Merge branch 'dev_3.3.0' into 'master'
Dev 3.3.0 See merge request oceanbase/ob-deploy!489
2 parents d91c434 + 8c263e4 commit 2537e30

File tree

150 files changed

+12343
-3980
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

150 files changed

+12343
-3980
lines changed

_cmd.py

Lines changed: 44 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1225,6 +1225,10 @@ def __init__(self):
12251225
self.parser.add_option('-t', '-n', '--tenant-name', type='string', help="The standby tenant name. The default tenant name is consistent with the primary tenant name.", default='')
12261226
self.parser.add_option('--standbyro-password', type='string', help="standbyro user password.")
12271227
self.parser.add_option('-p', '--tenant-root-password', type='string', help="tenant root password,for crate standby user.")
1228+
self.parser.add_option('--type', type='string', help="Standby tenant data sync mode. Supports 'SERVICE' and 'LOCATION' modes. Defaults: 'SERVICE'.", default='SERVICE')
1229+
self.parser.add_option('-d', '--data_backup_uri', type='string',help='The path to the directory where the backups are stored.')
1230+
self.parser.add_option('-a', '--archive_log_uri', type='string',help='The Path to the directory where archive logs are stored.')
1231+
self.parser.add_option('-D', '--decryption', type='string', help='The decryption password for all backups. example: key1,key2,key3')
12281232

12291233

12301234
def init(self, cmd, args):
@@ -1409,7 +1413,7 @@ def __init__(self):
14091413
self.parser.add_option('--replica_type ', type='string', help='The replica type of the tenant.')
14101414
self.parser.add_option('-p', '--primary_zone', type='string', help="The primary zone of the tenant to be restored.")
14111415
self.parser.add_option('-T', '--timestamp', type='string', help='The timestamp to restore to.')
1412-
self.parser.add_option('-S', '--scn', type='int', help="The SCN to restore to.. Default: 0.")
1416+
self.parser.add_option('-S', '--scn', type='int', help="The SCN to restore to. Default: 0.")
14131417
self.parser.add_option('-s', '--ha_high_thread_score', type='int', help='The high thread score for HA. Range: [0, 100]')
14141418
self.parser.add_option('-c', '--concurrency', type='int', help='The number of threads to use for the restore operation.')
14151419
self.parser.add_option('-D', '--decryption', type='string', help='The decryption password for all backups. example: key1,key2,key3')
@@ -1500,6 +1504,43 @@ def _do_command(self, obd):
15001504
else:
15011505
return self._show_help()
15021506

1507+
class ClusterTenantRecoverCommand(ClusterMirrorCommand):
1508+
def __init__(self):
1509+
super(ClusterTenantRecoverCommand, self).__init__('recover', 'Modify the recovery target of the new standby tenant')
1510+
self.parser.add_option('-T', '--timestamp', type='string', help='The timestamp to restore to.')
1511+
self.parser.add_option('-S', '--scn', type='int', help="The SCN to restore to.")
1512+
self.parser.add_option('-u', '--unlimited', action='store_true', help="Continuously replay archived source logs")
1513+
1514+
def init(self, cmd, args):
1515+
super(ClusterTenantRecoverCommand, self).init(cmd, args)
1516+
self.parser.set_usage('%s <deploy name> <tenant name>' % self.prev_cmd)
1517+
return self
1518+
1519+
def _do_command(self, obd):
1520+
if len(self.cmds) == 2:
1521+
return obd.log_recover(self.cmds[0], self.cmds[1])
1522+
else:
1523+
return self._show_help()
1524+
1525+
class ClusterTenantSwitchLogSourceCommand(ClusterMirrorCommand):
1526+
def __init__(self):
1527+
super(ClusterTenantSwitchLogSourceCommand, self).__init__('switch-log-source', 'Switch standby tenant sync mode')
1528+
self.parser.add_option('--type', type='string', help="Standby tenant data sync mode. Supports 'SERVICE' and 'LOCATION' modes. Defaults: 'SERVICE'.", default='SERVICE')
1529+
self.parser.add_option('-a', '--archive_log_uri', type='string',help='The Path to the directory where archive logs are stored.')
1530+
self.parser.add_option('-p', '--tenant-root-password', type='string', help="tenant root password,for crate standby user.")
1531+
self.parser.add_option('--standbyro-password', type='string', help="standbyro user password.")
1532+
1533+
def init(self, cmd, args):
1534+
super(ClusterTenantSwitchLogSourceCommand, self).init(cmd, args)
1535+
self.parser.set_usage('%s <deploy name> <tenant name>' % self.prev_cmd)
1536+
return self
1537+
1538+
def _do_command(self, obd):
1539+
if len(self.cmds) == 2:
1540+
return obd.switch_log_source(self.cmds[0], self.cmds[1])
1541+
else:
1542+
return self._show_help()
1543+
15031544

15041545
class ClusterTenantCommand(MajorCommand):
15051546

@@ -1520,6 +1561,8 @@ def __init__(self):
15201561
self.register_command(ClusterTenantQueryRestoreTaskCommand())
15211562
self.register_command(ClusterTenantCancelBackupTaskCommand())
15221563
self.register_command(ClusterTenantCancelRestoreTaskCommand())
1564+
self.register_command(ClusterTenantRecoverCommand())
1565+
self.register_command(ClusterTenantSwitchLogSourceCommand())
15231566

15241567

15251568
class ClusterMajorCommand(MajorCommand):

_errno.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,9 @@ class InitDirFailedErrorMessage(object):
172172
EC_OBSERVER_UNKONE_SCENARIO = OBDErrorCodeTemplate(2013, 'Unknown scenario: {scenario}')
173173
EC_CPU_NOT_SUPPORT_AVX = OBDErrorCodeTemplate(2014, "{server}'s cpu does not support avx")
174174
EC_OBSERVER_DISABLE_AUTOSTART = OBDErrorCodeTemplate(2015, "{server}: Failed to modify the configuration of the automatic startup. Please check whether the current user has sudo permissions")
175+
EC_OBSERVER_LOG_INCOMPLETE = OBDErrorCodeTemplate(2016, "Primary tenant {primary_tenant} have not full log, not support create standby cluster, rerun with '--type=LOCATION' if you want to create standby tenant.")
176+
EC_OBSERVER_LOG_RECOVER = OBDErrorCodeTemplate(2017, "Continuous log synchronization is not enabled. Please execute the command `obd cluster tenant recover {cluster_name} {tenant_name} --unlimited` to enable continuous log synchronization")
177+
EC_OBSERVER_LOCATION_CREATE_STANDBY = OBDErrorCodeTemplate(2018, "For the standby tenant created by {primary_tenant} in log archive mode, it is prohibited to create a network-mode standby tenant for this standby tenant.")
175178

176179
WC_OBSERVER_SYS_MEM_TOO_LARGE = OBDErrorCodeTemplate(2010, '({server}): system_memory too large. system_memory should be less than {factor} * memory_limit/memory_limit_percentage.')
177180

_stdio.py

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -745,7 +745,17 @@ def _print(self, msg_lv, msg, *args, **kwargs):
745745
del kwargs['_disable_log']
746746
else:
747747
enaable_log = True
748-
748+
749+
print_msg = str(print_msg)
750+
if "PASSWORD" in print_msg and "IP_LIST=" not in print_msg:
751+
print_msg = self._format(print_msg, *args)
752+
pk_regex = r'(?i)(password([:|=]))(?! \S)(.*?)(,|\s)'
753+
pattern = re.compile(pk_regex)
754+
is_match = pattern.search(print_msg)
755+
if is_match:
756+
password_length = len(is_match.group(3))
757+
replacement = r"\1" + '*' * password_length + r"\4"
758+
print_msg = pattern.sub(replacement, print_msg)
749759
kwargs['file'] and print(self._format(print_msg, *args), **kwargs)
750760
del kwargs['file']
751761
enaable_log and self.log(msg_lv, msg, *args, **kwargs)
@@ -816,6 +826,17 @@ def table_log_masking(self, msg):
816826
if match:
817827
masked_password = "*"*len(match.group(3))
818828
str_msg = pattern.sub(rf"\1{masked_password}\4", str_msg)
829+
elif 'access_' in str_msg:
830+
access_regex = r"(access_id=)[^&]*|(access_key=)[^&,| ]*"
831+
access_pattern = re.compile(access_regex)
832+
def replace_with_stars(match):
833+
full_match = match.group(0) # Full match including prefix
834+
key, value = full_match.split('=', 1) # Split into key and value
835+
masked_value = '*' * len(value) # Create the mask
836+
return f"{key}={masked_value}"
837+
match = re.search(access_pattern, str_msg)
838+
if match:
839+
str_msg = re.sub(access_pattern, replace_with_stars, str_msg)
819840
return str_msg
820841

821842
@staticmethod
@@ -900,7 +921,7 @@ def log_masking(self, msg):
900921
if is_match:
901922
return msg
902923
if "access_id" in msg or "access_key" in msg:
903-
access_regex = r'(access_id=|access_key=)([^&\']+)'
924+
access_regex = r'(access_id=|access_key=)([^&\',]+)'
904925
access_pattern = re.compile(access_regex)
905926
if access_pattern.search(msg):
906927
return access_pattern.sub(r'\1******', msg)
@@ -936,6 +957,7 @@ def verbose(self, msg, *args, **kwargs):
936957
if self.level > self.VERBOSE_LEVEL:
937958
self.log(MsgLevel.VERBOSE, '%s %s' % (self._verbose_prefix, msg), *args, **kwargs)
938959
return
960+
msg = self.log_masking(msg)
939961
self._print(MsgLevel.VERBOSE, '%s %s' % (self._verbose_prefix, msg), *args, **kwargs)
940962

941963
if sys.version_info.major == 2:

const.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,3 +134,6 @@
134134
#standalone
135135
INTERACTIVE_INSTALL = 'INTERACTIVE_INSTALL'
136136

137+
SERVICE_MODE = 'SERVICE'
138+
LOCATION_MODE = 'LOCATION'
139+

0 commit comments

Comments
 (0)