Skip to content

handle hostname type waypoint for istio 1.24#995

Merged
kmesh-bot merged 10 commits intokmesh-net:mainfrom
YaoZengzeng:124
Nov 1, 2024
Merged

handle hostname type waypoint for istio 1.24#995
kmesh-bot merged 10 commits intokmesh-net:mainfrom
YaoZengzeng:124

Conversation

@YaoZengzeng
Copy link
Copy Markdown
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
Copy Markdown
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.

AddOrUpdateService(svc *workloadapi.Service)
DeleteService(resourceName string)
GetService(resourceName string) *workloadapi.Service
HandleWaypoint(svc *workloadapi.Service) []*workloadapi.Service
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.

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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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) {

AddOrUpdateService(svc *workloadapi.Service)
DeleteService(resourceName string)
GetService(resourceName string) *workloadapi.Service
HandleWaypoint(svc *workloadapi.Service) []*workloadapi.Service
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.

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>
import (
"sync"

"istio.io/istio/pkg/log"
Copy link
Copy Markdown
Contributor

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
Copy Markdown
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>
@codecov
Copy link
Copy Markdown

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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
Contributor

tacslon commented Nov 1, 2024

/retest

Signed-off-by: YaoZengzeng <yaozengzeng@huawei.com>
Copy link
Copy Markdown
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
Copy Markdown
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

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

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