From 5f34ac82c6976c203b87f140e5206602f259ea54 Mon Sep 17 00:00:00 2001 From: Gerald Pinder Date: Sat, 14 Dec 2024 16:25:06 -0500 Subject: [PATCH] feat: Allow fresh rechunking of image --- .github/workflows/build-pr.yml | 1 + .github/workflows/build.yml | 5 ++--- justfile | 9 +++++++++ process/drivers/opts/rechunk.rs | 3 +++ process/drivers/traits.rs | 2 +- src/commands/build.rs | 9 +++++++++ 6 files changed, 25 insertions(+), 4 deletions(-) diff --git a/.github/workflows/build-pr.yml b/.github/workflows/build-pr.yml index 348e9fbf..1cf66ceb 100644 --- a/.github/workflows/build-pr.yml +++ b/.github/workflows/build-pr.yml @@ -296,6 +296,7 @@ jobs: COSIGN_PRIVATE_KEY: ${{ secrets.TEST_SIGNING_SECRET }} run: | export CARGO_HOME=$HOME/.cargo + just test-fresh-rechunk-build just test-rechunk-build arm64-build: diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index d00c2090..dc7ee527 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -333,10 +333,9 @@ jobs: GH_PR_EVENT_NUMBER: ${{ github.event.number }} COSIGN_PRIVATE_KEY: ${{ secrets.TEST_SIGNING_SECRET }} run: | - just install-debug-all-features - cd integration-tests/test-repo export CARGO_HOME=$HOME/.cargo - sudo -E $CARGO_HOME/bin/bluebuild build --push -vv --rechunk recipes/recipe-rechunk.yml + just test-fresh-rechunk-build + just test-rechunk-build arm64-build: timeout-minutes: 40 diff --git a/justfile b/justfile index 8128c787..21b7b4e7 100644 --- a/justfile +++ b/justfile @@ -155,6 +155,15 @@ test-rechunk-build: install-debug-all-features --rechunk \ recipes/recipe-rechunk.yml +test-fresh-rechunk-build: install-debug-all-features + cd integration-tests/test-repo \ + && sudo -E {{ cargo_bin }}/bluebuild build \ + {{ should_push }} \ + -vv \ + --rechunk \ + --fresh-rechunk \ + recipes/recipe-rechunk.yml + # Run arm integration test test-arm64-build: install-debug-all-features cd integration-tests/test-repo \ diff --git a/process/drivers/opts/rechunk.rs b/process/drivers/opts/rechunk.rs index e85d909e..82f9b84a 100644 --- a/process/drivers/opts/rechunk.rs +++ b/process/drivers/opts/rechunk.rs @@ -45,4 +45,7 @@ pub struct RechunkOpts<'scope> { #[builder(default)] pub compression: CompressionType, pub tempdir: Option<&'scope Path>, + + #[builder(default)] + pub clear_plan: bool, } diff --git a/process/drivers/traits.rs b/process/drivers/traits.rs index bdccafd9..4eaaa89c 100644 --- a/process/drivers/traits.rs +++ b/process/drivers/traits.rs @@ -442,7 +442,7 @@ pub trait RechunkDriver: RunDriver + BuildDriver + ContainerMountDriver { "REPO" => "/var/ostree/repo", "PREV_REF" => &*opts.image, "OUT_NAME" => ostree_cache_id, - // "PREV_REF_FAIL" => "true", + "CLEAR_PLAN" => if opts.clear_plan { "true" } else { "" }, "VERSION" => format!("{}", opts.version), "OUT_REF" => format!("oci:{ostree_cache_id}"), "GIT_DIR" => "/var/git", diff --git a/src/commands/build.rs b/src/commands/build.rs index 36b4be24..413ff6b9 100644 --- a/src/commands/build.rs +++ b/src/commands/build.rs @@ -120,6 +120,14 @@ pub struct BuildCommand { #[cfg(feature = "rechunk")] rechunk: bool, + /// Use a fresh rechunk plan, regardless of previous ref. + /// + /// NOTE: Only works with `--rechunk`. + #[arg(long)] + #[builder(default)] + #[cfg(feature = "rechunk")] + clear_plan: bool, + /// The location to temporarily store files /// while building. If unset, it will use `/tmp`. #[arg(long)] @@ -359,6 +367,7 @@ impl BuildCommand { .description(&*recipe.description) .base_image(format!("{}:{}", &recipe.base_image, &recipe.image_version)) .maybe_tempdir(self.tempdir.as_deref()) + .clear_plan(self.clear_plan) .build(), )? } else {