in mysqloperator/controller/innodbcluster/initdb.py [0:0]
def start_clone_seed_pod(session: 'ClassicSession',
cluster: InnoDBCluster,
seed_pod: MySQLPod, clone_spec: CloneInitDBSpec,
logger: Logger) -> bool:
logger.info(
f"Initializing seed instance. method=clone pod={seed_pod} source={clone_spec.uri}")
donor_root_co = dict(mysqlsh.globals.shell.parse_uri(clone_spec.uri))
# Here we get only the password from the cluster secret. The secret
# might contain also rootUser and rootHost (mask from where the user connects)
# shouldn't we respect rootUser and not ask for rootUser in clone_spec?
# Or...this is different kind of secret?
donor_root_co["user"] = clone_spec.root_user or "root"
donor_root_co["password"] = clone_spec.get_password(cluster.namespace)
logger.info(f"CONNECTING {donor_root_co['user']}@{donor_root_co['host']}...")
# Let's check if the donor has the CLONE plugin and if not install it
# It's not possible to clone without this plugin being installed
with SessionWrap(donor_root_co) as donor:
clone_installed = False
for row in iter(donor.run_sql("SHOW PLUGINS").fetch_one, None):
if row[3]:
logger.info(f"Donor has plugin {row[0]} / {row[3]}")
if row[0] == "clone":
clone_installed = True
if not clone_installed:
logger.info(f"Installing clone plugin at {donor.uri}")
# A: Check here if the plugin reall got installed before continuing?
donor.run_sql("install plugin clone soname 'mysql_clone.so'")
# TODO copy other installed plugins(?)
# clone
try:
donor_co = dict(mysqlsh.globals.shell.parse_uri(clone_spec.uri))
# Here we get only the password from the cluster secret. The secret
# might contain also rootUser and rootHost (mask from where the user connects)
# shouldn't we respect rootUser although the clone_spec.uri might already contain it?
# spec : root@xyz.abc.dev
donor_co["password"] = clone_spec.get_password(cluster.namespace)
with SessionWrap(donor_co) as donor:
logger.info(f"Starting server clone from {clone_spec.uri}")
ret = mysqlutils.clone_server(donor_co, donor, session, logger)
logger.info("Cloning finished")
return ret
except mysqlsh.Error as e:
if mysqlutils.is_client_error(e.code) or e.code == mysqlsh.mysql.ErrorCode.ER_ACCESS_DENIED_ERROR:
# TODO check why are we still getting access denied here, the container should have all accounts ready by now
# rethrow client and retriable errors
raise
else:
raise