From 2b22c2d15907a6937442be10284e84764617188f Mon Sep 17 00:00:00 2001 From: Wade Barnes Date: Fri, 24 May 2024 14:01:56 -0700 Subject: [PATCH 1/2] Upgrade ACA-Py Version - Upgrade to ACA-Py 0.12.1 Signed-off-by: Wade Barnes --- openshift/templates/agent/agent-build.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/openshift/templates/agent/agent-build.yaml b/openshift/templates/agent/agent-build.yaml index 9e062e4..59c8a11 100644 --- a/openshift/templates/agent/agent-build.yaml +++ b/openshift/templates/agent/agent-build.yaml @@ -112,12 +112,12 @@ parameters: displayName: Source Image Registry description: The name of the Source Image Registry. required: false - value: artifacts.developer.gov.bc.ca/docker-remote/ + value: artifacts.developer.gov.bc.ca/github-docker-remote/ - name: SOURCE_IMAGE_NAME displayName: Source Image Name description: The name of the Docker image to be used for the build. Overrides the FROM instruction in the Dockerfile. required: false - value: bcgovimages/aries-cloudagent:py36-1.16-1_0.7.0 + value: hyperledger/aries-cloudagent-python:py3.9-indy-1.16.0-0.12.1 - name: CPU_REQUEST displayName: Resources CPU Request description: The resources CPU request (in cores) for this build. From 78ddcc54a95c2fa739a9150fbd0713fe86a9b7cd Mon Sep 17 00:00:00 2001 From: Wade Barnes Date: Tue, 4 Jun 2024 09:16:45 -0700 Subject: [PATCH 2/2] Add support for hard reset Signed-off-by: Wade Barnes --- openshift/manage | 134 ++++++++++++++++++++++++++++++++--------------- 1 file changed, 93 insertions(+), 41 deletions(-) diff --git a/openshift/manage b/openshift/manage index 04d9ce5..cca8ce8 100755 --- a/openshift/manage +++ b/openshift/manage @@ -29,8 +29,8 @@ usage () { The following operations are performed during a reset: - All credentials are be requeued for posting. - The 'event-processor-log-db' is reset and reinitialized. - - The wallet is reset, by restoring initial copy of ICIA Wallet. - - The process pauses at the end to confirm the corresponding ICOB reset process has completed + - The wallet is reset, by restoring initial copy of BC Registries Agent Wallet. + - The process pauses at the end to confirm the corresponding OrgBook reset process has completed before scalling up the controller which performs its issuer registration on startup. - Various pods are scaled up and down automatically during the process. @@ -259,6 +259,20 @@ resourceSuffix="${resourceSuffix:--primary}" # Process the local command line arguments and pass everything else along. # - The 'getopts' options string must start with ':' for this to work. # ----------------------------------------------------------------------------------------------------------------- +for arg in "$@"; do + # Remove recognized arguments from the list after processing. + shift + case "$arg" in + --hard-reset) + HARD_RESET=1 + ;; + *) + # If not recognized, save it for later processing ... + set -- "$@" "$arg" + ;; + esac +done + while [ ${OPTIND} -le $# ]; do if getopts :s: FLAG; then case ${FLAG} in @@ -401,6 +415,14 @@ function deleteDatabase() { echoWarning "\nThe databases on ${_podName}${resourceSuffix} have been deleted." } +function hardReset() { + if [ ! -z ${HARD_RESET} ]; then + return 0 + else + return 1 + fi +} + function reset() { ( agentPod=${1} @@ -423,7 +445,7 @@ function reset() { # Explain what is about to happen and wait for confirmation ... txtMsg=$(cat <<-EOF -The [${targetNamespace}] ICIA environment will be RESET using the following settings: +The [${targetNamespace}] BC Registries Agent environment will be RESET using the following settings: - agentPod: ${agentPod}${resourceSuffix} - controllerPod: ${controllerPod}${resourceSuffix} - eventDbPod: ${eventDbPod}${resourceSuffix} @@ -435,28 +457,51 @@ The [${targetNamespace}] ICIA environment will be RESET using the following sett - walletDbBackupSpec: ${walletDbBackupSpec} - walletDbBackupFileFilter: ${walletDbBackupFileFilter} - walletDbAdminPasswordKey: ${walletDbAdminPasswordKey} +EOF +) + if hardReset; then +txtMsg+=$(cat <<-EOF +\n +\033[0;31mYou have requested a Hard Reset. The following operations will be performed (ALL DATA WILL BE LOST): + \033[1;33m- The process will pause at the beginning to ensure the related OrgBook reset process has started. + - All credentials will be requeued for posting. + - The 'event-processor-log-db' will be reset and reinitialized. + - The wallet will be deleted and recreated. + - The process will pause at the end to confirm the corresponding OrgBook reset process has completed + before scalling up the controller which will perform its issuer registration on startup. + - Various pods will be scaled up and down automatically during the process.\n +EOF +) + else +txtMsg+=$(cat <<-EOF +\n The following operations will be performed: - All credentials will be requeued for posting. - The 'event-processor-log-db' will be reset and reinitialized. - - The wallet will be reset, by restoring initial copy of ICIA Wallet. - - The process will pause at the end to confirm the corresponding ICOB reset process has completed + - The wallet will be reset, by restoring initial copy of BC Registries Agent Wallet. + - The process will pause at the end to confirm the corresponding OrgBook reset process has completed before scalling up the controller which will perform its issuer registration on startup. - Various pods will be scaled up and down automatically during the process.\n EOF ) - printAndAskToContinue "${txtMsg}" + fi + + if ! printAndWaitForYes "${txtMsg}"; then + echoWarning "Exiting ..." + exit 1 + fi - # - scaledown ICIA controller and agent + # - scaledown BC Registries Agent controller and agent echo "Scaling down ${agentPod}${resourceSuffix} and ${controllerPod}${resourceSuffix} ..." scaleDown -w "${controllerPod}${resourceSuffix}" "${agentPod}${resourceSuffix}" exitOnError - # Nonblocking - Indicate the ICOB reset could safely start now ... + # Nonblocking - Indicate the OrgBook reset could safely start now ... echoWarning "\n=================================================================================" echoWarning "*********************************************************************************" echo - echoWarning "You can now safely start the reset process in the corresponding ICOB environment." + echoWarning "You can now safely start the reset process in the corresponding OrgBook environment." echo echoWarning "*********************************************************************************" echoWarning "=================================================================================\n\n" @@ -468,47 +513,54 @@ EOF requeueProcessedCreds "${eventDbPod}" exitOnError - # - reset ICIA event-processor-log-db + # - reset BC Registries Agent event-processor-log-db echo -e "\nResetting ${eventProcessorLogDbPod}${resourceSuffix} ..." resetEventProcLogDatabase -q "${eventProcessorLogDbPod}" "${eventProcessorPod}" exitOnError - # - reset ICIA Wallet Database, by restoring initial copy of ICIA Wallet. - echo -e "\nResetting ${walletDbPod}${resourceSuffix} ..." - if isScaledUp ${backupPod}${resourceSuffix}; then - local backupStarted=1 + if hardReset; then + # - Delete Wallet Database + echoError "Deleteing ${walletDbPod}${resourceSuffix} ..." + deleteDatabase "${walletDbPod}" + exitOnError else - local unset backupStarted - scaleUp -w "${backupPod}${resourceSuffix}" + # - reset BC Registries Agent Wallet Database, by restoring initial copy of BC Registries Agent Wallet. + echo -e "\nResetting ${walletDbPod}${resourceSuffix} ..." + if isScaledUp ${backupPod}${resourceSuffix}; then + local backupStarted=1 + else + local unset backupStarted + scaleUp -w "${backupPod}${resourceSuffix}" + exitOnError + fi + + runInContainer -i \ + ${backupPod}${resourceSuffix} \ + "./backup.sh -s -a $(getSecret ${walletDbPod}${resourceSuffix} ${walletDbAdminPasswordKey}) -r ${walletDbBackupSpec} -f ${walletDbBackupFileFilter}" exitOnError - fi - runInContainer -i \ - ${backupPod}${resourceSuffix} \ - "./backup.sh -s -a $(getSecret ${walletDbPod}${resourceSuffix} ${walletDbAdminPasswordKey}) -r ${walletDbBackupSpec} -f ${walletDbBackupFileFilter}" - exitOnError + if [ -z ${backupStarted} ]; then + # Leave the backup container in the same state we found it. + scaleDown "${backupPod}${resourceSuffix}" + exitOnError + fi - if [ -z ${backupStarted} ]; then - # Leave the backup container in the same state we found it. - scaleDown "${backupPod}${resourceSuffix}" + # - verify BC Registries Agent Wallet - There should only be 4 items. + recordCounts=$(getRecordCounts "${walletDbPod}" "${walletDbName}") + numItems=$(echo "${recordCounts}" | grep items | awk '{print $5}') + if (( ${numItems} >= 4 )); then + echo "Wallet 'items' count verified; ${numItems} items found." + else + echoError "Wallet 'items' count verification failed; ${numItems} items found. Please fix the issue and try again." + exit 1 + fi exitOnError fi - # - verify ICIA Wallet - There should only be 4 items. - recordCounts=$(getRecordCounts "${walletDbPod}" "${walletDbName}") - numItems=$(echo "${recordCounts}" | grep items | awk '{print $5}') - if (( ${numItems} >= 4 )); then - echo "Wallet 'items' count verified; ${numItems} items found." - else - echoError "Wallet 'items' count verification failed; ${numItems} items found. Please fix the issue and try again." - exit 1 - fi - exitOnError - - # - Pause for ICOB reset - printAndAskToContinue "Please ensure the ICOB reset is complete before you continue." + # - Pause for OrgBook reset + printAndAskToContinue "Please ensure the OrgBook reset is complete before you continue." - # - scaleup ICIA agent + # - scaleup BC Registries Agent agent echo "Scaling up ${agentPod}${resourceSuffix} ..." scaleUp -w "${agentPod}${resourceSuffix}" exitOnError @@ -518,14 +570,14 @@ EOF removeAgentConnections "${agentPod}" exitOnError - # - scaleup ICIA controller + # - scaleup BC Registries Agent controller echo "Scaling up ${controllerPod}${resourceSuffix} ..." scaleUp -w "${controllerPod}${resourceSuffix}" exitOnError - # - verify ICIA registered with ICOB + # - verify BC Registries Agent registered with OrgBook # - Test posting a few credentials using the pipelines - echo "You can now verifiy ICIA has successfully registered with ICOB. Following that you can test things by issuing a few credentials." + echo "You can now verifiy BC Registries Agent has successfully registered with OrgBook. Following that you can test things by issuing a few credentials." ) }