Repository navigation
feat(backup): prove recovery from the independent snapshot store #5470
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
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
bf1f30a
feat(backup): prove recovery from the independent snapshot store
devantler bf9bd01
fix(backup): use the reviewed private endpoint invocation
devantler 9d78bc1
fix(backup): authenticate snapshot reads with the required payload hash
devantler bd21fe8
fix(backup): limit isolated restore inputs
devantler 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 hidden or 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,124 @@ | ||
| name: Verify OpenBao Backup Recovery | ||
|
|
||
| "on": | ||
| workflow_dispatch: | ||
| inputs: | ||
| confirm: | ||
| description: "Type exactly: verify-openbao-backup-recovery" | ||
| required: true | ||
| type: string | ||
|
|
||
| permissions: {} | ||
| concurrency: | ||
| group: prod-deploy | ||
| cancel-in-progress: false | ||
| queue: max | ||
|
|
||
| jobs: | ||
| verify: | ||
| name: Restore an independent backup without changing production | ||
| runs-on: ubuntu-latest | ||
| timeout-minutes: 15 | ||
| environment: prod | ||
| permissions: | ||
| contents: read | ||
| steps: | ||
| - name: Require main and typed confirmation | ||
| shell: bash | ||
| env: | ||
| CONFIRM: ${{ inputs.confirm }} | ||
| run: | | ||
| if [[ "$GITHUB_EVENT_NAME" != workflow_dispatch || "$GITHUB_REF" != refs/heads/main || "$GITHUB_REPOSITORY" != devantler-tech/platform || "$CONFIRM" != verify-openbao-backup-recovery ]]; then | ||
| printf '%s\n' 'OPENBAO_BACKUP_RESTORE=UNVERIFIED' >&2 | ||
| exit 2 | ||
| fi | ||
|
|
||
| - name: Check out the confirmed revision | ||
| uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 | ||
| with: | ||
| ref: ${{ github.sha }} | ||
| persist-credentials: false | ||
|
|
||
| - name: Set up the repository Go version | ||
| uses: actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e # v7.0.0 | ||
| with: | ||
| go-version-file: go.mod | ||
| cache: false | ||
|
|
||
| - name: Install the repository-approved Kubernetes reader | ||
| shell: bash | ||
| run: | | ||
| set -euo pipefail | ||
| kubectl_path="$RUNNER_TEMP/openbao-recovery-kubectl" | ||
| curl --disable --fail --silent --show-error --location --proto '=https' --proto-redir '=https' --max-redirs 3 --connect-timeout 10 --max-time 60 \ | ||
| https://dl.k8s.io/release/v1.36.2/bin/linux/amd64/kubectl -o "$kubectl_path" | ||
| printf '%s %s\n' 1e9045ec32bea85da43de85f0065358529ea7c7a152eca78154fba5b58c27d82 "$kubectl_path" | sha256sum --check | ||
| mkdir -p "$RUNNER_TEMP/openbao-recovery-tools" | ||
| install -m 0755 "$kubectl_path" "$RUNNER_TEMP/openbao-recovery-tools/kubectl" | ||
| printf '%s\n' "$RUNNER_TEMP/openbao-recovery-tools" >> "$GITHUB_PATH" | ||
| CGO_ENABLED=0 go build -trimpath -o "$RUNNER_TEMP/openbao-recovery-tools/verifier" ./scripts/openbao-backup-recovery | ||
|
|
||
| - name: Read the fixed backup inputs and prove isolated recovery | ||
| shell: bash | ||
| env: | ||
| KUBE_CONFIG: ${{ secrets.KUBE_CONFIG }} | ||
| HCLOUD_TOKEN: ${{ secrets.HCLOUD_TOKEN }} | ||
| run: | | ||
| set +x | ||
| set -euo pipefail | ||
| umask 077 | ||
| ulimit -c 0 | ||
| fail() { printf '%s\n' 'OPENBAO_BACKUP_RESTORE=UNVERIFIED' >&2; exit 2; } | ||
| [[ $(id -u) != 0 && $(findmnt -n -o FSTYPE --target /dev/shm) == tmpfs ]] || fail | ||
| latest=$(git ls-remote --exit-code https://github.com/devantler-tech/platform.git refs/heads/main) || fail | ||
| [[ "$latest" == "$GITHUB_SHA"$'\trefs/heads/main' ]] || fail | ||
| proof_dir=$(mktemp -d /dev/shm/openbao-recovery.XXXXXXXX) | ||
| forward_pid='' | ||
| cleanup() { | ||
| if [[ -n "$forward_pid" ]]; then | ||
| kill "$forward_pid" 2>/dev/null || true | ||
| wait "$forward_pid" 2>/dev/null || true | ||
| fi | ||
| rm -rf "$proof_dir" | ||
| } | ||
| trap cleanup EXIT | ||
| binary="$RUNNER_TEMP/openbao-recovery-tools/verifier" | ||
| [[ -n "$KUBE_CONFIG" && ${#KUBE_CONFIG} -le 1048576 ]] || fail | ||
| export KUBECONFIG="$proof_dir/kubeconfig" | ||
| printf '%s' "$KUBE_CONFIG" > "$KUBECONFIG" | ||
| unset KUBE_CONFIG | ||
| if ! ( | ||
| if ! ./scripts/use-prod-stable-api-endpoint.sh >/dev/null; then | ||
| exit 1 | ||
| fi | ||
| ) 2>"$proof_dir/endpoint.log"; then | ||
| fail | ||
| fi | ||
| unset HCLOUD_TOKEN | ||
| kubectl --context=admin@prod -n openbao port-forward --address=127.0.0.1 service/openbao-active 38200:8200 > "$proof_dir/forward.log" 2>&1 & | ||
| forward_pid=$! | ||
| ready=false | ||
| for ((attempt=0; attempt<20; attempt++)); do | ||
| kill -0 "$forward_pid" 2>/dev/null || fail | ||
| if curl --disable --silent --fail --noproxy '*' --connect-timeout 1 --max-time 2 \ | ||
| http://127.0.0.1:38200/v1/sys/health > /dev/null 2>"$proof_dir/health.log"; then | ||
| ready=true | ||
| break | ||
| fi | ||
| sleep 1 | ||
| done | ||
| [[ "$ready" == true ]] || fail | ||
| export OPENBAO_RECOVERY_DIR="$proof_dir" | ||
| if ! "$binary" collect > "$proof_dir/collection-result" 2>"$proof_dir/collection.log"; then fail; fi | ||
| [[ $(cat "$proof_dir/collection-result") == OPENBAO_BACKUP_INPUTS=PASS ]] || fail | ||
| kill "$forward_pid" 2>/dev/null || fail | ||
| wait "$forward_pid" 2>/dev/null || true | ||
| forward_pid='' | ||
| unset OPENBAO_RECOVERY_DIR KUBECONFIG | ||
| rm -- "$proof_dir/kubeconfig" | ||
| image=$("$binary" image) || fail | ||
| if ! docker pull "$image" > "$proof_dir/pull.log" 2>&1; then fail; fi | ||
| if ! bash scripts/run-openbao-backup-sandbox.sh verify "$proof_dir" "$binary" > "$proof_dir/verification-result" 2>"$proof_dir/verification.log"; then fail; fi | ||
| result=$(cat "$proof_dir/verification-result") | ||
| [[ "$result" == 'OPENBAO_BACKUP_RESTORE=PASS records=3 version=2.6.3' ]] || fail | ||
| printf '%s\n' "$result" | ||
This file contains hidden or 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 hidden or 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 hidden or 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.
Uh oh!
There was an error while loading. Please reload this page.