Skip to content

many: make two builds of core26, one with and one without cloud-init#423

Merged
alfonsosanchezbeato merged 14 commits intocanonical:mainfrom
alfonsosanchezbeato:separate-cloud-init
Apr 6, 2026
Merged

many: make two builds of core26, one with and one without cloud-init#423
alfonsosanchezbeato merged 14 commits intocanonical:mainfrom
alfonsosanchezbeato:separate-cloud-init

Conversation

@alfonsosanchezbeato
Copy link
Copy Markdown
Member

No description provided.

Make building core26 with cloud-init optional: do not include by default but
build with it when the cloud-init-build marker file exists. This allows
building variants with or without cloud-init support from the same codebase.
Add logic to automatically detect cloud-init builds based on branch
naming convention. A marker file is created when the current branch
ends with '-cloud-init', enabling conditional inclusion of
cloud-init in the build.
as now we have snaps published in that channel.
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR introduces a build-time “variant” mechanism for core26 so CI/CD can produce two base snaps: one that includes cloud-init and one that excludes it.

Changes:

  • Add a cloud-init-build marker-file mechanism to toggle cloud-init inclusion during snap build.
  • Update hook execution to conditionally apply cloud-init-specific configuration and unit enablement based on SNAP_CLOUD_INIT_BUILD.
  • Matrix GitHub Actions workflows to build/test both “regular” and “cloud-init” variants (with skips for bases where cloud-init is already default).

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
tests/lib/prepare-utils.sh Creates cloud-init-build marker during spread build based on BUILD_VARIANT.
snapcraft.yaml Conditionally includes cloud-init_bins slice when marker exists; adds slices needed when cloud-init isn’t default; updates build-snaps to core26.
Makefile Exports SNAP_CLOUD_INIT_BUILD for hook scripts based on marker presence.
hooks/011-cloud-init-config.chroot Runs cloud-init-specific config edits only when SNAP_CLOUD_INIT_BUILD=true.
hooks/005-initialize-systemd.chroot Conditionally enables cloud-init systemd units based on SNAP_CLOUD_INIT_BUILD.
.github/workflows/tests.yaml Adds a build/test matrix over variant: [regular, cloud-init] and variant-scoped artifact names.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 229 to 233
cd "$project_dir"
if [ "$BUILD_VARIANT" = cloud-init ]
then touch cloud-init-build
fi
snapcraft pack --verbosity verbose
Copy link

Copilot AI Apr 2, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

build_base_snap creates cloud-init-build when BUILD_VARIANT=cloud-init, but it never removes the marker when building the regular variant. If the same project_dir is reused across builds (e.g., local dev running both variants in sequence), the marker can persist and cause a "regular" build to accidentally include cloud-init. Consider explicitly removing cloud-init-build (or building in a clean directory) when BUILD_VARIANT is not cloud-init.

Copilot uses AI. Check for mistakes.
Comment on lines 100 to 111
tests-snapd:
runs-on: ubuntu-latest
needs: build
strategy:
fail-fast: false
matrix:
variant: [regular, cloud-init]
# Skip cloud-init variant for bases that had it included by default
if: ${{ !((startsWith(github.ref_name, 'core22') || startsWith(github.ref_name, 'core24')) && matrix.variant == 'cloud-init') }}
env:
BUILD_VARIANT: ${{ matrix.variant }}
steps:
Copy link

Copilot AI Apr 2, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tests-snapd is now matrixed over variant: [regular, cloud-init], but the image boot/SSH helper (tests/lib/prepare-utils.sh) SSHes as user test@localhost (created via cloud-init config) and the workflow still relies on prepare_base_cloudinit to inject a cloud-init config into the gadget. The "regular" variant (intended to be built without cloud-init) is likely to never create the test user, causing the VM boot step to time out. Consider running tests-snapd only for the cloud-init variant (or updating the VM/user provisioning to not depend on cloud-init for the regular build).

Copilot uses AI. Check for mistakes.
# recipe, and then removed.
(
cd "$CRAFT_PROJECT_DIR"
if git branch --show-current | grep '.*-cloud-init$'
Copy link

Copilot AI Apr 2, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The branch detection pipeline will print the branch name into the build logs because grep is not quiet. Using grep -q (and potentially anchoring to -cloud-init$ without .*) would avoid noisy output while keeping the same behavior.

Suggested change
if git branch --show-current | grep '.*-cloud-init$'
if git branch --show-current | grep -q -- '-cloud-init$'

Copilot uses AI. Check for mistakes.
@alfonsosanchezbeato alfonsosanchezbeato force-pushed the separate-cloud-init branch 3 times, most recently from eb0cb7b to 3deb55c Compare April 2, 2026 20:57
Add base-variant input parameter to run-spread-tests action to
support different base image types (regular or cloud-init). Export
BUILD_VARIANT environment variable and pass the variant through
workflow test jobs. Also update external tests to use
ubuntu-core-26-64 and remove inline cloud-init preparation in favor
of variant-based approach.
Add conditional SSH authentication based on BUILD_VARIANT (cloud-init vs
system-user).
as in some cases we hack the user into a script inside the snapd snap.
What we have now is invalid if installing from the initramfs.
Only run tests for one variant since the user is introduced by modifying the
snapd snap, and neither cloud-init nor system-user assertions are used.
- Define SSH_PRIVATE_KEY variable at the top of the file Replace
- hardcoded path with variable reference in execute_remote Add chmod
- to fix permissions when file is copied (repo permissions not
- respected) ```
@alfonsosanchezbeato alfonsosanchezbeato merged commit d8dcd1d into canonical:main Apr 6, 2026
5 of 6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants