Skip to content

Commit

Permalink
feat: Allow fresh rechunking of image
Browse files Browse the repository at this point in the history
  • Loading branch information
gmpinder committed Dec 14, 2024
1 parent 4103184 commit 27008ac
Show file tree
Hide file tree
Showing 7 changed files with 33 additions and 8 deletions.
1 change: 1 addition & 0 deletions .github/workflows/build-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
5 changes: 2 additions & 3 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
9 changes: 9 additions & 0 deletions justfile
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand Down
3 changes: 3 additions & 0 deletions process/drivers/opts/rechunk.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,7 @@ pub struct RechunkOpts<'scope> {
#[builder(default)]
pub compression: CompressionType,
pub tempdir: Option<&'scope Path>,

#[builder(default)]
pub clear_plan: bool,
}
2 changes: 1 addition & 1 deletion process/drivers/traits.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
19 changes: 15 additions & 4 deletions src/commands/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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},
Expand Down Expand Up @@ -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)]
Expand Down Expand Up @@ -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 {
Expand Down
2 changes: 2 additions & 0 deletions utils/src/constants.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down

0 comments on commit 27008ac

Please sign in to comment.