Skip to content
This repository was archived by the owner on Apr 20, 2023. It is now read-only.

Commit aafc2e1

Browse files
committed
major-iteration-2: Correcting Backup Ingestion Mode
This commit adds multiple changes to the previos commit 1. Backup Ingestion modifications to remove the operations that are not needed. 2. Create a delphixdb user so that the customers can use that in future for snapshots. 3. Update the code to use the source user from staged_source for future snapshots 4. Not fail if grants cause error. Customer must bring the grants from source db. 5. Made changes to Replication restore-stage.sh to use command_runner. 6. Added new exit codes.
1 parent 4ec4b1f commit aafc2e1

File tree

7 files changed

+174
-176
lines changed

7 files changed

+174
-176
lines changed

plugin_config.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,4 @@ pluginType: STAGED
77
entryPoint: plugin_runner:plugin
88
srcDir: src
99
schemaFile: schema.json
10-
buildNumber: 1.69.25
10+
buildNumber: 1.69.26

src/common/constants.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,13 @@
5252
ERR_INVALID_BINARY_ACTION="mysql was not found under the provided installation directory \n" \
5353
"Please verify the MySQL directory and retry the operation."
5454

55+
ERR_BI_CONNECT_MSG="Unable to connect to MySQL database after restart."
56+
ERR_BI_CONNECT_ACTION="There may have been an error while initializing or creating the staging DB user." \
57+
"Please check plugin and server host logs for additional details. "
58+
59+
ERR_BI_USERCREATE_MSG="Unable to create a new MySQL user in staging database."
60+
ERR_BI_USERCREATE_ACTION="Please check plugin and server host logs for additional details."
61+
5562
ERR_GENERAL_MSG="An error occurred while provisioning the MySQL VDB."
5663
ERR_GENERAL_ACTION="This could be due to an unsupported version of MySQL."
5764
ERR_GENERAL_OUT="For additional details, check the log " \

src/common/utils.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,12 @@ def process_exit_codes(exit_code,operation,std_err=None):
6565
elif exit_code == 10: # Invalid Binary Path
6666
err_msg=const.ERR_INVALID_BINARY_MSG
6767
err_action=const.ERR_INVALID_BINARY_ACTION
68+
elif exit_code == 11: # Connection Test Failure / Backup INgestion
69+
err_msg=const.ERR_BI_CONNECT_MSG
70+
err_action=const.ERR_BI_CONNECT_ACTION
71+
elif exit_code == 12: # User creation issue/ Backup Ingestion
72+
err_msg=const.ERR_BI_USERCREATE_MSG
73+
err_action=const.ERR_BI_USERCREATE_ACTION
6874
elif exit_code == 2:
6975
err_msg=const.ERR_GENERAL_MSG
7076
err_action=const.ERR_GENERAL_ACTION

src/pluginops/pluginops.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -358,13 +358,16 @@ def linked_pre_snapshot(staged_source, repository, source_config, snapshot_param
358358
}
359359
logger.debug("Initializing Seed DB")
360360
restore_script = pkgutil.get_data('resources', 'restore_stage_bi.sh')
361-
result = libs.run_bash(staged_source.staged_connection, restore_script,environment_vars,check=True)
361+
result = libs.run_bash(staged_source.staged_connection, restore_script,environment_vars,check=False)
362362
output = result.stdout.strip()
363-
error = result.stderr.strip()
363+
std_err = result.stderr.strip()
364364
exit_code = result.exit_code
365365
if exit_code !=0:
366-
logger.debug("Error is : "+error)
367-
raise LinkingException("Exception in pre-snapshot/restore_db:"+error)
366+
logger.debug("There was an error while creating the seed database. Check error logs for more info.")
367+
logger.error("Error is : "+std_err)
368+
err = utils.process_exit_codes(exit_code,"DBLINK",std_err)
369+
logger.error(err)
370+
raise err
368371
else:
369372
logger.debug("Pre-Snapshot/Restore_DB successful "+output)
370373
else:

src/resources/library.sh

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -498,8 +498,8 @@ function command_runner {
498498
masklog "command_runner: CMD : $1"
499499
return_msg=$(eval $1 2>&1 1>&2 > /dev/null)
500500
return_code=$?
501-
log "Return Status for source backup: ${return_code}"
502-
log "Return message for source backup:${return_msg}"
501+
log "Return Status: ${return_code}"
502+
log "Return message:${return_msg}"
503503
if [ $return_code != 0 ]; then
504504
masklog "command_runnder: exitcode : $2"
505505
terminate "${return_msg}" $2
@@ -508,6 +508,7 @@ function command_runner {
508508

509509

510510

511+
511512
###########################################################
512513
## Test/Debug ...
513514

src/resources/restore_stage.sh

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -375,16 +375,17 @@ fi
375375
CMD="${INSTALL_BIN}/mysql ${STAGING_CONN} --connect-expired-password -se \"ALTER USER 'root'@'localhost' IDENTIFIED BY ${STAGINGPASS};UPDATE mysql.user SET authentication_string=PASSWORD(${STAGINGPASS}) where USER='root';FLUSH PRIVILEGES;\""
376376
CMDFORLOG="${INSTALL_BIN}/mysql ${STAGING_CONN} --connect-expired-password -se \"ALTER USER 'root'@'localhost' IDENTIFIED BY '********';UPDATE mysql.user SET authentication_string=PASSWORD('********') where USER='root';FLUSH PRIVILEGES;\""
377377
masklog "Final Command to Change Password is : ${CMDFORLOG}"
378+
command_runner "${CMD}" 5
379+
380+
#eval ${CMD} 1>>${DEBUG_LOG} 2>&1
381+
#return_msg=$(eval ${CMD} 2>&1 1>&2 > /dev/null)
382+
#return_code=$?
383+
#log "Return Status for change password: ${return_code}"
384+
#log "Return message for change password:${return_msg}"
385+
#if [ $return_code != 0 ]; then
386+
# terminate "${return_msg}" 5
387+
#fi
378388

379-
#eval ${CMD} 1>>${DEBUG_LOG} 2>&1
380-
return_msg=$(eval ${CMD} 2>&1 1>&2 > /dev/null)
381-
return_code=$?
382-
log "Return Status for change password: ${return_code}"
383-
log "Return message for change password:${return_msg}"
384-
if [ $return_code != 0 ]; then
385-
terminate "${return_msg}" 5
386-
fi
387-
#
388389
# Update Staging Connection with supplied password ...
389390
#
390391
masklog "Staging Connection Prior to updaging password : ${STAGINGCONN}"
@@ -411,14 +412,15 @@ eval ${CMD} 1>>${DEBUG_LOG} 2>&1
411412

412413
## Ingest Backup File
413414
CMD="${INSTALL_BIN}/mysql ${STAGING_CONN} < ${BKUP_FILE}"
414-
#eval ${CMD} 1>>${DEBUG_LOG} 2>&1
415-
return_msg=$(eval ${CMD} 2>&1 1>&2 > /dev/null)
416-
return_code=$?
417-
log "Return Status for ingest backup: ${return_code}"
418-
log "Return message for ingest backup:${return_msg}"
419-
if [ $return_code != 0 ]; then
420-
terminate "${return_msg}" 6
421-
fi
415+
command_runner "${CMD}" 5
416+
#eval ${CMD} 1>>${DEBUG_LOG} 2>&1
417+
#return_msg=$(eval ${CMD} 2>&1 1>&2 > /dev/null)
418+
#return_code=$?
419+
#log "Return Status for ingest backup: ${return_code}"
420+
#log "Return message for ingest backup:${return_msg}"
421+
#if [ $return_code != 0 ]; then
422+
# terminate "${return_msg}" 6
423+
#fi
422424

423425
log "Validating Restored Databases"
424426
#RESULTS=`${INSTALL_BIN}/mysql ${STAGING_CONN} -e "show databases;"`

0 commit comments

Comments
 (0)