-
Notifications
You must be signed in to change notification settings - Fork 119
[kamaji] Pass in-tree image as migrate-image #1338
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Note Other AI code review bot(s) detectedCodeRabbit 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. WalkthroughExtends 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
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
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~15 minutes Poem
✨ Finishing Touches🧪 Generate unit tests
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. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. CodeRabbit Commands (Invoked using PR/Issue comments)Type Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this 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 thevalues.yaml
file via the Makefile. This resolves issues with invalid image tags andldflags
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
-
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. ↩
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
There was a problem hiding this 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.
packages/system/kamaji/Makefile
Outdated
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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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>
9ee2ff9
to
fbc2c45
Compare
There was a problem hiding this 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 fieldsThis 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
📒 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 allvalues.yaml
files shows many images (including Kamaji) already use therepository: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 torepository@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 |
There was a problem hiding this comment.
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.
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.
Successfully created backport PR for |
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
Summary by CodeRabbit