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

handle hostname type waypoint for istio 1.24 #995

Merged
merged 10 commits into from
Nov 1, 2024

Conversation

YaoZengzeng
Copy link
Member

What type of PR is this?

/kind enhancement

What this PR does / why we need it:

Starting from istio 1.24, waypoint supports the address type of hostname and Kmesh need to support it.

Which issue(s) this PR fixes:
Fixes part of #984

Special notes for your reviewer:

Does this PR introduce a user-facing change?:


@kmesh-bot kmesh-bot added the kind/enhancement New feature or request label Oct 30, 2024
@kmesh-bot kmesh-bot requested review from kwb0523 and nlgwcy October 30, 2024 02:01
@YaoZengzeng YaoZengzeng changed the title handle hostname type waypoint for istio 1.24 WIP: handle hostname type waypoint for istio 1.24 Oct 30, 2024
@kmesh-bot kmesh-bot added size/L and removed size/M labels Oct 30, 2024
Copy link
Member

@hzxuzhonghu hzxuzhonghu left a comment

Choose a reason for hiding this comment

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

It makes me confusing with so many map around waypoint added, can you reduce unnecessary ones.

@@ -27,17 +28,28 @@ type ServiceCache interface {
AddOrUpdateService(svc *workloadapi.Service)
DeleteService(resourceName string)
GetService(resourceName string) *workloadapi.Service
HandleWaypoint(svc *workloadapi.Service) []*workloadapi.Service
Copy link
Member

Choose a reason for hiding this comment

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

not clear what does this method do, please comment

// NOTE: The following data structure is used to change the waypoint
// address of type hostname in the service to type ip address.
waypointToServices map[string]map[string]*workloadapi.Service
waypointToAddress map[string]*workloadapi.NetworkAddress
Copy link
Member

Choose a reason for hiding this comment

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

comment all the new added map ,what is the key

// otherwise it waits for the arrival of the waypoint.
func (s *serviceCache) HandleWaypoint(svc *workloadapi.Service) []*workloadapi.Service {
s.mutex.Lock()
defer s.mutex.Unlock()
Copy link
Member

Choose a reason for hiding this comment

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

moe it close to the critical section

}

if svc.GetWaypoint() == nil || svc.GetWaypoint().GetAddress() != nil {
return res
Copy link
Member

Choose a reason for hiding this comment

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

Seems we donot need to return as the svc has been processed originally

Copy link
Member Author

Choose a reason for hiding this comment

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

We don't need to process waypoint with IP address type and res is empty in this context.

return res
}

func (s *serviceCache) updateWaypoint(svc *workloadapi.Service, addr *workloadapi.NetworkAddress) {
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
func (s *serviceCache) updateWaypoint(svc *workloadapi.Service, addr *workloadapi.NetworkAddress) {
func updateWaypoint(svc *workloadapi.Service, addr *workloadapi.NetworkAddress) {

@@ -27,17 +28,28 @@ type ServiceCache interface {
AddOrUpdateService(svc *workloadapi.Service)
DeleteService(resourceName string)
GetService(resourceName string) *workloadapi.Service
HandleWaypoint(svc *workloadapi.Service) []*workloadapi.Service
Copy link
Member

Choose a reason for hiding this comment

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

This can be called within AddOrUpdateService

Signed-off-by: YaoZengzeng <yaozengzeng@huawei.com>
Signed-off-by: YaoZengzeng <yaozengzeng@huawei.com>
Signed-off-by: YaoZengzeng <yaozengzeng@huawei.com>
Signed-off-by: YaoZengzeng <yaozengzeng@huawei.com>
Signed-off-by: YaoZengzeng <yaozengzeng@huawei.com>
@@ -19,6 +19,7 @@ package cache
import (
"sync"

"istio.io/istio/pkg/log"
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why not use kmesh.net/kmesh/pkg/logger?

Copy link
Member Author

Choose a reason for hiding this comment

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

Good catch, IDE automatically completes it.

Signed-off-by: YaoZengzeng <yaozengzeng@huawei.com>
Signed-off-by: YaoZengzeng <yaozengzeng@huawei.com>
Copy link

codecov bot commented Oct 31, 2024

Codecov Report

Attention: Patch coverage is 12.59843% with 111 lines in your changes missing coverage. Please review.

Project coverage is 48.61%. Comparing base (90312f8) to head (a6e025f).
Report is 47 commits behind head on main.

Files with missing lines Patch % Lines
pkg/controller/workload/cache/service_cache.go 0.00% 104 Missing ⚠️
pkg/controller/workload/workload_processor.go 69.56% 5 Missing and 2 partials ⚠️
Files with missing lines Coverage Δ
pkg/controller/workload/workload_processor.go 62.44% <69.56%> (+0.77%) ⬆️
pkg/controller/workload/cache/service_cache.go 0.00% <0.00%> (ø)

... and 8 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 6e56261...a6e025f. Read the comment docs.

Signed-off-by: YaoZengzeng <yaozengzeng@huawei.com>
Signed-off-by: YaoZengzeng <yaozengzeng@huawei.com>
@YaoZengzeng YaoZengzeng changed the title WIP: handle hostname type waypoint for istio 1.24 handle hostname type waypoint for istio 1.24 Nov 1, 2024
@YaoZengzeng
Copy link
Member Author

@hzxuzhonghu Updated, CI fail because of #1004

log.Errorf("storeServiceData failed, err:%s", err)
return err
services := []*workloadapi.Service{service}
services = append(services, servicesToRefresh...)
Copy link
Member

Choose a reason for hiding this comment

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

pre allocate memory make ( ,o, len(servicesToRefresh)+1)

svc3 := createFakeService("svc3", "10.240.10.4", "default/waypoint.default.svc.cluster.local", createLoadBalancing(workloadapi.LoadBalancing_UNSPECIFIED_MODE, make([]workloadapi.LoadBalancing_Scope, 0)))
assert.NoError(t, p.handleService(svc3))

updateWaypointOfService(svc3, waypointIP)
Copy link
Member

Choose a reason for hiding this comment

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

don't you feel the test cases is not friendly to add, it has tight dependency with previous cases?

Copy link
Member Author

Choose a reason for hiding this comment

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

For other cases that are not related to testing waypoint hostname resolution, we could create a a fake service with IP address type, just like before, then we don't have to call updateWaypointOfService everytime.

@tacslon
Copy link
Contributor

tacslon commented Nov 1, 2024

/retest

Signed-off-by: YaoZengzeng <yaozengzeng@huawei.com>
Copy link
Member

@hzxuzhonghu hzxuzhonghu left a comment

Choose a reason for hiding this comment

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

/lgtm

@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

@kmesh-bot kmesh-bot merged commit 217660c into kmesh-net:main Nov 1, 2024
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants