Skip to content

Conversation

SuyashParmar
Copy link

This PR adds a comment to TaskSpec.MinAvailable indicating it defaults to the task's Replicas, and implements a Default() method to set MinAvailable to Replicas if unset.

Signed-off-by: SuyashParmar <[email protected]>
@volcano-sh-bot
Copy link
Collaborator

Welcome @SuyashParmar!

It looks like this is your first PR to volcano-sh/apis.

Thank you, and welcome to Volcano. 😃

@volcano-sh-bot
Copy link
Collaborator

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
To complete the pull request process, please assign kevin-wangzefeng
You can assign the PR to them by writing /assign @kevin-wangzefeng in a comment when ready.

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

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

Copy link

@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.

Summary of Changes

Hello @SuyashParmar, 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!

I've implemented a new Default() method for the TaskSpec struct. This method automatically assigns the value of Replicas to MinAvailable if MinAvailable is not specified, standardizing the default behavior for task specifications and ensuring MinAvailable always has a sensible fallback.

Highlights

  • Defaulting Logic: I've introduced a Default() method for the TaskSpec struct to automatically set MinAvailable.
  • Field Default Value: I've ensured that TaskSpec.MinAvailable now defaults to the value of TaskSpec.Replicas if it is not explicitly set.
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 or fill out our survey to provide feedback.

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

@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 Default() method for TaskSpec to set a default value for MinAvailable if it's not provided. The review identifies a potential issue with field aliasing in the current implementation, which could lead to subtle bugs and inconsistent behavior. A suggestion is provided to fix this by decoupling the defaulted value from its source.

// Default sets default values for TaskSpec fields.
func (t *TaskSpec) Default() {
if t.MinAvailable == nil {
t.MinAvailable = &t.Replicas

Choose a reason for hiding this comment

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

high

Assigning &t.Replicas directly to t.MinAvailable creates an alias between these two fields, which can cause unexpected side effects and inconsistent behavior after a DeepCopy. To avoid this, allocate a new int32 for MinAvailable and copy the value from Replicas.

v := t.Replicas
	t.MinAvailable = &v

@Monokaix
Copy link
Member

Please also execute bash ./hack/update-codegen.sh.

}

// Default sets default values for TaskSpec fields.
func (t *TaskSpec) Default() {
Copy link
Member

Choose a reason for hiding this comment

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

Can this take effect when the job CRD created?

Copy link
Author

Choose a reason for hiding this comment

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

The Default() method will only take effect if a defaulting webhook is enabled for the Job CRD, or if the API server is set up to call it via controller-runtime's defaulting registration. If neither is set up, the method will not be invoked automatically when a Job is created.

Copy link
Author

Choose a reason for hiding this comment

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

Can this take effect when the job CRD created?

sir waiting for the confirmation ?

Copy link
Member

Choose a reason for hiding this comment

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

Sorry for late.
In volcano, there is a seperate webhook,so I'm curious when and where this Default method will take effect: )

@SuyashParmar
Copy link
Author

Please also execute bash ./hack/update-codegen.sh.

done, ran successfully

@Monokaix
Copy link
Member

Please also execute bash ./hack/update-codegen.sh.

done, ran successfully

And there is no CRD definition changed, so seems the default value will not be set automatically.

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