fix(render): do not overwrite function docker network if set, start crossplane-container in same network#65
fix(render): do not overwrite function docker network if set, start crossplane-container in same network#65nkzk wants to merge 12 commits into
Conversation
|
Thanks for the PR, @nkzk! Would you mind creating an issue for this as well, for discoverability and tracking? I haven't reviewed in detail yet, but the described fixes sound reasonable. |
cad5894 to
abb26bd
Compare
|
I see that there are already tests for passing function annotations to the engine. I had copilot help me create unit tests for injectNetworkAnnotations. Also ran flake check. |
|
Hmm, i got it to work in a devcontainer with this fix, but the current implemention has some issues in CI. But i think this can be solved on the user-side. One of our earliest approaches was to start up functions as service-containers before running multiple/different renders, and it worked because gitlab/github connects the job-container to the bridge-network used by service-containers. But since crossplane render will start up crossplane in another temporary bridge network, it doesnt seem that this will continue to work. However, my theory is that the user can specify the docker-network in their CI-provider (gitlab/github), and then specify the the docker-network flag in the crossplane render command with the fix in this branch to solve this. We have another workflow which uses rootless DinD/PinP, but kind of the same issue there. I'll do some more testing soon. But let me know if something i say sounds off :D |
Signed-off-by: Nikita Z <nkzk95@gmail.com>
…ntainer in it Signed-off-by: Nikita Z <nkzk95@gmail.com>
Signed-off-by: Nikita Z <nkzk95@gmail.com>
Signed-off-by: Nikita Z <nkzk95@gmail.com>
Signed-off-by: Nikita Z <nkzk95@gmail.com>
669f038 to
396a2d1
Compare
|
Think this PR is ready for review, i did some more testing in CI and did not completely figure it out yet, but i think its just an issue of configuring the docker-network in CI and setting that value as the function-docker-network flag in the render-command. A quality of life improvement for us would be if we can spin up the crossplane container ourselves and make render use it. If we could configure the crossplane-containerthe same way as functions, with the development annotation to manage the container lifecycle ourselves, it would just simplify this alot for us. But maybe its out of scope for this PR, i'm not sure whats the best way to implement this would be. But open to work on it if someone has some ideas. |
Signed-off-by: Nikita Z <nkzk95@gmail.com>
|
Warning Review limit reached
More reviews will be available in 30 minutes and 35 seconds. Learn how PR review limits work. Your organization has run out of usage credits. Purchase more credits in the billing tab to continue. ⌛ How to resolve this issue?After more reviews become available, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available. Please see our Fair Usage Limits Policy for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (3)
📝 WalkthroughWalkthroughThis PR extends the render engine to accept an optional preconfigured Docker network, avoiding automatic temporary network creation and annotation overwrites. Commands now parse function and CLI annotations to populate the network parameter, enabling callers to reuse networks across renders. ChangesDocker network preconfiguration support
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related issues
Suggested reviewers
🚥 Pre-merge checks | ✅ 5 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. 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. Comment |
…tions in comment Signed-off-by: Nikita Z <nkzk95@gmail.com>
@nkzk Good thought - I can see how this would be useful. It's a little tricky, since the crossplane container in For your use-case, would it be easier to download a crossplane binary and use the |
adamwg
left a comment
There was a problem hiding this comment.
Thanks for filing an issue for this, and for the fix. A few comments inline, but the overall approach looks good to me.
Signed-off-by: Nikita Z <nkzk95@gmail.com>
…lags if empty, default to the first docker-network annotation in the provided functions. If provided, the docker-network annotation in the FunctionAnnotations cli flag takes presedence Signed-off-by: Nikita Z <nkzk95@gmail.com>
…aneDockerNetwork Signed-off-by: Nikita Z <nkzk95@gmail.com>
Signed-off-by: Nikita Z <nkzk95@gmail.com>
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
cmd/crossplane/render/engine.go (1)
67-71: ⚡ Quick winUpdate stale constructor docs after signature change.
Could you update this comment? On Line 69 it still mentions a
network parameter, butNewEngineFromFlagsnow derives this fromEngineFlags.CrossplaneDockerNetwork.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@cmd/crossplane/render/engine.go` around lines 67 - 71, Update the doc comment for NewEngineFromFlags to remove the outdated reference to a `network parameter` and instead state that the Docker network is derived from EngineFlags.CrossplaneDockerNetwork; specifically edit the comment block above the NewEngineFromFlags function to reflect that when no binary path is set it returns a Docker engine using the resolved image reference and that the Docker network is taken from EngineFlags.CrossplaneDockerNetwork (not supplied by the caller).
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@cmd/crossplane/render/op/cmd.go`:
- Around line 170-185: The override parsing for
render.AnnotationKeyRuntimeDockerNetwork is nested inside the if
c.EngineFlags.CrossplaneDockerNetwork == "" block so the --function-annotations
override never applies when a network is already set; move the block that parses
c.FunctionAnnotations (using render.NewAnnotationsFromStrings and checking
render.AnnotationKeyRuntimeDockerNetwork) out of that conditional and always run
it so that when an annotation value exists you set
c.EngineFlags.CrossplaneDockerNetwork (and/or c.CrossplaneDockerNetwork if used
elsewhere) to that value, ensuring the function-annotations override takes
precedence.
---
Nitpick comments:
In `@cmd/crossplane/render/engine.go`:
- Around line 67-71: Update the doc comment for NewEngineFromFlags to remove the
outdated reference to a `network parameter` and instead state that the Docker
network is derived from EngineFlags.CrossplaneDockerNetwork; specifically edit
the comment block above the NewEngineFromFlags function to reflect that when no
binary path is set it returns a Docker engine using the resolved image reference
and that the Docker network is taken from EngineFlags.CrossplaneDockerNetwork
(not supplied by the caller).
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 14a09b90-8615-4a74-831b-924cd8db6271
📒 Files selected for processing (6)
cmd/crossplane/render/annotation.gocmd/crossplane/render/engine.gocmd/crossplane/render/engine_docker.gocmd/crossplane/render/op/cmd.gocmd/crossplane/render/render.gocmd/crossplane/render/xr/cmd.go
🚧 Files skipped from review as they are similar to previous changes (2)
- cmd/crossplane/render/engine_docker.go
- cmd/crossplane/render/render.go
Signed-off-by: Nikita Z <nkzk95@gmail.com>
Description of your changes
Closes #75
Fixes:
FunctionAnnotationsflag, run crossplane-container in it.I have:
./nix.sh flake checkto ensure this PR is ready for review.backport release-x.ylabels to auto-backport this PR.Need help with this checklist? See the cheat sheet.