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 in workload #1021

Merged
merged 10 commits into from
Nov 18, 2024

Conversation

YaoZengzeng
Copy link
Member

What type of PR is this?

/kind bug

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.

Supplement to PR #995

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

Special notes for your reviewer:

Does this PR introduce a user-facing change?:


Copy link

codecov bot commented Nov 8, 2024

Codecov Report

Attention: Patch coverage is 74.79339% with 61 lines in your changes missing coverage. Please review.

Project coverage is 49.49%. Comparing base (edc7c5e) to head (279951e).
Report is 26 commits behind head on main.

Files with missing lines Patch % Lines
pkg/controller/workload/cache/waypoint_cache.go 75.51% 40 Missing and 8 partials ⚠️
pkg/controller/workload/workload_processor.go 71.73% 8 Missing and 5 partials ⚠️
Files with missing lines Coverage Δ
pkg/controller/workload/cache/service_cache.go 30.76% <ø> (+30.76%) ⬆️
pkg/controller/workload/workload_processor.go 62.23% <71.73%> (-0.21%) ⬇️
pkg/controller/workload/cache/waypoint_cache.go 75.51% <75.51%> (ø)

... 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 cb05690...279951e. Read the comment docs.

@YaoZengzeng
Copy link
Member Author

/retest

@YaoZengzeng YaoZengzeng changed the title WIP: handle hostname type waypoint in workload handle hostname type waypoint in workload Nov 8, 2024
@YaoZengzeng
Copy link
Member Author

@hzxuzhonghu PTAL

hzxuzhonghu
hzxuzhonghu previously approved these changes Nov 11, 2024
return nil, nil
}

type associatedObjects struct {
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
type associatedObjects struct {
type waypointAssociatedObjects struct {

}

func (w *associatedObjects) isResolved() bool {
return w.address != nil
Copy link
Member

Choose a reason for hiding this comment

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

donot you need to protect address?

// AddOrUpdateWorkload add or update workload in this cache, return true if the
// workload's waypoint doesn't need to be resolved or resolved successfully.
AddOrUpateWorkload(workload *workloadapi.Workload) bool
DeleteWorkload(uid string)
Copy link
Member

Choose a reason for hiding this comment

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

And they are duplicate with workload cache

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, but it's a tradeoff and duplicating a little code now maybe better than making further abstractions.

// Anyway, add svc to the association list.
w.waypointAssociatedObjects[waypointResourceName].addService(resourceName, svc)

return ret
Copy link
Member

Choose a reason for hiding this comment

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

Could you add ut coverage for this branch

}

log.Debugf("Refreshing services associated with waypoint %s", resourceName)
return associated.update(address)
Copy link
Member

Choose a reason for hiding this comment

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

Also add ut coverage for this

@hzxuzhonghu
Copy link
Member

@YaoZengzeng please add some ut, then we can merge

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>
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>
@@ -14,15 +14,15 @@
* and sidecar containers. The bpf_sk_original_addr auxiliary function is
* used to obtain the original destination address.
*/
#define MDA_NAT_ACCEL 1
#define MDA_NAT_ACCEL 0
Copy link
Collaborator

Choose a reason for hiding this comment

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

retract

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

func (w *waypointCache) AddOrUpdateService(svc *workloadapi.Service) bool {
w.mutex.Lock()
defer w.mutex.Unlock()
Copy link
Collaborator

Choose a reason for hiding this comment

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

Do you need to lock the whole function?

Copy link
Member Author

Choose a reason for hiding this comment

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

It's OK, we should make it easy at first. If we find this is a performance bottleneck later, we can further optimize it and make more precise control.

@YaoZengzeng
Copy link
Member Author

@hzxuzhonghu updated

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 ce92599 into kmesh-net:main Nov 18, 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.

4 participants