Skip to content

Conversation

@LeslieKuo
Copy link
Contributor

fix issue #64

@volcano-sh-bot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:

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

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @LeslieKuo, 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 significantly enhances the reliability and operational readiness of sandboxes by integrating Kubernetes-style readiness probes. It allows for flexible definition of custom readiness checks and ensures that sandboxes are not considered available until their underlying Pods and Services are fully functional. This change directly addresses an existing issue related to sandbox initialization and readiness, improving the overall stability of the system.

Highlights

  • Readiness Probe Definition: New Go structs (ReadinessProbe, TCPSocketAction, HTTPGetAction, ExecAction) have been introduced in pkg/common/types/sandbox.go to define Kubernetes-style readiness probe configurations for sandboxes.
  • Readiness Probe Integration: The sandbox creation process now accepts and applies these readiness probe configurations to the underlying Kubernetes Pods, allowing for custom health checks (TCP, HTTP, or Exec).
  • Default Readiness Probe: If no custom readiness probe is explicitly provided, a default TCP readiness probe will be automatically configured for containers that expose ports, ensuring basic health checking.
  • Sandbox Readiness Waiting: A new mechanism has been implemented to actively wait for both the sandbox's Kubernetes Pod and its associated Service to become fully ready and operational before the sandbox is considered provisioned and available.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

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 by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

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 pull request 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
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 support for readinessProbe in sandbox creation, which is a valuable addition for ensuring services are ready to accept traffic. The implementation looks mostly correct, but I've found a couple of critical compilation errors due to an undefined variable and a missing import. I've also suggested an improvement to logging consistency and adding validation for the new probe configuration. Additionally, there's a minor formatting issue to address.

Comment on lines 129 to 131
sandbox, externalInfo, err = buildSandboxByAgentRuntime(createAgentRequest.Namespace, createAgentRequest.Name, s.informers, createAgentRequest.ReadinessProbe)
case types.CodeInterpreterKind:
sandbox, sandboxClaim, externalInfo, err = buildSandboxByCodeInterpreter(sandboxReq.Namespace, sandboxReq.Name, s.informers)
sandbox, sandboxClaim, externalInfo, err = buildSandboxByCodeInterpreter(createAgentRequest.Namespace, createAgentRequest.Name, s.informers, createAgentRequest.ReadinessProbe)
Copy link
Contributor

Choose a reason for hiding this comment

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

critical

The variable createAgentRequest is used here but it's not defined in this scope. This seems to be a copy-paste error and will cause a compilation failure. You should use sandboxReq instead.

Suggested change
sandbox, externalInfo, err = buildSandboxByAgentRuntime(createAgentRequest.Namespace, createAgentRequest.Name, s.informers, createAgentRequest.ReadinessProbe)
case types.CodeInterpreterKind:
sandbox, sandboxClaim, externalInfo, err = buildSandboxByCodeInterpreter(sandboxReq.Namespace, sandboxReq.Name, s.informers)
sandbox, sandboxClaim, externalInfo, err = buildSandboxByCodeInterpreter(createAgentRequest.Namespace, createAgentRequest.Name, s.informers, createAgentRequest.ReadinessProbe)
sandbox, externalInfo, err = buildSandboxByAgentRuntime(sandboxReq.Namespace, sandboxReq.Name, s.informers, sandboxReq.ReadinessProbe)
case types.CodeInterpreterKind:
sandbox, sandboxClaim, externalInfo, err = buildSandboxByCodeInterpreter(sandboxReq.Namespace, sandboxReq.Name, s.informers, sandboxReq.ReadinessProbe)

}

if err := s.k8sClient.WaitForSandboxDependenciesReady(c.Request.Context(), namespace, sandboxName, sandboxReadinessTimeout); err != nil {
log.Printf("sandbox %s/%s dependencies not ready: %v", namespace, sandboxName, err)
Copy link
Contributor

Choose a reason for hiding this comment

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

critical

The log package is not imported, and this call to log.Printf will cause a compilation error. To maintain consistency with the logging framework used in this file, please use klog.Errorf instead.

Suggested change
log.Printf("sandbox %s/%s dependencies not ready: %v", namespace, sandboxName, err)
klog.Errorf("sandbox %s/%s dependencies not ready: %v", namespace, sandboxName, err)

@@ -61,4 +90,4 @@ func (car *CreateSandboxRequest) Validate() error {
return fmt.Errorf("name is required")
}
return nil
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

The Validate() method doesn't validate the newly added ReadinessProbe. It's a good practice to validate new fields to ensure requests are well-formed. For example, you could check that a ReadinessProbe has exactly one handler (TCPSocket, HTTPGet, or Exec) defined.

sandboxReq.Kind = types.CodeInterpreterKind
default:
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

This line has trailing whitespace, which should be removed to maintain code style consistency.

Suggested change
}
}

Metadata map[string]string `json:"metadata"`
PublicKey string `json:"publicKey,omitempty"`
InitTimeoutSeconds int `json:"initTimeoutSeconds,omitempty"`
ReadinessProbe *ReadinessProbe `json:"readinessProbe,omitempty"`
Copy link
Member

Choose a reason for hiding this comment

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

we donot need to pass thie probe config in the request body, the probe config is already in the pod spec.

For code interpreter, i think we may need to add a new api field in the spec to indicate the probe

return
}

if err := s.k8sClient.WaitForSandboxDependenciesReady(c.Request.Context(), namespace, sandboxName, sandboxReadinessTimeout); err != nil {
Copy link
Member

Choose a reason for hiding this comment

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

We can just check IsSandboxReady, and return after ready

@acsoto acsoto mentioned this pull request Dec 23, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants