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

fix crash when waypoint is not network address type #842

Merged
merged 1 commit into from
Sep 11, 2024

Conversation

YaoZengzeng
Copy link
Member

What type of PR is this?

/kind bug

What this PR does / why we need it:

Which issue(s) this PR fixes:
Fixes #815

Special notes for your reviewer:

Does this PR introduce a user-facing change?:


@kmesh-bot kmesh-bot added the kind/bug Something isn't working label Sep 11, 2024
Copy link

codecov bot commented Sep 11, 2024

Codecov Report

Attention: Patch coverage is 50.00000% with 1 line in your changes missing coverage. Please review.

Project coverage is 52.82%. Comparing base (e217f2b) to head (0956425).
Report is 87 commits behind head on main.

Files with missing lines Patch % Lines
pkg/controller/workload/workload_processor.go 50.00% 1 Missing ⚠️
Files with missing lines Coverage Δ
pkg/controller/workload/workload_processor.go 62.04% <50.00%> (-0.78%) ⬇️

... and 16 files with indirect coverage changes


Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 2a93193...0956425. Read the comment docs.

@@ -501,7 +501,7 @@ func (p *Processor) handleService(service *workloadapi.Service) error {
}

// Preprocess service, remove the waypoint from waypoint service, otherwise it will fall into a loop in bpf
if service.Waypoint != nil {
if service.Waypoint != nil && service.GetWaypoint().GetAddress() != nil && len(service.Addresses) != 0 {
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
if service.Waypoint != nil && service.GetWaypoint().GetAddress() != nil && len(service.Addresses) != 0 {
if service.Waypoint != nil && len(service.GetWaypoint().GetAddress()) > 0 {

Copy link
Member Author

Choose a reason for hiding this comment

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

The return type of service.GetWaypoint().GetAddress() is a struct, ref: https://github.com/kmesh-net/kmesh/blob/main/api/v2/workloadapi/workload.pb.go#L1292

Copy link
Member

Choose a reason for hiding this comment

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

my fault, misread service.Addresses as waypoint.Address

Copy link
Member

Choose a reason for hiding this comment

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

how could service.Addresses cause panic now

Copy link
Member Author

Choose a reason for hiding this comment

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

As the description, it could be empty when it's the headless service: https://github.com/kmesh-net/kmesh/blob/main/api/v2/workloadapi/workload.pb.go#L540

Also I think it's fine to determine whether it's out of bound before accessing the slice as a defensive method.

@kmesh-bot
Copy link
Collaborator

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: hzxuzhonghu

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

@hzxuzhonghu
Copy link
Member

/lgtm

@kmesh-bot kmesh-bot added the lgtm label Sep 11, 2024
@kmesh-bot kmesh-bot merged commit d83baf8 into kmesh-net:main Sep 11, 2024
9 checks passed
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.

Panic with istio 1.24-alpha.96593644e05baa5c1b6aaab3647b2d9335a23942
3 participants