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..3a5c90e5 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 \ + --rechunk-clear-plan \ + 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..e143578c 100644 --- a/src/commands/build.rs +++ b/src/commands/build.rs @@ -14,8 +14,8 @@ use blue_build_process_management::{ use blue_build_recipe::Recipe; use blue_build_utils::{ constants::{ - ARCHIVE_SUFFIX, BB_REGISTRY_NAMESPACE, CONFIG_PATH, CONTAINER_FILE, RECIPE_FILE, - RECIPE_PATH, + ARCHIVE_SUFFIX, BB_BUILD_RECHUNK, BB_BUILD_RECHUNK_CLEAR_PLAN, BB_REGISTRY_NAMESPACE, + CONFIG_PATH, CONTAINER_FILE, RECIPE_FILE, RECIPE_PATH, }, cowstr, credentials::{Credentials, CredentialsArgs}, @@ -111,15 +111,25 @@ pub struct BuildCommand { squash: bool, /// Performs rechunking on the image to allow for smaller images - /// and smaller updates. This will increase the build-time + /// and smaller updates. + /// + /// WARN: This will increase the build-time /// and take up more space during build-time. /// /// NOTE: This must be run as root! - #[arg(long, group = "archive_rechunk")] + #[arg(long, group = "archive_rechunk", env = BB_BUILD_RECHUNK)] #[builder(default)] #[cfg(feature = "rechunk")] rechunk: bool, + /// Use a fresh rechunk plan, regardless of previous ref. + /// + /// NOTE: Only works with `--rechunk`. + #[arg(long, env = BB_BUILD_RECHUNK_CLEAR_PLAN)] + #[builder(default)] + #[cfg(feature = "rechunk")] + rechunk_clear_plan: bool, + /// The location to temporarily store files /// while building. If unset, it will use `/tmp`. #[arg(long)] @@ -359,6 +369,7 @@ impl BuildCommand { .description(&*recipe.description) .base_image(format!("{}:{}", &recipe.base_image, &recipe.image_version)) .maybe_tempdir(self.tempdir.as_deref()) + .clear_plan(self.rechunk_clear_plan) .build(), )? } else { diff --git a/utils/src/constants.rs b/utils/src/constants.rs index 80966cae..ef97b69c 100644 --- a/utils/src/constants.rs +++ b/utils/src/constants.rs @@ -22,6 +22,8 @@ pub const BB_PRIVATE_KEY: &str = "BB_PRIVATE_KEY"; pub const BB_REGISTRY: &str = "BB_REGISTRY"; pub const BB_REGISTRY_NAMESPACE: &str = "BB_REGISTRY_NAMESPACE"; pub const BB_USERNAME: &str = "BB_USERNAME"; +pub const BB_BUILD_RECHUNK: &str = "BB_BUILD_RECHUNK"; +pub const BB_BUILD_RECHUNK_CLEAR_PLAN: &str = "BB_BUILD_RECHUNK_CLEAR_PLAN"; // Docker vars pub const DOCKER_HOST: &str = "DOCKER_HOST";