Skip to content

[519] Cross-arch builds: builders variables - #907

Merged
Timofei Larkin (lllamnyp) merged 10 commits into
mainfrom
519-cross-arch-build
May 12, 2025
Merged

Timofei Larkin (lllamnyp) merged 10 commits into
mainfrom
519-cross-arch-build

Conversation

@nbykov0

@nbykov0 Nikita (nbykov0) commented Apr 30, 2025 •

Copy link
Copy Markdown
Collaborator

Added PLATFORM variable to common-envs.mk: if not defined, it is calculated based on docker daemon arch.
May be overridden by e.g. make -e PLATFORM='linux/arm64' ...
Added the variable to a single Dockerfile for now.

Summary by CodeRabbit

  • Chores
    • Improved Docker build process to automatically detect and use the current builder and supported platforms, enhancing consistency and flexibility for multi-platform builds. No changes to user-facing features.

@coderabbitai

coderabbitai Bot commented Apr 30, 2025 •

Copy link
Copy Markdown
Contributor

Walkthrough

The changes introduce dynamic detection of the Docker buildx builder and supported platforms in a shared Makefile snippet. These new variables are then used in the Docker build command for the CozyStack controller, ensuring explicit specification of builder and platform during image builds.

Changes

File(s) Change Summary
scripts/common-envs.mk Added logic to dynamically set BUILDER and PLATFORM variables based on Docker buildx environment.
packages/system/cozystack-controller/Makefile Updated Docker buildx command to use new --builder=$(BUILDER) and --platform=$(PLATFORM) options.

Sequence Diagram(s)

sequenceDiagram
    participant Developer
    participant Makefile
    participant Docker Buildx

    Developer->>Makefile: Invoke build target
    Makefile->>Makefile: Set BUILDER and PLATFORM variables (dynamic detection)
    Makefile->>Docker Buildx: Build image with --builder and --platform options
    Docker Buildx-->>Makefile: Build process completes
    Makefile-->>Developer: Build result
Loading

Poem

In the warren where builds are spun,
Rabbits now choose builders—oh, what fun!
Platforms detected, no guessing game,
Docker images built, always the same.
With paws on the keys and whiskers a-twitch,
The stack hops forward, smooth and rich! 🐇

Tip

⚡️ Faster reviews with caching
  • CodeRabbit now supports caching for code and dependencies, helping speed up reviews. This means quicker feedback, reduced wait times, and a smoother review experience overall. Cached data is encrypted and stored securely. This feature will be automatically enabled for all accounts on May 16th. To opt out, configure Review - Disable Cache at either the organization or repository level. If you prefer to disable all data retention across your organization, simply turn off the Data Retention setting under your Organization Settings.

Enjoy the performance boost—your workflow just got faster.


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 3067bd1 and 2349ff6.

📒 Files selected for processing (2)
  • packages/system/cozystack-controller/Makefile (1 hunks)
  • scripts/common-envs.mk (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
  • scripts/common-envs.mk
  • packages/system/cozystack-controller/Makefile
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: Build and Test

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@nbykov0 Nikita (nbykov0) self-assigned this Apr 30, 2025
Comment thread packages/system/cozystack-controller/Makefile
Comment thread scripts/common-envs.mk Outdated

@lllamnyp Timofei Larkin (lllamnyp) left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The general direction I want to go in is that the GitHub actions for building Cozystack don't change too much, but any developer, who doesn't have access to our cloud runners can also just set up a buildx builder, pass in the right values for PLATFORMS and/or BUILDER and also get good results.

@nbykov0

Copy link
Copy Markdown
Collaborator Author

pass in the right values for PLATFORMS and/or BUILDER and also get good results.

Now it works like this:

  • specify BUILDER. The selected one (default of selected with docker buildx use) is used if not specified
  • optionally specify PLATFORM. It will be calculated based on builder supported platforms if not specified

Comment thread scripts/common-envs.mk Outdated
@nbykov0 Nikita (nbykov0) changed the title [519] Cross-arch builds for images [519] Cross-arch builds for images: builders variables May 6, 2025
@nbykov0
Nikita (nbykov0) marked this pull request as ready for review May 6, 2025 13:33

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (1)
packages/system/cozystack-controller/Makefile (1)

12-13: Cross-arch build support correctly implemented

These changes correctly implement the cross-architecture build support by using the dynamically determined builder and platform variables from common-envs.mk.

Consider adding a comment above these new options explaining the cross-architecture build functionality, for example:

	docker buildx build -f images/cozystack-controller/Dockerfile ../../.. \
		--provenance false \
+		# Use specified or detected buildx builder and platforms for cross-architecture builds
		--builder=$(BUILDER) \
		--platform=$(PLATFORM) \
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between c482289 and b32d654.

📒 Files selected for processing (2)
  • packages/system/cozystack-controller/Makefile (1 hunks)
  • scripts/common-envs.mk (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: Build and Test
🔇 Additional comments (1)
scripts/common-envs.mk (1)

18-23:

Details

❓ Verification inconclusive

Solid approach for dynamically determining builder and platforms

The implementation for determining the Docker buildx builder and supported platforms is well thought out. Using the buildx inspect command to extract platform information is a practical approach.

A few considerations:

  1. The parsing of command output (egrep, sort, sed) is functional but potentially brittle if Docker CLI output formats change
  2. The commented-out JSON parsing alternative could be more stable long-term, as previously discussed in the PR comments

🏁 Script executed:

#!/bin/bash
# Verify that the platform detection works correctly with various builder setups

echo "Testing platform detection..."
BUILDER=$(jq -r '.Name' ~/.docker/buildx/current 2>/dev/null || echo "default")
echo "Current builder: $BUILDER"

# Verify the platform detection works
PLATFORMS=$(docker buildx inspect --bootstrap $BUILDER 2>/dev/null | egrep '^Platforms:' | egrep -o 'linux/amd64|linux/arm64' | sort -u | xargs | sed 's/ /,/g')
echo "Detected platforms: $PLATFORMS"

# Verify that the command doesn't break with different builders
docker buildx ls | awk '{print $1}' | grep -v "^NAME" | while read builder; do
  echo "Testing with builder: $builder"
  PLATFORMS=$(docker buildx inspect --bootstrap $builder 2>/dev/null | egrep '^Platforms:' | egrep -o 'linux/amd64|linux/arm64' | sort -u | xargs | sed 's/ /,/g')
  echo "  - Detected platforms: $PLATFORMS"
done

Length of output: 590


Manual verification required for Docker Buildx platform detection

The sandbox environment doesn’t include Docker or Buildx, so the verification script couldn’t produce any platforms. Please test this locally in an environment with Docker Buildx installed:

  • Run
    BUILDER=$(jq -r '.Name' ~/.docker/buildx/current)
    docker buildx inspect --bootstrap "$BUILDER" \
      | egrep '^Platforms:' \
      | egrep -o 'linux/amd64|linux/arm64' \
      | sort -u \
      | xargs | sed 's/ /,/g'
    and confirm it outputs the expected comma-separated platforms.
  • Repeat for each builder returned by docker buildx ls.
  • Evaluate the commented JSON-parsing alternative:
    PLATFORM ?= $(shell jq -r '.Nodes[] | .Platforms | map(.os + "/" + .architecture) | join(",")' \
      ~/.docker/buildx/instances/$(BUILDER))
    to see if it yields more stable results over future Docker CLI changes.

@NickVolynkin

Copy link
Copy Markdown
Contributor

Nikita (@nbykov0) DCO check failed, please do git commit --amend --signoff

@nbykov0
Nikita (nbykov0) marked this pull request as draft May 6, 2025 14:20
@nbykov0

Copy link
Copy Markdown
Collaborator Author

I've messed a bit while rebasing, commit 243fb41 is included in my PR.
Does not seem like it breaks something; at the same time I might break more thing while fixing it.

@nbykov0
Nikita (nbykov0) marked this pull request as ready for review May 7, 2025 20:42

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (1)
packages/core/platform/bundles/paas-full.yaml (1)

137-141: Ensure cpuAllocationRatio is documented and validated in the Helm chart.

The bundle correctly pulls cpu-allocation-ratio from the cozystack ConfigMap into the kubevirt release values when present. As a follow-up:

  1. Confirm that the cozy-kubevirt chart’s values.yaml declares cpuAllocationRatio (with a default, type, and description) so it’s discoverable in docs.
  2. Run helm lint packages/core/platform/bundles/paas-full.yaml and helm template on your bundle to verify rendering.

Optionally, add to packages/system/kubevirt/values.yaml:

cpuAllocationRatio: null  # CPU overcommit ratio for KubeVirt (e.g. 1.5, 2.0)
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between b32d654 and 7fbe18b.

📒 Files selected for processing (4)
  • packages/core/platform/bundles/paas-full.yaml (1 hunks)
  • packages/system/cozystack-controller/Makefile (1 hunks)
  • packages/system/kubevirt/templates/kubevirt-cr.yaml (1 hunks)
  • scripts/common-envs.mk (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
  • packages/system/cozystack-controller/Makefile
  • scripts/common-envs.mk
🧰 Additional context used
🪛 YAMLlint (1.35.1)
packages/system/kubevirt/templates/kubevirt-cr.yaml

[warning] 14-14: wrong indentation: expected 4 but found 6

(indentation)


[error] 13-13: syntax error: expected the node content, but found '-'

(syntax)

⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: Build and Test
🔇 Additional comments (1)
packages/system/kubevirt/templates/kubevirt-cr.yaml (1)

13-15: Conditional inclusion of cpuAllocationRatio is correct; ignore YAMLlint false positives.

The Helm snippet properly wraps cpuAllocationRatio under developerConfiguration only when .Values.cpuAllocationRatio is set. The indentation (6 spaces under developerConfiguration) aligns with sibling keys like featureGates. The YAMLlint errors here are false positives caused by Helm directives and can be safely ignored.

Please validate via Helm:

helm lint packages/system/kubevirt
helm template test-release packages/system/kubevirt
🧰 Tools
🪛 YAMLlint (1.35.1)

[warning] 14-14: wrong indentation: expected 4 but found 6

(indentation)


[error] 13-13: syntax error: expected the node content, but found '-'

(syntax)

@nbykov0 Nikita (nbykov0) changed the title [519] Cross-arch builds for images: builders variables [519] Cross-arch builds: builders variables May 9, 2025
@nbykov0 Nikita (nbykov0) linked an issue May 10, 2025 that may be closed by this pull request
@lllamnyp Timofei Larkin (lllamnyp) added the ok-to-test Indicates a non-member PR is safe to run CI on label May 12, 2025
@lllamnyp
Timofei Larkin (lllamnyp) deleted the 519-cross-arch-build branch May 12, 2025 09:08
Timofei Larkin (lllamnyp) added a commit that referenced this pull request May 20, 2025
Added PLATFORM variable to `common-envs.mk`: if not defined, it is
calculated based on docker daemon arch.
May be overridden by e.g. `make -e PLATFORM='linux/arm64' ...`
Added the variable to a single Dockerfile for now.

(cherry picked from commit 653e2bc)
Signed-off-by: Timofei Larkin <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ok-to-test Indicates a non-member PR is safe to run CI on

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants