Skip to content

feat(infra): olf infra backup for the local provider (#910) - #926

Merged
malon64 merged 4 commits into
mainfrom
feat/910-olf-infra-backup
Nov 6, 2026
Merged

malon64 merged 4 commits into
mainfrom
feat/910-olf-infra-backup

Conversation

@malon64

@malon64 malon64 commented Nov 6, 2026

Copy link
Copy Markdown
Collaborator

Closes #910 (part of #531), PR 2 of 3. It is stacked on the backup-format PR; olf infra restore (#911) follows.

What

olf infra backup --output DIR [-f openlakeforge.yaml] [--project-root …], local provider only. The provider comes from the profile, and a backup always covers every enabled stage.

  1. Refuses a directory that isn't empty, or a missing profile.
  2. Pauses deployment/dagster-daemon in every stage, and waits for the pods to be gone. It refuses if runs are in flight (Dagster GraphQL), and always resumes the daemon, in a finally. If the resume itself fails, the error carries the exact kubectl scale command to run.
  3. Dumps polaris first, then the other databases. pg_dump -Fc --no-owner --no-acl runs in postgresql-0 and streams to a file (k8s.exec_to_file), so a dump never sits in memory.
  4. Copies every planned bucket through the existing port-forward S3 client. It writes a {key: size} inventory and checks each object's size; a path-traversal key is refused.
  5. Reads each planned Secret with its type (k8s.secret_with_type) and fails, naming any that is missing. It encrypts them into secrets.enc.
  6. Writes manifest.json with release = olf.__version__, profile_sha256 = sha256_file(profile), provider, stages, dumps, buckets, and Secret names and keys (never values). It also writes SHA256SUMS.

A failed backup leaves what it wrote and no manifest.json, so restore refuses it.

  • New k8s helpers: secret_with_type, exec_to_file, deployment_replicas, scale_deployment (which waits for pods to be gone at 0).
  • docs/reference/cli.md, CHANGELOG (Added).

Size

12 files, +816/−17, over the ~600 guide. About 470 lines are non-test code, a single command; the rest are tests for its ordering and secret-handling guarantees. The format modules already went out separately in PR 1 of 3.

Not verified on a live stack

  • pg_dump -U postgres over the pod's local socket;
  • the dagster-daemon Deployment name;
  • the Dagster runsOrError status filter;
  • binary-safe kubectl exec streaming;
  • SeaweedFS listing and download, including folder-marker keys.

The restore drill (#913) exercises these.

Checks run

  • Tests that fail first (test_backup.py, test_backup_cluster.py, test_k8s.py):
    • polaris is dumped before any other dump and before the first object copy;
    • the daemon is resumed after a failed step, after the in-flight refusal, and after a failed resume (which reports the manual command);
    • find_exposures finds no Secret value in the backup directory or the captured logs, and the passphrase appears nowhere;
    • a path-traversal key and a size mismatch are refused.
  • Full pytest tools/olf/tests: 3252 passed, 17 skipped
  • mypy: no issues
  • ruff check and ruff format on the changed files: pass
  • olf check docs and olf check structure: pass

Generated by Claude Code

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 6, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-06T16:56:32.069973Z ae5be9c New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 4d91dd39a0

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread tools/olf/olf/infra/backup/_cluster.py Resolved
Comment thread tools/olf/olf/infra/commands/backup.py Resolved

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: b9caa7798b

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread tools/olf/olf/infra/backup/_cluster.py Resolved
Comment thread tools/olf/tests/infra/test_backup.py Resolved
Comment thread tools/olf/olf/infra/backup/_cluster.py Resolved
Comment thread tools/olf/olf/infra/backup/_cluster.py Resolved
Base automatically changed from feat/910-backup-format to main November 6, 2026 16:13
@malon64
malon64 force-pushed the feat/910-olf-infra-backup branch from 8197174 to c462c0c Compare November 6, 2026 16:18
@malon64
malon64 changed the base branch from main to refactor/531-k8s-backup-helpers November 6, 2026 16:18
Base automatically changed from refactor/531-k8s-backup-helpers to main November 6, 2026 16:49
Pauses the Dagster daemon of every stage, refuses while a run is in flight,
dumps polaris first and then the other databases, copies every bucket with a
key and size inventory, seals the data-bound Secrets and local-ca under a
passphrase, and writes manifest.json and SHA256SUMS. The daemon is resumed
in a finally.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01UVCVTmCcKfSZH6Q4J2L5fZ
…910)

Distinct keys such as a//b and a/b resolve to one path under the backup
directory, so the second download overwrote the first while both stayed in
the inventory and the size checks passed. The copy now refuses colliding keys.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01UVCVTmCcKfSZH6Q4J2L5fZ
In CI, Rich colours option names, so "--output" was split by ANSI codes and
the plain substring check failed. Render with NO_COLOR and strip any codes left.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01UVCVTmCcKfSZH6Q4J2L5fZ
Backup tests assert daemon and dump state instead of call order; trailing-slash
objects with data and keys with line breaks are refused; the Dagster check
bypasses ambient proxies via the route exemption.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01UVCVTmCcKfSZH6Q4J2L5fZ
@malon64
malon64 force-pushed the feat/910-olf-infra-backup branch from c462c0c to ae5be9c Compare November 6, 2026 16:53
@malon64
malon64 enabled auto-merge November 6, 2026 16:54
@malon64
malon64 added this pull request to the merge queue Nov 6, 2026
Merged via the queue into main with commit b4b20d6 Nov 6, 2026
12 checks passed
@malon64
malon64 deleted the feat/910-olf-infra-backup branch November 6, 2026 17:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat(infra): olf infra backup for the local provider (#531)

2 participants