Repository navigation
fix(deploy): hand the process CODEFLY_GRPC_PORT in the deployment - #124
Merged
Merged
Conversation
A deployed FastAPI service with grpc-server on got the gRPC containerPort and Service port from the kustomize template, but its container env carried only CODEFLY_CONNECT_PORT. Locally the runtime hands the process CODEFLY_GRPC_PORT; in the cluster the app had to guess the port the agent had already rendered into the Service. The scaffold guessed 9090, and a service that reads the variable strictly crashlooped with KeyError. The deployment template now projects CODEFLY_GRPC_PORT from Parameters.GRPCPort whenever GRPCEnabled is set, mirroring the Connect block, so the variable and the Service port come from the same value. The Parameters doc comment and the scaffold's main.py comment say so. TestDeploymentRendersGRPCPort asserts the variable and its value on a gRPC-enabled render and its absence when gRPC is off; it fails against the previous template. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
A deployed FastAPI service that declares a gRPC endpoint (
grpc-server.enabled) gets the gRPCcontainerPortand Service port from this agent's kustomize template, but its container env carries noCODEFLY_GRPC_PORT: the template projected onlyCODEFLY_CONNECT_PORT. Locally the runtime hands the processCODEFLY_GRPC_PORT(runtime.go), so a service that reads the variable strictly works locally and crashloops in the cluster withKeyError(measured live on a cell). The scaffold hid this by guessing 9090 when the variable is unset; a deployed service should not have to guess a port the agent already rendered into the Service.Fix
templates/deployment/kustomize/base/deployment.yaml.tmplnow projectsCODEFLY_GRPC_PORTfrom.Deployment.Parameters.GRPCPortwheneverGRPCEnabledis set, mirroring the Connect block. The env value and the Service/containerPort come from the same parameter (core'sstandards.Port(standards.GRPC)). No port is hardcoded and no service code changes.Docs: the
Parametersdoc comment inbuilder.gono longer says the app defaults when the variable is unset, and the scaffold'smain.py.tmplcomment says codefly hands the port locally and in the deployment.docs/and the repo have no other description of the deployment env (there is no README).Classification: fix, at the owning place (this agent's deployment recipe). Reuses the existing
GRPCEnabled/GRPCPortparameters and the existing Connect env pattern; adds no mechanism.Tests
TestDeploymentRendersGRPCPort(extended) asserts the rendered deployment carries- name: CODEFLY_GRPC_PORT/value: "9090"for a gRPC-enabled render and noCODEFLY_GRPC_PORTwhen gRPC is off. It fails against the previous template (checked by restoring it).go build ./...,go vet ./...,go mod tidy -diff,gofmt -lclean. Fullgo test -count=1 -timeout 40m -v ./...:okin 391 s, 180 top-level tests passed, 0 failed, 1 skipped (TestNativeAgentOwnershipLifecycle, which needsFASTAPI_NATIVE_AGENT_HOME/FASTAPI_QUALIFICATION_CLI). The lifecycle matrix ran native, nix and docker;TestCreateToRunDockerpassed.go test -racewas left to the CIracejob (runtime.gois untouched).Not verified: a redeploy on a cluster with the released agent.
🤖 Generated with Claude Code