Repository navigation
refactor: shared Python deploy tooling with shell CLI orchestration - #12
Conversation
Split the deploy pipeline by tool strength: shell keeps orchestrating the
CLIs (terraform, kubectl, helm, docker, dbt, floe, aws, az), while
cross-environment logic (REST/API calls, object-storage uploads, report
bundle manipulation, credential handling, contract parsing) moves into one
uv-managed Python package, tools/olf, exposed through the `olf` CLI.
- New olf subcommands replace duplicated/heredoc logic: contracts env,
floe render-profile, artifacts upload-manifests, superset deploy/export,
openmetadata deploy-metadata, k8s set-project-code-image, polaris
check-credentials.
- Shared shell helpers deduped into scripts/lib/{common,helm,kube,python}.sh;
the three env infra-up/deploy-artifacts scripts are now thin orchestrators.
- Env-neutral shell moved out of scripts/local: scripts/contracts/ and
scripts/artifacts/. Terraform stays the provider-contract source of truth;
olf contracts env keeps the exported variable names byte-identical.
- make <env>-up is now a full foundation+infra+artifacts wrapper (foundation
apply is a Terraform no-op when the cluster exists); former behavior kept as
make <env>-stack-up. All granular targets retained.
- CI gains a tooling job (ruff + pytest) and uv on the contracts/dbt jobs.
- Records ADR 0017; logs the bash check-*/e2e rewrite as follow-up debt.
Verified: check-structure, check-contracts, ruff, and 31 pytest pass;
contract-env and Floe-profile output diffed byte-identical against the
original scripts.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: f2dbe1029e
ℹ️ 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".
Address two P1 review findings from the subprocess isolation of the new contract resolver: - olf contracts env resolved AWS_REGION during the pre-contract default pass (storage region still at the us-east-1 default) and never re-derived it once provider contracts set the real region. The old bash saw a shell-local AWS_REGION in-process; the uv subprocess cannot, so a cloud stack kept the stale us-east-1 and mis-targeted ECR. AWS_REGION/AWS_DEFAULT_REGION now follow the resolved storage region unless the caller exported them. Local output stays byte-identical (us-east-1 -> us-east-1). - discover_runtime_manifests only globbed one directory down, but floe-manifest.sh persists the two-level <domain>/<product>/ layout, so direct AWS upload found nothing. It now recurses and takes the domain from the first path segment, matching the original find-based upload. Tests updated (32 pass); local contract-env output diffed byte-identical against the pre-refactor scripts.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: acc22378cc
ℹ️ 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".
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: ff94225d6c
ℹ️ 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".
| if [[ "${status}" -eq 3 ]]; then | ||
| POLARIS_BOOTSTRAP_GENERATION="rebootstrap-$(date -u +%Y%m%d%H%M%S)" | ||
| cleanup_jobs_by_prefix "polaris-bootstrap-" | ||
| cleanup_jobs_by_prefix "openmetadata-bootstrap-" | ||
| cleanup_failed_jobs_by_prefix "openmetadata-polaris-refresh-" | ||
| fi |
There was a problem hiding this comment.
Propagate Polaris helper failures
When olf_run polaris check-credentials exits with any non-stale error (for example a uv/Python failure or an unexpected kubectl error), this function falls through the if [[ "${status}" -eq 3 ]] block and returns success, so local-infra-up/azure-infra-up continue as if the preflight passed. The helper already maps unreachable/unknown Polaris to exit 0 and stale credentials to 3, so other statuses should be returned; otherwise the stack can apply with an unchanged bootstrap generation after the credential check failed.
Useful? React with 👍 / 👎.
…penLakeForge#12) * refactor: shared Python deploy tooling with shell CLI orchestration Split the deploy pipeline by tool strength: shell keeps orchestrating the CLIs (terraform, kubectl, helm, docker, dbt, floe, aws, az), while cross-environment logic (REST/API calls, object-storage uploads, report bundle manipulation, credential handling, contract parsing) moves into one uv-managed Python package, tools/olf, exposed through the `olf` CLI. - New olf subcommands replace duplicated/heredoc logic: contracts env, floe render-profile, artifacts upload-manifests, superset deploy/export, openmetadata deploy-metadata, k8s set-project-code-image, polaris check-credentials. - Shared shell helpers deduped into scripts/lib/{common,helm,kube,python}.sh; the three env infra-up/deploy-artifacts scripts are now thin orchestrators. - Env-neutral shell moved out of scripts/local: scripts/contracts/ and scripts/artifacts/. Terraform stays the provider-contract source of truth; olf contracts env keeps the exported variable names byte-identical. - make <env>-up is now a full foundation+infra+artifacts wrapper (foundation apply is a Terraform no-op when the cluster exists); former behavior kept as make <env>-stack-up. All granular targets retained. - CI gains a tooling job (ruff + pytest) and uv on the contracts/dbt jobs. - Records ADR 0017; logs the bash check-*/e2e rewrite as follow-up debt. Verified: check-structure, check-contracts, ruff, and 31 pytest pass; contract-env and Floe-profile output diffed byte-identical against the original scripts. * fix: correct AWS region resolution and runtime manifest discovery Address two P1 review findings from the subprocess isolation of the new contract resolver: - olf contracts env resolved AWS_REGION during the pre-contract default pass (storage region still at the us-east-1 default) and never re-derived it once provider contracts set the real region. The old bash saw a shell-local AWS_REGION in-process; the uv subprocess cannot, so a cloud stack kept the stale us-east-1 and mis-targeted ECR. AWS_REGION/AWS_DEFAULT_REGION now follow the resolved storage region unless the caller exported them. Local output stays byte-identical (us-east-1 -> us-east-1). - discover_runtime_manifests only globbed one directory down, but floe-manifest.sh persists the two-level <domain>/<product>/ layout, so direct AWS upload found nothing. It now recurses and takes the domain from the first path segment, matching the original find-based upload. Tests updated (32 pass); local contract-env output diffed byte-identical against the pre-refactor scripts. * fix(polaris): remove orphan helm release and bump floe to 0.6.6 --------- Co-authored-by: a.metwalli <alexis.metwalli_ext@sonepar.com>
Context
The deploy pipeline was ~6,900 lines of bash across
scripts/{local,azure,aws}, with environment-agnostic logic duplicated three times and several concerns embedded as Python heredocs inside shell.scripts/local/*was also acting as shared code for the cloud environments.This splits responsibilities by tool strength:
tools/olf, behind theolfCLI.Recorded in ADR 0017.
What changed
New
tools/olfpackage (uv-managed, ruff + pytest in CI). Each subcommand replaces duplicated/heredoc logic:olfcommandcontracts envemit-contract-env.py+ the defaulting/branching body ofload-runtime-env.shfloe render-profilerender-floe-profile.pyartifacts upload-manifests --via port-forward|directupload-floe-manifest.sh+ AWS's inlineupload_floe_manifests_to_s3()superset deploy-reports/export-reportssuperset-reports-deploy.sh/-export.shopenmetadata deploy-metadataopenmetadata-metadata-deploy.shk8s set-project-code-imagepolaris check-credentialsShared shell helpers deduped into
scripts/lib/{common,helm,kube,python}.sh. The three envinfra-up.sh/deploy-artifacts.share now thin orchestrators.Reorganized so
scripts/local/*no longer doubles as shared code:scripts/contracts/andscripts/artifacts/are env-neutral. Terraform stays the contract source of truth;olf contracts envkeeps exported variable names byte-identical.make <env>-upis now a full wrapper — foundation + infra + artifacts (foundation apply is a Terraform no-op when the cluster exists). Former behavior preserved asmake <env>-stack-up; all granular targets retained.Net: −2,625 / +288 lines in
scripts/, replaced by a tested/linted Python package + 267 lines of shared shell libs. Host gains one prerequisite:uv.Verification
make check-structure,make check-contractspassruff checkclean, 31 pytest passbash -nolf contracts envandolf floe render-profilediffed against the original scripts (local + AWS-shaped envs, with/without Terraform state) — zero diffNot run here (need environment): local e2e (
make local-up, Docker/kind), cloud (make aws-up/make azure-up, sandbox creds).Follow-up (logged in technical-debt.md)
check-*ande2escripts remain bash andcheck-contracts.shgrep-asserts on source text — the natural next step is to rewrite them on top oftools/olf.