Skip to content

Commit

Permalink
Fix the mysql_bosh_lite script
Browse files Browse the repository at this point in the history
- It was incorrectly matching the `rotate-cc-database-key` errand when
  looking for the IP of the database
- New regex only looks for instance groups that _start with_ "database"
- Added some comments to clarify what the script is doing
  • Loading branch information
Gerg committed Nov 18, 2022
1 parent caea955 commit 07471bc
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion bin/mysql_bosh_lite
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,9 @@ get_database_password(){
}

ssh_tunnel(){
# random port on local machine for the SSH tunnel
mysql_port=$(gshuf -i 10000-65535 -n 1)
mysql_ip=$(bosh is --column ips --column instance | grep database | cut -f 2)
mysql_ip=$(bosh is --column ips --column instance | grep ^database | cut -f 2)
test -z "$mysql_port" && exit 1
test -z "$mysql_ip" && exit 1
bosh ssh --opts="-L ${mysql_port}:${mysql_ip}:3306" -c 'while true; do continue; done' database &
Expand All @@ -31,6 +32,7 @@ connect_to_db(){
exit 1
fi

# connect to the database via localhost:<random port>, using the SSH tunnel we created above
mysql -ucloud_controller -p"${cc_database_password}" -P $mysql_port -h 127.0.0.1 cloud_controller
}

Expand Down

0 comments on commit 07471bc

Please sign in to comment.