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

Refactor error state checking #1983

Merged
merged 3 commits into from
Mar 9, 2023

Conversation

sawsa307
Copy link
Contributor

@sawsa307 sawsa307 commented Mar 2, 2023

Create function ValidateEndpoints and move endpoint validation logics into EndpointCalculator. Now it would correctly validate endpoints for L4 and L7 endpoint calculators. Validation for L4 endpoints is currently a no-op.

@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Mar 2, 2023
@k8s-ci-robot k8s-ci-robot requested review from aojea and MrHohn March 2, 2023 18:53
@k8s-ci-robot
Copy link
Contributor

Hi @sawsa307. 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-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. labels Mar 2, 2023
@sawsa307 sawsa307 force-pushed the error-state-refactor branch from bc44e2b to 58fdf6f Compare March 2, 2023 18:55
@sawsa307
Copy link
Contributor Author

sawsa307 commented Mar 2, 2023

/assign @swetharepakula

@sawsa307
Copy link
Contributor Author

sawsa307 commented Mar 2, 2023

/cc @mmamczur

@k8s-ci-robot
Copy link
Contributor

@sawsa307: GitHub didn't allow me to request PR reviews from the following users: mmamczur.

Note that only kubernetes members and repo collaborators can review this PR, and authors cannot review their own PRs.

In response to this:

/cc @mmamczur

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.

@sawsa307
Copy link
Contributor Author

sawsa307 commented Mar 2, 2023

/assign @mmamczur

@k8s-ci-robot
Copy link
Contributor

@sawsa307: GitHub didn't allow me to assign the following users: mmamczur.

Note that only kubernetes members with read permissions, repo collaborators and people who have commented on this issue/PR can be assigned. Additionally, issues/PRs can only have 10 assignees at the same time.
For more information please see the contributor guide

In response to this:

/assign @mmamczur

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.

@sawsa307 sawsa307 force-pushed the error-state-refactor branch 3 times, most recently from 7ba9c00 to 8aa3a49 Compare March 2, 2023 19:23
@sawsa307
Copy link
Contributor Author

sawsa307 commented Mar 2, 2023

cc @mmamczur

@@ -259,16 +261,15 @@ func (s *transactionSyncer) syncInternalImpl() error {
}
endpointsData := negtypes.EndpointsDataFromEndpointSlices(endpointSlices)
targetMap, endpointPodMap, dupCount, err = s.endpointsCalculator.CalculateEndpoints(endpointsData, currentMap)
if valid, reason := s.isValidEPField(err); !valid {
Copy link
Contributor

Choose a reason for hiding this comment

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

thanks for getting rid of this part as well, it looked super confusing with this isValidEPField potentially ignoring errors

@mmamczur
Copy link
Contributor

mmamczur commented Mar 3, 2023

LGTM, probably best choice that you move this validation to the calculator

// isValidEPField returns false and the corresponding reason if there is endpoint with missing zone or nodeName
func (s *transactionSyncer) isValidEPField(err error) (bool, string) {
// getErrorStateReason returns the reason of the error state based returned error
func (s *transactionSyncer) getErrorStateReason(err error) string {
if errors.Is(err, negtypes.ErrEPMissingNodeName) {
Copy link
Contributor Author

@sawsa307 sawsa307 Mar 8, 2023

Choose a reason for hiding this comment

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

Create a map in the sync_result.go that match errors to reasons.

@sawsa307 sawsa307 force-pushed the error-state-refactor branch 3 times, most recently from 96a715b to 4193ef8 Compare March 9, 2023 00:58
@@ -50,6 +50,17 @@ var (
ResultOtherError = "OtherError"
ResultInProgress = "InProgress"
ResultSuccess = "Success"

ErrorStateReason = map[error]string{
Copy link
Member

Choose a reason for hiding this comment

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

add a comment as to why we need this.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added. Thanks!

@@ -50,6 +50,17 @@ var (
ResultOtherError = "OtherError"
Copy link
Member

Choose a reason for hiding this comment

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

all the results should be constants.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated. Thanks!

Create function ValidateEndpoints, so it would correctly validate
endpoints for L4 and L7 endpoint calculators. Validation for L4
endpoints is currently a noop.
@sawsa307 sawsa307 force-pushed the error-state-refactor branch from 4193ef8 to 915788c Compare March 9, 2023 01:04
Copy link
Member

@swetharepakula swetharepakula left a comment

Choose a reason for hiding this comment

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

/lgtm
/approve

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Mar 9, 2023
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: sawsa307, swetharepakula

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

The pull request process is described 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

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Mar 9, 2023
@swetharepakula
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 Mar 9, 2023
@k8s-ci-robot k8s-ci-robot merged commit 90f3dfb into kubernetes:master Mar 9, 2023
@sawsa307 sawsa307 deleted the error-state-refactor branch September 2, 2023 20:42
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. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm "Looks good to me", indicates that a PR is ready to be merged. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants