Skip to content

Commit

Permalink
Added guardrails scripts installation to the installer script (#1744)
Browse files Browse the repository at this point in the history
  • Loading branch information
ShivanshGahlot authored Oct 10, 2024
1 parent 5e56005 commit 1bf233c
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 2 deletions.
26 changes: 26 additions & 0 deletions installer_scripts/install-yb-voyager
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ centos_main() {
$YUM https://download.postgresql.org/pub/repos/yum/reporpms/EL-${majorVersion}-x86_64/pgdg-redhat-repo-latest.noarch.rpm 1>&2 || true
$YUM postgresql16 1>&2
$YUM sqlite 1>&2
create_guardrail_scripts_dir
create_pg_dump_args_file
create_gather_assessment_metadata_dir
install_golang linux
Expand Down Expand Up @@ -187,6 +188,7 @@ ubuntu_main() {
sudo apt-get -y install sqlite3 1>&2
install_golang linux
ubuntu_install_postgres
create_guardrail_scripts_dir
create_pg_dump_args_file
create_gather_assessment_metadata_dir
if [ $ONLY_PG == "false" ] ; then
Expand Down Expand Up @@ -230,6 +232,7 @@ macos_main() {
fi

macos_install_pg_dump
create_guardrail_scripts_dir
create_pg_dump_args_file
create_gather_assessment_metadata_dir
brew install wget
Expand Down Expand Up @@ -512,6 +515,7 @@ rebuild_debezium_server_voyager_plugin_local(){
rebuild_voyager_local() {
VERSION="local"
install_yb_voyager
create_guardrail_scripts_dir
create_gather_assessment_metadata_dir
rebuild_debezium_server_voyager_plugin_local
}
Expand Down Expand Up @@ -850,6 +854,28 @@ create_gather_assessment_metadata_dir() {
fi
}

create_guardrail_scripts_dir() {
scripts_parent_dir="/opt/yb-voyager"
scripts_dir_name="guardrails-scripts"
sudo mkdir -p $scripts_parent_dir/$scripts_dir_name
YB_VOYAGER_GIT_HASH_TEMP="512c53a3cd3f111b7e2c35c5dbb0c36e0c3280d1"

output "Installing the guardrails scripts"
if [ "${VERSION}" == "latest" ]
then
TAR_URL="https://github.com/yugabyte/yb-voyager/archive/$YB_VOYAGER_GIT_HASH_TEMP.tar.gz"
sudo wget -nv -O /tmp/yb-voyager.tar.gz $TAR_URL
sudo tar -xzf /tmp/yb-voyager.tar.gz -C /tmp 1>&2
sudo cp -r /tmp/yb-voyager-$YB_VOYAGER_GIT_HASH_TEMP/guardrails-scripts/* $scripts_parent_dir/$scripts_dir_name 1>&2
sudo rm -rf /tmp/yb-voyager-$YB_VOYAGER_GIT_HASH_TEMP
sudo rm /tmp/yb-voyager.tar.gz
else
pushd $REPO_ROOT > /dev/null
sudo rsync -avc --delete $REPO_ROOT/$scripts_dir_name $scripts_parent_dir 1>&2
popd > /dev/null
fi
}

#=============================================================================
# CENTOS
#=============================================================================
Expand Down
4 changes: 2 additions & 2 deletions migtests/scripts/functions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ grant_user_permission_postgresql() {
db_name=$1
db_schema=$2
conn_string="postgresql://${SOURCE_DB_ADMIN_USER}:${SOURCE_DB_ADMIN_PASSWORD}@${SOURCE_DB_HOST}:${SOURCE_DB_PORT}/${db_name}"
psql "${conn_string}" -v voyager_user="${SOURCE_DB_USER}" -v schema_list="${db_schema}" -v is_live_migration=0 -v is_live_migration_fall_back=0 -f ../../../../guardrails-scripts/yb-voyager-pg-grant-migration-permissions.sql
psql "${conn_string}" -v voyager_user="${SOURCE_DB_USER}" -v schema_list="${db_schema}" -v is_live_migration=0 -v is_live_migration_fall_back=0 -f /opt/yb-voyager/guardrails-scripts/yb-voyager-pg-grant-migration-permissions.sql

}

Expand Down Expand Up @@ -155,7 +155,7 @@ grant_permissions_for_live_migration_pg() {
db_name=$1
db_schema=$2
conn_string="postgresql://${SOURCE_DB_ADMIN_USER}:${SOURCE_DB_ADMIN_PASSWORD}@${SOURCE_DB_HOST}:${SOURCE_DB_PORT}/${db_name}"
psql "${conn_string}" -v voyager_user="${SOURCE_DB_USER}" -v schema_list="${db_schema}" -v replication_group='replication_group' -v original_owner_of_tables="${SOURCE_DB_ADMIN_USER}" -v is_live_migration=1 -v is_live_migration_fall_back=0 -f ../../../../guardrails-scripts/yb-voyager-pg-grant-migration-permissions.sql
psql "${conn_string}" -v voyager_user="${SOURCE_DB_USER}" -v schema_list="${db_schema}" -v replication_group='replication_group' -v original_owner_of_tables="${SOURCE_DB_ADMIN_USER}" -v is_live_migration=1 -v is_live_migration_fall_back=0 -f /opt/yb-voyager/guardrails-scripts/yb-voyager-pg-grant-migration-permissions.sql
}

grant_permissions() {
Expand Down

0 comments on commit 1bf233c

Please sign in to comment.