Repository navigation
Generate Cosmos Boost sidecars into the deploy bundle, not the project, and retire astro dbt cleanup - #2311
Merged
Conversation
…t, and retire astro dbt cleanup The pre-deploy step produces its .astro/dbt_metadata.json and .astro/manifest.slim.json in memory, and the bundle tarball carries them at the same paths with the same bytes, through a TarOverlay on fileutil.Tar. Nothing is written into the user's tree. Every bundle deploy leaves out the sidecars an earlier CLI wrote into the tree (producer marker "astro"), enabled or not, so a stale one never ships. One from an unrecognized producer still stops an enabled deploy, and ships untouched when the step is off. With nothing left to clean, astro dbt cleanup becomes a removed-command stub, and its cleanup code, json shape and golden go. Co-Authored-By: Claude <noreply@anthropic.com>
Coverage Report for CI Build 38606515661Coverage decreased (-0.04%) to 57.861%Details
Uncovered Changes
Coverage Regressions4 previously-covered lines in 3 files lost coverage.
Coverage Stats
💛 - Coveralls |
…t of generated images The bundle judges each .astro/dbt_metadata.json and manifest.slim.json by its producer marker inside Tar's own walk (TarOverlay.Skip), rather than in a separate pre-scan: what it leaves out is exactly what the tarball would have carried (one under logs/ too), and a deploy with the step off never fails over Cosmos Boost - a missing dags/ makes the empty tarball it always did. A foreign file still refuses an enabled deploy, now even where a fresh sidecar would replace it. The predicate lives in pkg/airflowrt, a leaf both the root module and pkg/imagebuild already require. A generated image's project copy (and its survey and tag digest) leaves the same files out; a declared Dockerfile's context carrying them is warned about, naming them. Tar names entries with filepath.Rel, so a source of "." (astro dbt deploy --project-path .) names .astro/ and other dotfiles right. A directory or link where a sidecar goes fails that unit instead of colliding with it in the bundle. The dbt cleanup stub says what v2 does now, and why old files are still worth deleting by hand. Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Claude <noreply@anthropic.com>
…decar paths, and keep the tarball out of the bundle UploadBundle writes the tarball to a temporary directory of its own. It used to land in the working directory, which under astro dbt deploy --project-path . is the directory being bundled, so it could carry itself. Tar asks the overlay's Skip about every entry, links and directories too, and anything at a sidecar's path that is not a regular file is left out with a warning. With the step on, a link there is replaced by the fresh sidecar; a directory cannot be, so that unit fails. A generated image leaves them out the same way, and a declared Dockerfile's survey names them for its warning. The foreign-producer refusal now covers only the .astro/ of a unit the step stamps, where the plugin reads, and runs on those few paths before anything is hashed, so it comes before any "step complete". One under dbt_packages/ or logs/ is the project's file and ships. precompute takes the sidecar directory, names and producer from airflowrt, and the marker check stream-decodes only the marker. Run splits into Discover and Units.Run so the check sees the units first. Co-Authored-By: Claude <noreply@anthropic.com>
…e gzipped file The foreign-producer refusal is decided from the paths this deploy actually writes a fresh sidecar to, after the step runs and before it reports complete; a foreign file anywhere else ships. That drops the separate pre-hash check and the Discover/SidecarDirs split. With the step off, only regular files an Astro CLI wrote are left out; links and everything else at a sidecar path ship as they are, in the bundle and in a generated image. With it on, whatever is at an artifact's path, a link or a directory too, is left out for the fresh sidecar; a unit fails only when its .astro is not a directory. The producer check goes back to unmarshaling the bytes already read. UploadBundle streams tar into gzip into one file (fileutil.TarGz) and checks every close, so a full disk fails the deploy instead of uploading a truncated bundle. Co-Authored-By: Claude <noreply@anthropic.com>
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Why
With
cosmos_boost.pre_deployon, every bundle deploy wrote.astro/dbt_metadata.json(and.astro/manifest.slim.jsonbeside each dbt manifest) into the user's dbt project. That left generated files in the repo to commit or ignore. Turning the setting off left them in place, and the next deploy shipped them stale, which is whyastro dbt cleanupexisted.The sidecars now go into the deploy bundle only. Nothing is written into the project, so there is no repo churn and nothing to clean up.
What changes
precompute.Runreturns its artifacts instead of writing them), andfileutil.TarGzadds them to the bundle through aTarOverlay. They land at the same relative paths, with the same bytes, that were written into the tree before..astroitself is not a directory.manifest.jsonthat is not dbt's;dbt_packages/orlogs/;.astro/dbt_metadata.json/.astro/manifest.slim.jsonwhose own producer marker names this tool is left out. It is judged by aSkippredicate inside the tarball's own walk, so:dags/makes the empty tarball it always did).pkg/imagebuild's project copy, which carriesdags/since Carry the project's files in the image a deploy or astro package generates #2302/Keep secrets out of shipped images, and deploy to DAG-deploy-off Deployments #2306, leaves the same files out of the copy, the survey and the tag digest.pkg/airflowrt, which both the root module andpkg/imagebuildalready require.precomputeuses those constants.astro dbt cleanupis now a removed-command stub (cliout.RemovedCommand, the Guard removed 1.x commands in CI, and give bundle create/update/delete -o json #2291 pattern). It is a usage error, exit 2, and under-o jsonthe one error object. It says v2 no longer writes Cosmos Boost files into the project and leaves out old ones from every bundle and generated image. It also says to delete any old ones by hand, since a local Airflow running the plugin, or a declared Dockerfile build, may still read them. It still satisfiesTestEveryV1CommandStillRunsOrSaysWhatReplacedIt.cosmosboost.Cleanup/EnsureClean/BestEffortPreDeploy/PreDeploy,precompute.Cleanupand its report, the on-disk writers,dbtCleanupJSONand its goldencmd/astro/testdata/schema/dbt-cleanup.json. Astro Desktop does not usepkg/cosmosboost.UploadBundlestreams tar into gzip into one file, in a temporary directory of its own. That directory is never the one being bundled, so the tarball cannot carry itself, which--project-path .used to allow.filepath.Rel, so a source of.names.astro/...and other dotfiles correctly.Plugin contract: unchanged
Same paths (
<unit>/.astro/dbt_metadata.json,<unit>/.astro/manifest.slim.json), same JSON, same hash algorithms. The project hash already excludes.astroat any depth, so whether a stale sidecar sits in the tree does not change it. When a DAG deploy prependsdags/, the sidecars sit under it like every other file.Tests
pkg/cosmosboost, through a real tarball:precompute.Runbyte for byte, and the tree snapshot is unchanged;logs/and orphans;manifest.json,dbt_packages/,logs/, slim off);pkg/cosmosboost/precompute:Runwrites nothing, a file named.astrofails the unit, and whatever sits at an artifact path is replaced. The existing hash and slim tests are kept.pkg/airflowrt: the predicate, including duplicate keys and malformed input.pkg/imagebuild: the generated image leaves stale sidecars out of the survey, copy and digest; a declared survey names them.internal/shipcheck: the declared-Dockerfile warning.pkg/fileutil:TarGzwith the overlay, source., aSkiperror, and a compressed stream that fails at close.internal/platform/astro/deploy:UploadBundle/DeployBundledecode the upload and check:dags/with the feature off and on;--project-path .from the working directory gives only the fresh sidecar and no tarball inside.cmd/astro: thedbt cleanupstub in text and-o json, and it touches nothing.Notes
pkg/cosmosboostalso lives onmain, so future main→v2 syncs may conflict there.