Skip to content

Improve error handling across kong & ingress-nginx#152

Merged
k8s-ci-robot merged 1 commit intokubernetes-sigs:mainfrom
levikobi:improve-error-handling
Apr 14, 2024
Merged

Improve error handling across kong & ingress-nginx#152
k8s-ci-robot merged 1 commit intokubernetes-sigs:mainfrom
levikobi:improve-error-handling

Conversation

@levikobi
Copy link
Copy Markdown
Member

What type of PR is this?

/kind bug

What this PR does / why we need it:
Improves error handling across Kong and ingress-nginx providers by removing panic calls and stopping conversions if an error occurs.
Also, prevents the tool from crashing in case no pathType is specified.

Which issue(s) this PR fixes:

Fixes #151

Does this PR introduce a user-facing change?:

* Improves error handling for Kong and Ingress Nginx providers, making them more understandable.
* Prevents the tool from crashing in case no `pathType` is specified

@k8s-ci-robot k8s-ci-robot added kind/bug Categorizes issue or PR as related to a bug. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. labels Apr 10, 2024
@k8s-ci-robot k8s-ci-robot added the size/S Denotes a PR that changes 10-29 lines, ignoring generated files. label Apr 10, 2024
Comment thread pkg/i2gw/providers/kong/converter.go Outdated
Comment thread pkg/i2gw/providers/kong/converter.go Outdated
Comment thread pkg/i2gw/providers/kong/converter.go Outdated
httpRoute, ok := gatewayResources.HTTPRoutes[key]
if !ok {
panic("HTTPRoute not exists - this should never happen")
return field.ErrorList{field.InternalError(nil, fmt.Errorf("HTTPRoute does not exist"))}
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

On lines 44-45 we get errors from calculateBackendRefWeight. Although you replaced panic with returning an error, the errors above are still invisible and the user can not know whats wrong.

The concern is relevant for changes in Kong as well.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

That's a good catch. In those cases, instead of panicking or returning uninformative errors such as "HTTPRoute does not exist," we could continue to the next iteration. All the informative errors will be collected and returned at the end of the for-loop

WDYT @LiorLieberman @mlavacca?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

continue plus a comment on top of this to explain sounds good to me.
Also since you changed kong/converter.go to the logic proposed, I think is ok to log and return an error because in kong this indeed should never happen.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

continue plus a comment on top of this to explain sounds good to me.

Done

Also since you changed kong/converter.go to the logic #152 (comment), I think is ok to log and return an error because in kong this indeed should never happen.

I'm not exactly sure what you mean here

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

for all kong featureParsers changes you have added, (returning error instead of panic) maybe we should add that this should never happen? or something more clear to the user?
Because this indeed should never happen now with the change you added to check the errors and return before calling the featureParsers in kong/converter.go

I hope this is a bit more clear

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

OK got it now. I added back the "this should never happen" message. If we indeed encounter this error at some point for whatever reason we'll figure out how to address it better

@levikobi levikobi force-pushed the improve-error-handling branch from 18cd934 to 67cbfa8 Compare April 11, 2024 09:04
@k8s-ci-robot k8s-ci-robot added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. and removed size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Apr 11, 2024
@levikobi levikobi force-pushed the improve-error-handling branch from 67cbfa8 to c25070c Compare April 14, 2024 05:22
@LiorLieberman
Copy link
Copy Markdown
Member

/lgtm
/approve
/hold so you can decide what to do with the last piece of feedback

@k8s-ci-robot k8s-ci-robot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Apr 14, 2024
@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Apr 14, 2024
@k8s-ci-robot
Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: levikobi, LiorLieberman

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

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

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Apr 14, 2024
@levikobi levikobi force-pushed the improve-error-handling branch from c25070c to 6b75fe1 Compare April 14, 2024 05:38
@k8s-ci-robot k8s-ci-robot removed the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Apr 14, 2024
@levikobi
Copy link
Copy Markdown
Member Author

/unhold

@k8s-ci-robot k8s-ci-robot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Apr 14, 2024
@LiorLieberman
Copy link
Copy Markdown
Member

thanks,
/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Apr 14, 2024
@k8s-ci-robot k8s-ci-robot merged commit 960a12a into kubernetes-sigs:main Apr 14, 2024
xtineskim pushed a commit to xtineskim/ingress2gateway that referenced this pull request Apr 23, 2024
rajashish pushed a commit to rajashish/ingress2gateway1 that referenced this pull request Feb 21, 2026
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. kind/bug Categorizes issue or PR as related to a bug. lgtm "Looks good to me", indicates that a PR is ready to be merged. 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.

Unnecessary panic calls causes unclear errors

3 participants