Skip to content

Commit

Permalink
Fix postgres port issue by just port-forwarding a different one in ./…
Browse files Browse the repository at this point in the history
…scripts/load_dev_db.sh

Summary: we keep getting this issue with ./script/load_dev_db.sh where a running postgres instance gets in the way. To avoid this issue, here's a solution where we get a port that's two above a typical postgres and choose that instead. Slightly better than nothing, but might benefit from a future where we error out saying the port is busy. Kinda hard to do in bash, would recommend we rewrite in golang to really do this properly.

Test Plan: Tested out and after port change, now successfully writes to k8s postgres.

Reviewers: vihang, nserrino, michelle

Reviewed By: vihang

Differential Revision: https://phab.corp.pixielabs.ai/D8487

GitOrigin-RevId: aa770ba
  • Loading branch information
Phillip Kuznetsov authored and copybaranaut committed Apr 30, 2021
1 parent 060e1d6 commit 33bb82e
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions scripts/load_dev_db.sh
Original file line number Diff line number Diff line change
Expand Up @@ -57,29 +57,32 @@ while true; do
fi
done


# Port-forward to a different port than postgres to avoid problems.
# If you are having troubles in the future, check overlapping `sudo lsof -i :<postgres_port>`
# (substitute manually) and edit the script to a different port if it's not empty
postgres_port=35432
# Port-forward the postgres pod.
postgres_pod=$(kubectl get pod --namespace "$namespace" --selector="name=postgres" \
--output jsonpath='{.items[0].metadata.name}')
kubectl port-forward pods/"$postgres_pod" 5432:5432 -n "$namespace" &
kubectl port-forward pods/"$postgres_pod" ${postgres_port}:5432 -n "$namespace" &

# Update database with Vizier versions.
bazel run -c opt //src/utils/artifacts/versions_gen:versions_gen -- \
--repo_path "${repo_path}" --artifact_name vizier --versions_file "${versions_file}"
bazel run -c opt //src/utils/artifacts/artifact_db_updater:artifact_db_updater -- \
--versions_file "${versions_file}" --postgres_db "pl"
--versions_file "${versions_file}" --postgres_db "pl" --postgres_port "${postgres_port}"

# Update database with CLI versions.
bazel run -c opt //src/utils/artifacts/versions_gen:versions_gen -- \
--repo_path "${repo_path}" --artifact_name cli --versions_file "${versions_file}"
bazel run -c opt //src/utils/artifacts/artifact_db_updater:artifact_db_updater -- \
--versions_file "${versions_file}" --postgres_db "pl"
--versions_file "${versions_file}" --postgres_db "pl" --postgres_port "${postgres_port}"

git checkout main "$versions_file"

# Update database with SSL certs.
bazel run -c opt //src/cloud/dnsmgr/load_certs:load_certs -- \
--certs_path "${certs_path}" --postgres_db "pl"
--certs_path "${certs_path}" --postgres_db "pl" --postgres_port "${postgres_port}"

# Run the kratos and hydra migrate jobs.
if [[ $load_ory_auth -ne 0 ]]; then
Expand Down

0 comments on commit 33bb82e

Please sign in to comment.