Skip to content

[Refactor] Optimize the logic and readability of the waitDependsOnTas… #4191

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

feyounger
Copy link
Contributor

@feyounger feyounger commented Apr 15, 2025

…kMeetCondition function

What type of PR is this?

Related with #4190 code

What this PR does / why we need it:

Make the structure fresher

Which issue(s) this PR fixes:

Fixes #

Special notes for your reviewer:

None

Does this PR introduce a user-facing change?

None

@volcano-sh-bot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
To complete the pull request process, please assign lowang-bh
You can assign the PR to them by writing /assign @lowang-bh 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

@volcano-sh-bot volcano-sh-bot added the size/S Denotes a PR that changes 10-29 lines, ignoring generated files. label Apr 15, 2025
@JesseStutler
Copy link
Member

Please complete your description

@feyounger
Copy link
Contributor Author

Please complete your description

@feyounger feyounger closed this Apr 15, 2025
@feyounger feyounger reopened this Apr 15, 2025
@feyounger
Copy link
Contributor Author

feyounger commented Apr 15, 2025

Please complete your description

ok

@Monokaix Monokaix requested a review from Copilot April 16, 2025 01:07
Copy link

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

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

Comments suppressed due to low confidence (1)

pkg/controllers/job/job_controller_actions.go:581

  • [nitpick] Consider using a consistent variable name (e.g., 'dependsOnTask') instead of 'taskName' to maintain consistency with previous naming and improve readability.
for _, taskName := range dependsOn.Name {

@@ -567,7 +567,8 @@ func (cc *jobcontroller) waitDependsOnTaskMeetCondition(taskIndex int, job *batc
return true
}
dependsOn := *job.Spec.Tasks[taskIndex].DependsOn
if len(dependsOn.Name) > 1 && dependsOn.Iteration == batch.IterationAny {
switch dependsOn.Iteration {
Copy link
Preview

Copilot AI Apr 16, 2025

Choose a reason for hiding this comment

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

Ensure that the default branch's logic for non-IterationAny cases matches the intended behavior of requiring all dependency tasks to be ready. Verify that this change preserves the original business logic from the previous if-statement condition.

Copilot uses AI. Check for mistakes.

@Monokaix
Copy link
Member

Should add ut when refactoring.

@volcano-sh-bot volcano-sh-bot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Apr 17, 2025
@feyounger
Copy link
Contributor Author

Should add ut when refactoring.

ok..

@Monokaix
Copy link
Member

Hi, please squash to one commit.

@feyounger
Copy link
Contributor Author

Hi, please squash to one commit.

ok

if cc.isDependsOnPodsReady(task, job) {
switch dependsOn.Iteration {
case batch.IterationAny:
// any ready to create task, return truechi
Copy link
Member

Choose a reason for hiding this comment

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

truechi? Unnecessary chi.

@@ -863,3 +864,126 @@ func TestRecordPodGroupEvent(t *testing.T) {
}

}

func TestWaitDependsOnTaskMeetCondition(t *testing.T) {
Copy link
Member

Choose a reason for hiding this comment

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

UT is not correct, please re-write it, the expected value should be a bool type.
sample

func TestWaitDependsOnTaskMeetCondition(t *testing.T) {
	namespace := "test"

	testcases := []struct {
		Name         string
		Job          *v1alpha1.Job
		TaskIndex    int
		JobInfo      *apis.JobInfo
		Pods         map[string]map[string]*v1.Pod
		ExpectResult bool
	}
....

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'll make the change right away

…kMeetCondition function

Signed-off-by: feyounger <[email protected]>

[Refactor] Optimize the logic and readability of the waitDependsOnTaskMeetCondition function ut

Signed-off-by: feyounger <[email protected]>

[Refactor] Cover case checkControllers ut

Signed-off-by: feyounger <[email protected]>

[Refactor] update TestWaitDependsOnTaskMeetCondition ExpectVal type

Signed-off-by: feyounger <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants