Skip to content

Conversation

lllamnyp
Copy link
Member

@lllamnyp lllamnyp commented Aug 12, 2025

What this PR does

The in-tree build of the Kamaji image lacks the appropriate ldflags, resulting in invalid flags of the Kamaji controller manager binary. When a migration job starts, it tries to pull an image with an explicit empty string as a tag, which is invalid. This patch sets the in-tree image as the image for the migration job, both working around this issue, as well as being consistent in the image used.

Release note

[kamaji] Fix broken migration jobs originating from missing environment variables in the in-tree build.

Summary by CodeRabbit

  • Chores
    • Automatically sets the Kamaji migrate image argument during builds to match the configured registry, tag, and digest.
    • Updates deployment values to include the migrate image reference so all Kamaji images are consistently pinned.
    • Reduces manual configuration and improves reliability of deployments and upgrades by ensuring migrate image is kept in sync.

@lllamnyp lllamnyp requested review from kvaps and klinch0 as code owners August 12, 2025 11:27
Copy link
Contributor

coderabbitai bot commented Aug 12, 2025

Note

Other AI code review bot(s) detected

CodeRabbit has detected other AI code review bot(s) in this pull request and will avoid duplicating their findings in the review comments. This may lead to a less comprehensive review.

Walkthrough

Extends the kamaji Makefile image target to compute a migrate-image argument and inject it into values.yaml. Defines REPOSITORY from REGISTRY, reuses TAG with digest from images/kamaji.json, and updates .kamaji.extraArgs[0] via yq. No existing lines removed; logic appended.

Changes

Cohort / File(s) Summary
Build pipeline and config injection
packages/system/kamaji/Makefile
Adds a shell block in the image target to set REPOSITORY="$(REGISTRY)/kamaji", compute TAG including digest from images/kamaji.json, and write .kamaji.extraArgs[0]="--migrate-image=${REPOSITORY}:${TAG}" into values.yaml using yq. Extends existing repository/tag update flow without deletions.

Sequence Diagram(s)

sequenceDiagram
    participant Dev as Developer
    participant MK as Makefile (image target)
    participant IMG as images/kamaji.json
    participant YQ as yq
    participant VY as values.yaml

    Dev->>MK: run image target
    MK->>IMG: read digest/tag
    MK->>MK: set REPOSITORY and TAG
    MK->>YQ: write .kamaji.extraArgs[0]="--migrate-image=REPOSITORY:TAG"
    YQ->>VY: update values.yaml
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~15 minutes

Poem

I hop through Makefiles, quick and keen,
Binding digests to a migrate scene.
A flag tucked neat where configs play,
Values updated, ready to relay.
Carrots & commits, stitched in a stream. 🥕

✨ Finishing Touches
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix/kamaji-migrate-image

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.
    • 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.
  • 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 the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

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

CodeRabbit Commands (Invoked using PR/Issue comments)

Type @coderabbitai help to get the list of available commands.

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

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • 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.

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Summary of Changes

Hello @lllamnyp, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request addresses a critical issue affecting Kamaji migration jobs where the in-tree built image would cause failures due to missing ldflags and attempts to pull an image with an invalid empty tag. The core change involves modifying the Kamaji Makefile to explicitly pass the in-tree built Kamaji image as the --migrate-image argument. This ensures consistency in the image used for migration jobs and directly resolves the underlying problems, allowing migrations to proceed successfully.

Highlights

  • Kamaji Migration Job Fix: Ensures that the in-tree built Kamaji image is explicitly used for migration jobs by setting the --migrate-image argument in the values.yaml file via the Makefile. This resolves issues with invalid image tags and ldflags in the in-tree build.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in issue comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Member

@kvaps kvaps left a comment

Choose a reason for hiding this comment

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

LGTM

@lllamnyp lllamnyp added the backport Should change be backported on previus release label Aug 12, 2025
Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request addresses an issue with Kamaji migration jobs by ensuring the correct in-tree image is used. The change correctly passes the --migrate-image flag. However, the implementation in the Makefile introduces some redundant logic. My review includes a suggestion to refactor the new command for better efficiency and readability by leveraging values already set in the preceding steps.

Comment on lines 30 to 32
REPOSITORY="$(REGISTRY)/kamaji" \
TAG=$(TAG)@$$(yq e '."containerimage.digest"' images/kamaji.json -o json -r) \
yq -i '.kamaji.extraArgs[0] = "--migrate-image=" + strenv(REPOSITORY) + ":" + strenv(TAG)' values.yaml

Choose a reason for hiding this comment

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

medium

This command block re-defines REPOSITORY and re-calculates TAG, which is redundant and inefficient as it involves an extra yq call to get the image digest.

Since the previous commands already update values.yaml with the correct repository and tag, you can simplify this by directly referencing those values within the yq command. This avoids the need to set environment variables and makes the command cleaner.

	yq -i '.kamaji.extraArgs[0] = "--migrate-image=" + .kamaji.image.repository + ":" + .kamaji.image.tag' values.yaml

The in-tree build of the Kamaji image lacks the appropriate ldflags,
resulting in invalid flags of the Kamaji controller manager binary. When
a migration job starts, it tries to pull an image with an explicit empty
string as a tag, which is invalid. This patch sets the in-tree image as
the image for the migration job, both working around this issue, as well
as being consistent in the image used.

Signed-off-by: Timofei Larkin <lllamnyp@gmail.com>
@lllamnyp lllamnyp force-pushed the fix/kamaji-migrate-image branch from 9ee2ff9 to fbc2c45 Compare August 12, 2025 11:31
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

♻️ Duplicate comments (1)
packages/system/kamaji/Makefile (1)

30-30: Good fix: compute migrate-image directly from values.yaml fields

This addresses the earlier redundancy concern by avoiding extra env var interpolation and re-parsing. Clean and maintainable.

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 9ee2ff9 and fbc2c45.

📒 Files selected for processing (1)
  • packages/system/kamaji/Makefile (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: Build
🔇 Additional comments (1)
packages/system/kamaji/Makefile (1)

30-30: Consistent use of :tag@digest across the repo – no change required
A search for @sha256: in all values.yaml files shows many images (including Kamaji) already use the repository:tag@digest format. Kubernetes, Docker, and containerd all accept this combined reference, so you can leave the Makefile as-is. If you do run into pull errors in a particular environment, switch to repository@digest by extracting the digest only.

@@ -27,4 +27,5 @@ image:
yq -i '.kamaji.image.repository = strenv(REPOSITORY)' values.yaml
TAG=$(TAG)@$$(yq e '."containerimage.digest"' images/kamaji.json -o json -r) \
yq -i '.kamaji.image.tag = strenv(TAG)' values.yaml
yq -i '.kamaji.extraArgs[0] = "--migrate-image=" + .kamaji.image.repository + ":" + .kamaji.image.tag' values.yaml
Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Avoid overwriting existing extraArgs; append/update migrate-image idempotently

Setting index 0 will replace whatever the chart/user already specified as the first extra arg. Safer behavior is:

  • ensure extraArgs exists (array),
  • replace existing --migrate-image entry if present,
  • otherwise append a new one.

Apply this diff to make the change idempotent and non-destructive:

-	yq -i '.kamaji.extraArgs[0] = "--migrate-image=" + .kamaji.image.repository + ":" + .kamaji.image.tag' values.yaml
+	yq -i '.kamaji as $k | .kamaji.extraArgs = ($k.extraArgs // []) | .kamaji.extraArgs |= (if any(.[]; startswith("--migrate-image=")) then map(if startswith("--migrate-image=") then "--migrate-image=" + $k.image.repository + ":" + $k.image.tag else . end) else . + ["--migrate-image=" + $k.image.repository + ":" + $k.image.tag] end)' values.yaml
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
yq -i '.kamaji.extraArgs[0] = "--migrate-image=" + .kamaji.image.repository + ":" + .kamaji.image.tag' values.yaml
# packages/system/kamaji/Makefile (line 30)
yq -i '.kamaji as $k | .kamaji.extraArgs = ($k.extraArgs // []) | .kamaji.extraArgs |= (if any(.[]; startswith("--migrate-image=")) then map(if startswith("--migrate-image=") then "--migrate-image=" + $k.image.repository + ":" + $k.image.tag else . end) else . + ["--migrate-image=" + $k.image.repository + ":" + $k.image.tag] end)' values.yaml
🤖 Prompt for AI Agents
In packages/system/kamaji/Makefile around line 30, the current yq command
naively sets extraArgs[0] which can overwrite existing user-provided args;
instead ensure .kamaji.extraArgs exists as an array, search the array for an
element that starts with "--migrate-image=" and replace that element with the
new "--migrate-image=<repo>:<tag>" value, and if no such element exists append
the new entry; implement this with yq in an idempotent way so running it
multiple times neither duplicates entries nor clobbers other extraArgs.

@kvaps kvaps merged commit 992162f into main Aug 12, 2025
10 of 11 checks passed
@kvaps kvaps deleted the fix/kamaji-migrate-image branch August 12, 2025 12:35
Copy link

Successfully created backport PR for release-0.34:

kvaps added a commit that referenced this pull request Aug 12, 2025
@coderabbitai coderabbitai bot mentioned this pull request Aug 18, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport Should change be backported on previus release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants