-
-
Notifications
You must be signed in to change notification settings - Fork 152
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: Build and publish a QEMU image artifact #1430
Merged
Merged
Changes from all commits
Commits
Show all changes
98 commits
Select commit
Hold shift + click to select a range
549f9eb
fix: account for `public` grantee
soedirgo c83b1c6
fix(ci): respect postgresVersion input (#1237)
soedirgo 5671a39
feat: bump gotrue version to v2.162.0 (#1241)
kangmingtay a2f1ff8
fix: only grant pg_read_all_data if it exists (#1242)
soedirgo d71ec5f
fix(15.6): account for pg_stat_monitor major version upgrade (#1247)
pcnc 8706e3a
chore: release updates to run physical backup as a service to 15.6 im…
dragarcia 1d1396e
fix(15.6/pg_upgrade): retry commands within the cleanup step; wait un…
pcnc 320305e
fix(15.6/upgrades): collision when patching wrappers lib locations fo…
pcnc d264b9d
feat: bump auth 2.162.1 on 15.6 (#1256)
hf 5177fa3
fix(15.6): disable pg_stat_monitor (#1260)
pcnc ce2eb0c
fix(15.6): disable pg_stat_monitor (#1262)
pcnc 9062da4
feat: bump gotrue to v2.162.2 (#1264)
kangmingtay 0c52b1f
chore: add timescaledb 2.9.1; wrappers upgrade fix; wrappers & plv8 n…
pcnc ba417af
chore(15.6): bump pg version (#1273)
pcnc 82152fa
feat: bump auth to v2.163.0 on 15.6 (#1275)
hf 1912ed8
fix: restart PG during pre-upgrade steps to shed hanging connections …
pcnc 3cf6055
fix(upgrades): wrappers 4.2.0 -> wrappers 4.2.0 (#1278)
pcnc 054dbc1
fix: handle supabase_admin authenticator membership snowflake
soedirgo fb024e8
feat: add auth v2.163.1 to 15.6 (#1283)
hf 223952b
feat: bump gotrue to v2.163.2 (#1287)
kangmingtay 2d658fc
pg_net 0.11 on 15.6 release branch (#1290)
olirice a5e5919
fix: don't copy custom extension scripts during pg_upgrade (#1291)
pcnc 1211077
fix: add recursive flag to custom extension script directory delete (…
pcnc 407d41a
[GEN-11027] chore: reserve a fixed amount of blocks for the data volu…
pcnc 19ac493
fix: grant predefined roles post-upgrade
soedirgo 21d3823
fix: add more roles to reserved_roles & reserved_memberships (#1303)
soedirgo 1273c41
feat: update envoy lds config with auth jwks, oidc URLs, strip `sb-op…
hf 936713c
chore: udpate package repo for salt (#1307)
dragarcia 5350420
fix: use sudo for apt-get commands
soedirgo 9e285dd
Update pg net to 0.13.0 on pg 15.6 branch (#1315)
olirice a627e17
chore: cleanup pgbouncer.get_auth ownership accordingly
dragarcia 4b0e661
chore: standardize
dragarcia a3cce04
chore: try a qemu build
darora 4c2aa5b
chore: avoid using ansible globbing
darora ea0abae
revert stage2 changes
darora 41a4f14
preserve AMI build process
darora c7696d3
chore: check ec2ic perms if not in qemu mode
darora 98a87b5
chore: further ami build things
darora 841505a
chore: ship qcow2 image instead of raw
darora 36510ea
chore: cleanup + start building nix artifacts on qemu branches
darora 03eb5cf
chore: add rudimentary docs on the QEMU artifact
darora fc741e2
chore: upgrade to latest adminapi release
darora 6a233ca
chore: first pass at adding details to the docs
dragarcia 9fc808b
chore: update doc on steps when running within the cluster
dragarcia 78e7b0d
Update qemu_artifact.md
darora 46c5c51
chore: add image built on alpine with some qemu deps
darora c9c3be4
chore: upgrade to latest alpine
darora a21b88a
Merge remote-tracking branch 'origin/develop' into da/merging-qemu
darora a582a0c
chore: remove temporary changes that are no longer necessary
darora 5658e78
chore: upgrade to latest awscli release
darora 67bc2c9
fix: define postgres major version
darora 035dc13
fix: more new vars
darora 85c7e82
fix: yet another pg var
darora 2cf0be4
Merge remote-tracking branch 'origin/develop' into da/merging-qemu
darora bcf0e0e
chore: initial version of GHA to build qemu artifact
darora 277f761
.
darora aa07a38
.
darora a65a8c5
.
darora 4823c8a
chore: install system dependencies
darora 6ad5807
chore: pass in pg version var correctly
darora 09fecce
enable logs
darora b9fd20b
.
darora bdbd500
.
darora 2f0f1be
chore: temporarily disable KVM to test sw emulation performance
darora cb9ffbd
chore: specify number of CPU cores
darora 2965425
trigger build
darora e1b27e4
Revert "chore: temporarily disable KVM to test sw emulation performance"
darora 0e96fe8
chore: use native runners
darora 7528325
update apt sources
darora 3034704
.
darora 66c7850
attempt to enable kvm
darora 3a37d03
.
darora f964393
chore; REVERT this later
darora 23fbb98
.
darora 2f36aab
Revert "chore; REVERT this later"
darora 8d0ef7a
chore: remove path output
darora a24e13f
.
darora cf3b0ec
chore: install packer since we're experimenting with a base image
darora 9ad8432
reenable host cpu
darora dc080fc
.
darora add5d2b
try publishing
darora 4877903
cleanup
darora e423ffc
.
darora 08e6311
fix
darora 44f8563
.
darora b245fc2
.
darora 8c478bd
.
darora 8d5d14a
test using builtin deps
darora 75b76b7
Revert "test using builtin deps"
darora e8d5da4
.
darora ec51f42
simplify
darora a7496be
.
darora 1b23658
context
darora 45a2f3e
fix: correct tag
darora 44f115d
Merge remote-tracking branch 'origin/develop' into da/merging-qemu
darora e53bd62
chore: cleanup instructions for building image
darora bbd589f
chore: run scripts through an auto-formatter
darora 000ab44
Merge remote-tracking branch 'origin/develop' into da/merging-qemu
darora File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,185 @@ | ||
name: Build QEMU image | ||
|
||
on: | ||
push: | ||
branches: | ||
- develop | ||
- release/* | ||
paths: | ||
- '.github/workflows/qemu-image-build.yml' | ||
- 'qemu-arm64-nix.pkr.hcl' | ||
- 'common-nix.vars.pkr.hcl' | ||
- 'ansible/vars.yml' | ||
workflow_dispatch: | ||
|
||
jobs: | ||
prepare: | ||
runs-on: ubuntu-latest | ||
outputs: | ||
postgres_versions: ${{ steps.set-versions.outputs.postgres_versions }} | ||
steps: | ||
- name: Checkout Repo | ||
uses: actions/checkout@v3 | ||
|
||
- uses: DeterminateSystems/nix-installer-action@main | ||
|
||
- name: Set PostgreSQL versions - only builds pg15 atm | ||
id: set-versions | ||
run: | | ||
VERSIONS=$(nix run nixpkgs#yq -- '.postgres_major[0]' ansible/vars.yml | nix run nixpkgs#jq -- -R -s -c 'split("\n")[:-1]') | ||
echo "postgres_versions=$VERSIONS" >> $GITHUB_OUTPUT | ||
|
||
build: | ||
needs: prepare | ||
strategy: | ||
matrix: | ||
postgres_version: ${{ fromJson(needs.prepare.outputs.postgres_versions) }} | ||
runs-on: arm-native-runner | ||
timeout-minutes: 150 | ||
permissions: | ||
contents: write | ||
packages: write | ||
id-token: write | ||
|
||
steps: | ||
- name: Checkout Repo | ||
uses: actions/checkout@v3 | ||
|
||
- uses: DeterminateSystems/nix-installer-action@main | ||
|
||
- name: Run checks if triggered manually | ||
if: ${{ github.event_name == 'workflow_dispatch' }} | ||
run: | | ||
SUFFIX=$(sudo nix run nixpkgs#yq -- ".postgres_release[\"postgres${{ matrix.postgres_version }}\"]" ansible/vars.yml | sed -E 's/[0-9\.]+(.*)$/\1/') | ||
if [[ -z $SUFFIX ]] ; then | ||
echo "Version must include non-numeric characters if built manually." | ||
exit 1 | ||
fi | ||
|
||
- name: enable KVM support | ||
run: | | ||
sudo chown runner /dev/kvm | ||
sudo chmod 666 /dev/kvm | ||
|
||
- name: Set PostgreSQL version environment variable | ||
run: echo "POSTGRES_MAJOR_VERSION=${{ matrix.postgres_version }}" >> $GITHUB_ENV | ||
|
||
- name: Generate common-nix.vars.pkr.hcl | ||
run: | | ||
curl -L https://github.com/mikefarah/yq/releases/download/v4.45.1/yq_linux_arm64 -o yq && chmod +x yq | ||
PG_VERSION=$(./yq '.postgres_release["postgres'${{ matrix.postgres_version }}'"]' ansible/vars.yml) | ||
PG_VERSION=$(echo $PG_VERSION | tr -d '"') # Remove any surrounding quotes | ||
echo 'postgres-version = "'$PG_VERSION'"' > common-nix.vars.pkr.hcl | ||
echo 'postgres-major-version = "'$POSTGRES_MAJOR_VERSION'"' >> common-nix.vars.pkr.hcl | ||
# Ensure there's a newline at the end of the file | ||
echo "" >> common-nix.vars.pkr.hcl | ||
|
||
# TODO (darora): not quite sure why I'm having to uninstall and re-install these deps, but the build fails w/o this | ||
- name: Install dependencies | ||
run: | | ||
sudo apt-get update | ||
sudo apt-get remove -y qemu-efi-aarch64 cloud-image-utils qemu-system-arm qemu-utils | ||
sudo apt-get install -y qemu-efi-aarch64 cloud-image-utils qemu-system-arm qemu-utils | ||
|
||
- name: Build QEMU artifact | ||
run: | | ||
make init | ||
GIT_SHA=${{github.sha}} | ||
export PACKER_LOG=1 | ||
packer build -var "git_sha=${GIT_SHA}" -var-file="common-nix.vars.pkr.hcl" qemu-arm64-nix.pkr.hcl | ||
|
||
- name: Grab release version | ||
id: process_release_version | ||
run: | | ||
VERSION=$(cat common-nix.vars.pkr.hcl | sed -e 's/postgres-version = "\(.*\)"/\1/g') | ||
echo "version=$VERSION" >> $GITHUB_OUTPUT | ||
|
||
# - name: Create nix flake revision tarball | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. leaving some things commented out for now - will be needed later |
||
# run: | | ||
# GIT_SHA=${{github.sha}} | ||
# MAJOR_VERSION=${{ env.POSTGRES_MAJOR_VERSION }} | ||
|
||
# mkdir -p "/tmp/pg_upgrade_bin/${MAJOR_VERSION}" | ||
# echo "$GIT_SHA" >> "/tmp/pg_upgrade_bin/${MAJOR_VERSION}/nix_flake_version" | ||
# tar -czf "/tmp/pg_binaries.tar.gz" -C "/tmp/pg_upgrade_bin" . | ||
|
||
- name: configure aws credentials - staging | ||
uses: aws-actions/configure-aws-credentials@v4 | ||
with: | ||
role-to-assume: ${{ secrets.DEV_AWS_ROLE }} | ||
aws-region: "us-east-1" | ||
|
||
- name: Login to Amazon ECR Public | ||
id: login-ecr-public | ||
uses: aws-actions/amazon-ecr-login@v2 | ||
with: | ||
registry-type: public | ||
|
||
- name: Build, tag, and push docker image to Amazon ECR Public | ||
env: | ||
REGISTRY: public.ecr.aws/w9p6e7k7 | ||
REGISTRY_ALIAS: supabase | ||
REPOSITORY: postgres-vm-image | ||
IMAGE_TAG: ${{ steps.process_release_version.outputs.version }} | ||
run: | | ||
docker build -f Dockerfile-kubernetes -t $REGISTRY/$REGISTRY_ALIAS/$REPOSITORY:$IMAGE_TAG . | ||
docker push $REGISTRY/$REGISTRY_ALIAS/$REPOSITORY:$IMAGE_TAG | ||
|
||
# - name: Upload software manifest to s3 staging | ||
# run: | | ||
# cd ansible | ||
# ansible-playbook -i localhost \ | ||
# -e "ami_release_version=${{ steps.process_release_version.outputs.version }}" \ | ||
# -e "internal_artifacts_bucket=${{ secrets.ARTIFACTS_BUCKET }}" \ | ||
# -e "postgres_major_version=${{ env.POSTGRES_MAJOR_VERSION }}" \ | ||
# manifest-playbook.yml | ||
|
||
# - name: Upload nix flake revision to s3 staging | ||
# run: | | ||
# aws s3 cp /tmp/pg_binaries.tar.gz s3://${{ secrets.ARTIFACTS_BUCKET }}/upgrades/postgres/supabase-postgres-${{ steps.process_release_version.outputs.version }}/20.04.tar.gz | ||
|
||
# - name: configure aws credentials - prod | ||
# uses: aws-actions/configure-aws-credentials@v4 | ||
# with: | ||
# role-to-assume: ${{ secrets.PROD_AWS_ROLE }} | ||
# aws-region: "us-east-1" | ||
|
||
# - name: Upload software manifest to s3 prod | ||
# run: | | ||
# cd ansible | ||
# ansible-playbook -i localhost \ | ||
# -e "ami_release_version=${{ steps.process_release_version.outputs.version }}" \ | ||
# -e "internal_artifacts_bucket=${{ secrets.PROD_ARTIFACTS_BUCKET }}" \ | ||
# -e "postgres_major_version=${{ env.POSTGRES_MAJOR_VERSION }}" \ | ||
# manifest-playbook.yml | ||
|
||
# - name: Upload nix flake revision to s3 prod | ||
# run: | | ||
# aws s3 cp /tmp/pg_binaries.tar.gz s3://${{ secrets.PROD_ARTIFACTS_BUCKET }}/upgrades/postgres/supabase-postgres-${{ steps.process_release_version.outputs.version }}/20.04.tar.gz | ||
|
||
# - name: Create release | ||
# uses: softprops/action-gh-release@v1 | ||
# with: | ||
# name: ${{ steps.process_release_version.outputs.version }} | ||
# tag_name: ${{ steps.process_release_version.outputs.version }} | ||
# target_commitish: ${{github.sha}} | ||
|
||
# - name: Slack Notification on Failure | ||
# if: ${{ failure() }} | ||
# uses: rtCamp/action-slack-notify@v2 | ||
# env: | ||
# SLACK_WEBHOOK: ${{ secrets.SLACK_NOTIFICATIONS_WEBHOOK }} | ||
# SLACK_USERNAME: 'gha-failures-notifier' | ||
# SLACK_COLOR: 'danger' | ||
# SLACK_MESSAGE: 'Building Postgres AMI failed' | ||
# SLACK_FOOTER: '' | ||
|
||
- name: Cleanup resources after build | ||
if: ${{ always() }} | ||
run: | | ||
aws ec2 describe-instances --filters "Name=tag:packerExecutionId,Values=${GITHUB_RUN_ID}" --query "Reservations[].Instances[].InstanceId" --output text | xargs -r aws ec2 terminate-instances --instance-ids | ||
|
||
- name: Cleanup resources on build cancellation | ||
if: ${{ cancelled() }} | ||
run: | | ||
aws ec2 describe-instances --filters "Name=tag:packerExecutionId,Values=${GITHUB_RUN_ID}" --query "Reservations[].Instances[].InstanceId" --output text | xargs -r aws ec2 terminate-instances --instance-ids |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
FROM alpine:3.21 | ||
|
||
ADD ./output-cloudimg/packer-cloudimg /disk/focal.qcow2 | ||
|
||
RUN apk add --no-cache qemu-system-aarch64 qemu-img openssh-client nftables cloud-utils-localds aavmf | ||
# dev stuff | ||
# RUN apk add --no-cache iproute2 | ||
|
||
CMD exec /bin/sh -c "trap : TERM INT; sleep 9999999999d & wait" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
UPSTREAM_NIX_GIT_SHA := $(shell git rev-parse HEAD) | ||
GIT_SHA := $(shell git describe --tags --always --dirty) | ||
|
||
init: qemu-arm64-nix.pkr.hcl | ||
packer init qemu-arm64-nix.pkr.hcl | ||
|
||
output-cloudimg/packer-cloudimg: ansible qemu-arm64-nix.pkr.hcl | ||
packer build -var "git_sha=$(UPSTREAM_NIX_GIT_SHA)" qemu-arm64-nix.pkr.hcl | ||
|
||
disk/focal-raw.img: output-cloudimg/packer-cloudimg | ||
mkdir -p disk | ||
sudo qemu-img convert -O raw output-cloudimg/packer-cloudimg disk/focal-raw.img | ||
|
||
alpine-image: output-cloudimg/packer-cloudimg | ||
sudo nerdctl build . -t supabase-postgres-test:$(GIT_SHA) -f ./Dockerfile-kubernetes | ||
|
||
clean: | ||
rm -rf output-cloudimg | ||
|
||
.PHONY: alpine-image init clean |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@samrose not sure if you know?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@darora this var is used in ansible, which in turn is run by packer, and so that is the most likely reason it was set here
Those are all of the places where it's used in ansible.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are some parts of ansible build that use postgresql_major, and some that use the full version of postgres. If you think there is a way to refactor and change that into just using the version, I am in favor of that.
Otherwise, this was the pattern in vars.yml
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Or if you just think it might be better to move that line to another spot where other vars are defined, probably it won't be an issue
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's probably some easy minor cleanup we can do to ensure a little bit more consistency in how they're passed in, e.g. by getting rid of
ansible_arguments
and populating that from the underlying variables...will take a look at it