Skip to content

fix(cli): add publish endpoint option#327

Open
mrinalchaturvedi27 wants to merge 3 commits into
volcano-sh:mainfrom
mrinalchaturvedi27:fix-cli-publish-endpoint
Open

fix(cli): add publish endpoint option#327
mrinalchaturvedi27 wants to merge 3 commits into
volcano-sh:mainfrom
mrinalchaturvedi27:fix-cli-publish-endpoint

Conversation

@mrinalchaturvedi27
Copy link
Copy Markdown
Contributor

@mrinalchaturvedi27 mrinalchaturvedi27 commented May 12, 2026

What type of PR is this?

/kind bug

What this PR does / why we need it:

This makes the documented kubectl agentcube publish --endpoint option work. The CLI passes it to PublishRuntime as agent_endpoint, and the AgentCube publish path saves it in metadata so later commands like invoke can read it.

Which issue(s) this PR fixes:
Fixes #

Special notes for your reviewer:

I found this while working on PR #325. This adds a CLI test for the option pass-through and a runtime test to check that the endpoint is saved in metadata.

What I fixed

I fixed the Python CLI publish command so kubectl agentcube publish --endpoint works as documented. The endpoint is now passed to the runtime and saved in metadata.

How I found it

I found this while working on PR #325. I checked the README section for publish, then looked at cmd/cli/agentcube/cli/main.py and cmd/cli/agentcube/runtime/publish_runtime.py. The runtime already checked options.get('agent_endpoint'), but the CLI did not expose the option. A review also pointed out that the AgentCube publish path returned the endpoint but did not save it in metadata.

What I changed

  • Added --endpoint to the publish command options.
  • Passed it to PublishRuntime.publish as agent_endpoint.
  • Saved agent_endpoint in metadata in the AgentCube publish path.
  • Added a CLI test for publish --endpoint.
  • Added a runtime test for saving the endpoint in metadata.

Why this is legit

This matches the README and keeps publish and invoke behavior consistent. It is a small Python CLI/runtime change and does not touch Kubernetes resources, Go code, generated files, or chart templates.

Tests

  • Screenshot 2026-05-12 at 6 09 01 PM
  • Screenshot 2026-05-12 at 6 09 24 PM
  • Screenshot 2026-05-12 at 6 09 51 PM
  • Screenshot 2026-05-12 at 6 10 23 PM

Copilot AI review requested due to automatic review settings May 12, 2026 12:41
@volcano-sh-bot volcano-sh-bot added the kind/bug Something isn't working label May 12, 2026
@volcano-sh-bot
Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign acsoto for approval. For more information see the Kubernetes Code Review Process.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@mrinalchaturvedi27 mrinalchaturvedi27 changed the title Fix cli publish endpoint fix(cli): add publish endpoint option May 12, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes the Python CLI publish command so the documented kubectl agentcube publish --endpoint flag is accepted and forwarded into PublishRuntime.publish() under the agent_endpoint option key (which the runtime already consumes).

Changes:

  • Add --endpoint option to the Typer publish command.
  • Forward the CLI option as agent_endpoint in the options dict passed to PublishRuntime.publish.
  • Add a Typer-based CLI test that asserts --endpoint is forwarded correctly.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
cmd/cli/agentcube/cli/main.py Adds --endpoint to publish and forwards it as agent_endpoint into the runtime options.
cmd/cli/tests/test_cli_publish.py Adds a CLI test verifying --endpoint is passed through to PublishRuntime as agent_endpoint.

Comment thread cmd/cli/agentcube/cli/main.py
Copy link
Copy Markdown
Contributor

@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 introduces a new --endpoint CLI option to the publish command, allowing users to specify a custom API endpoint for AgentCube or Kubernetes clusters. This value is correctly forwarded to the PublishRuntime. Additionally, a new test file was added to verify this functionality. Feedback was provided to improve the test mock's robustness by using .get() for dictionary access to prevent potential KeyError exceptions when the endpoint option is omitted.

Comment thread cmd/cli/tests/test_cli_publish.py
@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented May 12, 2026

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 47.74%. Comparing base (524e55e) to head (26535f2).
⚠️ Report is 41 commits behind head on main.
❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #327      +/-   ##
==========================================
+ Coverage   47.57%   47.74%   +0.17%     
==========================================
  Files          30       30              
  Lines        2819     2855      +36     
==========================================
+ Hits         1341     1363      +22     
- Misses       1338     1344       +6     
- Partials      140      148       +8     
Flag Coverage Δ
unittests 47.74% <ø> (+0.17%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated no new comments.

"provider": provider,
"node_port": node_port,
"replicas": replicas,
"agent_endpoint": endpoint,
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.

Can we also persist this value in the AgentCube publish path? PublishRuntime._publish_cr_to_k8s returns agent_endpoint, but its metadata update only writes agent_id and k8s_deployment; a later agentcube invoke still reads metadata.agent_endpoint, so publishing with --endpoint can succeed and then invoke fails unless the metadata already had an endpoint.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Thank you so much for the review and catching this @acsoto .
I updated the AgentCube publish path to persist the endpoint passed via --endpoint into metadata as agent_endpoint. I also added a runtime test to cover this path, so a later invoke can read the saved endpoint from metadata.

Signed-off-by: Mrinal Chaturvedi <mrinal.chaturvedi27@gmail.com>
Signed-off-by: Mrinal Chaturvedi <mrinal.chaturvedi27@gmail.com>
Signed-off-by: Mrinal Chaturvedi <mrinal.chaturvedi27@gmail.com>
@mrinalchaturvedi27
Copy link
Copy Markdown
Contributor Author

Hi @acsoto @YaoZengzeng quick ping for this PR :)

endpoint: Optional[str] = typer.Option(
None,
"--endpoint",
help="Custom API endpoint for AgentCube or Kubernetes cluster",
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.

Nit: this reads like a Kubernetes API server endpoint, but the value is stored as agent_endpoint and later used as the base URL for invoking the published agent. Can we make the help text say that more directly?

except Exception as e:
raise RuntimeError(f"Failed to deploy AgentRuntime CR to K8s: {str(e)}")

endpoint = options.get('agent_endpoint') or metadata.agent_endpoint
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.

Can we resolve and validate this before calling deploy_agent_runtime? If neither --endpoint nor metadata.agent_endpoint is set, publish currently creates the AgentRuntime CR and then fails before updating metadata, leaving the cluster state ahead of the workspace state.

Copy link
Copy Markdown
Member

@hzxuzhonghu hzxuzhonghu left a comment

Choose a reason for hiding this comment

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

cmd/cli/agentcube/cli/main.py

  • Lines 306-310: The --endpoint option is clean. It is passed as agent_endpoint in the options dict.

cmd/cli/agentcube/runtime/publish_runtime.py

  • Lines 174-176: Moving the endpoint resolution and validation before the metadata update (Step 4) is a good improvement. In the original code, the endpoint check happened after update_metadata, meaning a missing endpoint would leave stale partial metadata. Now it fails early and cleanly.

cmd/cli/tests/test_cli_publish.py

  • Good end-to-end test using a stub PublishRuntime to verify the --endpoint flag is forwarded correctly.

LGTM.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kind/bug Something isn't working size/L

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants