-
Notifications
You must be signed in to change notification settings - Fork 69
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
Conversation
Signed-off-by: YaoZengzeng <[email protected]>
Codecov ReportAttention: Patch coverage is
... and 16 files with indirect coverage changes Continue to review full report in Codecov by Sentry.
|
@@ -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 { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if service.Waypoint != nil && service.GetWaypoint().GetAddress() != nil && len(service.Addresses) != 0 { | |
if service.Waypoint != nil && len(service.GetWaypoint().GetAddress()) > 0 { |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
[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 |
/lgtm |
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?: