Skip to content
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

pass status to handleSchedulingFailure #114082

Merged

Conversation

AxeZhan
Copy link
Member

@AxeZhan AxeZhan commented Nov 23, 2022

What type of PR is this?

/kind cleanup

What this PR does / why we need it:

  • remove reason from ScheduleResult
  • Pass status to scheduler.handleSchedulingFailure instead of an error and a string.
  • add WithError for Status

Which issue(s) this PR fixes:

Part of #103853

Special notes for your reviewer:

Does this PR introduce a user-facing change?

NONE

Additional documentation e.g., KEPs (Kubernetes Enhancement Proposals), usage docs, etc.:


@k8s-ci-robot k8s-ci-robot added release-note-none Denotes a PR that doesn't merit a release note. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. labels Nov 23, 2022
@k8s-ci-robot
Copy link
Contributor

Please note that we're already in Test Freeze for the release-1.26 branch. This means every merged PR will be automatically fast-forwarded via the periodic ci-fast-forward job to the release branch of the upcoming v1.26.0 release.

Fast forwards are scheduled to happen every 6 hours, whereas the most recent run was: Wed Nov 23 09:30:47 UTC 2022.

@k8s-ci-robot k8s-ci-robot added do-not-merge/needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. labels Nov 23, 2022
@k8s-ci-robot
Copy link
Contributor

@kidddddddddddddddddddddd: This issue is currently awaiting triage.

If a SIG or subproject determines this is a relevant issue, they will accept it by applying the triage/accepted label and provide further guidance.

The triage/accepted label can be added by org members by writing /triage accepted in a comment.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@k8s-ci-robot k8s-ci-robot added the needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. label Nov 23, 2022
@k8s-ci-robot
Copy link
Contributor

Hi @kidddddddddddddddddddddd. Thanks for your PR.

I'm waiting for a kubernetes member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@k8s-ci-robot k8s-ci-robot added needs-priority Indicates a PR lacks a `priority/foo` label and requires one. area/test sig/scheduling Categorizes an issue or PR as relevant to SIG Scheduling. sig/testing Categorizes an issue or PR as relevant to SIG Testing. and removed do-not-merge/needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. labels Nov 23, 2022
@AxeZhan
Copy link
Member Author

AxeZhan commented Nov 23, 2022

/cc @kerthcet
And please do let me know if we have some other refactor works about this.

@kerthcet
Copy link
Member

/ok-to-test

@k8s-ci-robot k8s-ci-robot added ok-to-test Indicates a non-member PR verified by an org member that is safe to test. and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Nov 24, 2022
@AxeZhan
Copy link
Member Author

AxeZhan commented Nov 24, 2022

/retest

@AxeZhan AxeZhan force-pushed the refactor_handleSchedulingFailure branch from 4f58d9b to 2b9af3e Compare November 24, 2022 12:56
@kerthcet
Copy link
Member

Sorry @kidddddddddddddddddddddd , really busy these days, will review this tomorrow or the day after tomorrow?

@AxeZhan AxeZhan force-pushed the refactor_handleSchedulingFailure branch from 2b9af3e to 5fd0509 Compare December 1, 2022 12:34
@AxeZhan AxeZhan requested review from kerthcet and removed request for chendave and sanposhiho December 1, 2022 12:35
@AxeZhan AxeZhan force-pushed the refactor_handleSchedulingFailure branch from 74bfb7d to 6554881 Compare December 12, 2022 16:57
@k8s-ci-robot k8s-ci-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Dec 12, 2022
@AxeZhan AxeZhan force-pushed the refactor_handleSchedulingFailure branch from 6554881 to b893a82 Compare December 12, 2022 17:12
@AxeZhan AxeZhan force-pushed the refactor_handleSchedulingFailure branch from b893a82 to 14e24b4 Compare December 12, 2022 17:15
@AxeZhan AxeZhan force-pushed the refactor_handleSchedulingFailure branch 4 times, most recently from 61a9f1a to d637e90 Compare December 12, 2022 17:50
Copy link
Member

@alculquicondor alculquicondor left a comment

Choose a reason for hiding this comment

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

last comment :)

pkg/scheduler/framework/interface.go Outdated Show resolved Hide resolved
@AxeZhan AxeZhan force-pushed the refactor_handleSchedulingFailure branch from d637e90 to e410c7a Compare December 12, 2022 18:34
@k8s-ci-robot k8s-ci-robot added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. and removed size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Dec 12, 2022

msg := truncateMessage(err.Error())
msg := truncateMessage(status.Message())
Copy link
Member

Choose a reason for hiding this comment

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

Then revert the change for reasons may be empty now. E.g. we no longer append reasons in NewStatus().WithError(). It should look like:

err := status.AsError()
msg := truncateMessage(err.Error())

Copy link
Member

Choose a reason for hiding this comment

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

ah, we should be calling s.err.Error() in Status.Message. Can you do as a follow up?

Copy link
Member

@kerthcet kerthcet Dec 13, 2022

Choose a reason for hiding this comment

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

We can not call s.err here. status.AsError will also return the error, and we're handling failures, so we'll always have an error in status.

Copy link
Member

@kerthcet kerthcet Dec 13, 2022

Choose a reason for hiding this comment

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

Sorry, you mean the status.Message()? But somethings status may have no error but only reasons.

Copy link
Member Author

Choose a reason for hiding this comment

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

ah, we should be calling s.err.Error() in Status.Message. Can you do as a follow up?

We construct s.err with reasons in AsStatus and NewStatus, so if the code of a status is Error, s.err.Error() will be contained by s.Message.
However, if status has a code not Error and has a error in the same time, s.Message() will not return the error msg, and in that case, we need to call s.err.Error() to get the error msg.(like fiterr in scheduling cycle).
I guess you're suggesting in status.Message(), we check the status's code and concate err.Error() into the result string, like:

func (s *Status) Message() string {
	if s == nil {
		return ""
	}
	if s.err != nil && s.code != Error {
		return s.err.Error() + "," + strings.Join(s.reasons, ", ") 
	}
	return strings.Join(s.reasons, ", ")
}

This looks a bit back to the start.

Copy link
Member

Choose a reason for hiding this comment

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

It's not back to the start. The main difference is that we are only serializing when actually needed.

Copy link
Member Author

Choose a reason for hiding this comment

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

created #114456 , we can have a disscussion/review there.

pkg/scheduler/schedule_one_test.go Outdated Show resolved Hide resolved
@AxeZhan AxeZhan force-pushed the refactor_handleSchedulingFailure branch from e410c7a to 6ca62eb Compare December 13, 2022 03:37
@AxeZhan
Copy link
Member Author

AxeZhan commented Dec 13, 2022

may have a flaky test: Test_Run_OneVolumeDetachFailNodeWithReadWriteOnce
/retest

@AxeZhan
Copy link
Member Author

AxeZhan commented Dec 13, 2022

/retest

@kerthcet
Copy link
Member

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Dec 13, 2022
@k8s-ci-robot k8s-ci-robot merged commit dc1e771 into kubernetes:master Dec 13, 2022
@k8s-ci-robot k8s-ci-robot added this to the v1.26 milestone Dec 13, 2022
@liggitt liggitt modified the milestones: v1.26, v1.27 Dec 13, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. area/test cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. lgtm "Looks good to me", indicates that a PR is ready to be merged. needs-priority Indicates a PR lacks a `priority/foo` label and requires one. needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. release-note-none Denotes a PR that doesn't merit a release note. sig/scheduling Categorizes an issue or PR as relevant to SIG Scheduling. sig/testing Categorizes an issue or PR as relevant to SIG Testing. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants