Skip to content

Conversation

@lec-bit
Copy link
Contributor

@lec-bit lec-bit commented Oct 26, 2024

What type of PR is this?
/kind feature

What this PR does / why we need it:

Which issue(s) this PR fixes:
Fixes #

Special notes for your reviewer:

Does this PR introduce a user-facing change?:


Signed-off-by: lec-bit <glfhmzmy@126.com>
Signed-off-by: lec-bit <glfhmzmy@126.com>
Signed-off-by: lec-bit <glfhmzmy@126.com>
@codecov
Copy link

codecov bot commented Oct 28, 2024

Codecov Report

Attention: Patch coverage is 36.98630% with 46 lines in your changes missing coverage. Please review.

Project coverage is 49.34%. Comparing base (6bb2ae0) to head (43f8129).
Report is 51 commits behind head on main.

Files with missing lines Patch % Lines
pkg/bpf/ads/sock_connection.go 50.00% 6 Missing and 4 partials ⚠️
pkg/cache/v2/cluster.go 18.18% 8 Missing and 1 partial ⚠️
pkg/cache/v2/listener.go 18.18% 8 Missing and 1 partial ⚠️
pkg/cache/v2/route.go 18.18% 8 Missing and 1 partial ⚠️
pkg/bpf/utils/bpf_helper.go 33.33% 4 Missing and 2 partials ⚠️
pkg/bpf/workload/sock_connection.go 0.00% 0 Missing and 2 partials ⚠️
pkg/bpf/workload/sock_ops.go 50.00% 0 Missing and 1 partial ⚠️
Files with missing lines Coverage Δ
pkg/bpf/bpf.go 41.75% <100.00%> (+1.61%) ⬆️
pkg/bpf/workload/sendmsg.go 54.90% <ø> (+1.74%) ⬆️
pkg/controller/ads/ads_processor.go 77.13% <100.00%> (+0.20%) ⬆️
pkg/bpf/workload/sock_ops.go 54.90% <50.00%> (-0.55%) ⬇️
pkg/bpf/workload/sock_connection.go 52.94% <0.00%> (-0.74%) ⬇️
pkg/bpf/utils/bpf_helper.go 57.14% <33.33%> (-42.86%) ⬇️
pkg/cache/v2/cluster.go 43.24% <18.18%> (-2.41%) ⬇️
pkg/cache/v2/listener.go 51.85% <18.18%> (-5.90%) ⬇️
pkg/cache/v2/route.go 52.77% <18.18%> (-6.90%) ⬇️
pkg/bpf/ads/sock_connection.go 55.90% <50.00%> (-0.62%) ⬇️

... and 11 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 288f6fa...43f8129. Read the comment docs.

// pin bpf_link and bpf_tail_call map
// pin bpf_link, after restart, update prog in bpf_link
// tail_call map cannot pin in SetMapPinType->LoadAndAssign, we pin them independent
mapPinPath := filepath.Join(sc.Info.BpfFsPath, "sockops_tail_call_map")
Copy link
Contributor

Choose a reason for hiding this comment

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

You can define the path name as a constant in the constant.go file

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ok

func BpfMapDeleteByPinPath(bpfFsPath string) error {
progMap, err := ebpf.LoadPinnedMap(bpfFsPath, nil)
if err != nil {
return fmt.Errorf("loadPinnedProgram failed for %s: %v", bpfFsPath, err)
Copy link
Contributor

Choose a reason for hiding this comment

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

LoadPinnedProgram or LoadPinnedMap?

Copy link
Contributor Author

@lec-bit lec-bit Oct 28, 2024

Choose a reason for hiding this comment

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

LoadPinnedMap here, a type of ebpf_map of BPF_MAP_TYPE_PROG_ARRAY ,I am wrong in log, will fix

func BpfMapDeleteByPinPath(bpfFsPath string) error {
progMap, err := ebpf.LoadPinnedMap(bpfFsPath, nil)
if err != nil {
return fmt.Errorf("loadPinnedProgram failed for %s: %v", bpfFsPath, err)
Copy link
Contributor

Choose a reason for hiding this comment

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

Perhaps your error message should carry more information, such as the circumstances under which this error occurred.

fmt.Errorf("loadPinnedProgram failed for %s: %v, when kmesh delete by pin path", bpfFsPath, err)

sc.Link = lk
pinPath := filepath.Join(sc.Info.BpfFsPath, "trace_point_link")
if restart.GetStartType() == restart.Restart {
lk, err := link.LoadPinnedLink(pinPath, &ebpf.LoadPinOptions{})
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
lk, err := link.LoadPinnedLink(pinPath, &ebpf.LoadPinOptions{})
sc.Link, err := link.LoadPinnedLink(pinPath, &ebpf.LoadPinOptions{})

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ok

sc := &BpfAds{}
sc.TracePoint.NewBpf(cfg)
if err := sc.TracePoint.NewBpf(cfg); err != nil {
return sc, err
Copy link
Member

Choose a reason for hiding this comment

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

By convention, return nil, err.

if err != nil {
// pin bpf_link and bpf_tail_call map
// pin bpf_link, after restart, update prog in bpf_link
// tail_call map cannot pin in SetMapPinType->LoadAndAssign, we pin them independent
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
// tail_call map cannot pin in SetMapPinType->LoadAndAssign, we pin them independent
// tail_call map cannot pin in SetMapPinType->LoadAndAssign, we pin them independently

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ok

@LiZhenCheng9527
Copy link
Contributor

Does ads has restart e2e test?

VersionPath = "/bpf_kmesh/map/"
WorkloadVersionPath = "/bpf_kmesh_workload/map/"

Tail_call_map = "tail_call_map"
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
Tail_call_map = "tail_call_map"
TailCallMap = "tail_call_map"

In go, everyone uses camel naming by default.

@YaoZengzeng
Copy link
Member

Does ads has restart e2e test?

Ads doesn't have E2E tests.

Signed-off-by: lec-bit <glfhmzmy@126.com>
Signed-off-by: lec-bit <glfhmzmy@126.com>
Signed-off-by: lec-bit <glfhmzmy@126.com>
Signed-off-by: lec-bit <glfhmzmy@126.com>
@kmesh-bot
Copy link
Collaborator

Adding label do-not-merge/contains-merge-commits because PR contains merge commits, which are not allowed in this repository.
Use git rebase to reapply your commits on top of the target branch. Detailed instructions for doing so can be found here.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@lec-bit lec-bit force-pushed the kernel_native_restart branch 2 times, most recently from 8e514ec to 976cdd2 Compare November 6, 2024 02:15
Signed-off-by: lec-bit <glfhmzmy@126.com>
Signed-off-by: lec-bit <glfhmzmy@126.com>
t.Run("new start", func(t *testing.T) {
runTestNormal(t)
t.Run("new start DualEengine", func(t *testing.T) {
runTestNormalDualEengine(t)
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
runTestNormalDualEengine(t)
runTestNormalDualEngine(t)

Spelling mistakes. Check them.

NameToLds: *c.AdsController.Processor.Cache.ListenerCache.GetListenerHashPtr(),
NameToRds: *c.AdsController.Processor.Cache.RouteCache.GetRouteHashPtr(),
}
ads.ResetPersistFile()
Copy link
Contributor

Choose a reason for hiding this comment

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

Where is the hash persistence code in dual-engine mode?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

func (p *Processor) handleRemovedAddressesDuringRestart() {

lec-bit and others added 7 commits November 22, 2024 01:48
Signed-off-by: lec-bit <glfhzmy@126.com>
Signed-off-by: lec-bit <glfhzmy@126.com>
Signed-off-by: lec-bit <glfhmzmy@126.com>
Signed-off-by: lec-bit <glfhmzmy@126.com>
Signed-off-by: lec-bit <glfhmzmy@126.com>
Signed-off-by: lec-bit <glfhmzmy@126.com>
return sclink, nil
}

// func BpfMapDeleteByPinPath(bpfFsPath string) error {
Copy link
Contributor

Choose a reason for hiding this comment

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

remove

@nlgwcy
Copy link
Contributor

nlgwcy commented Nov 25, 2024

/lgtm

Signed-off-by: lec-bit <glfhzmy@126.com>
@lec-bit lec-bit force-pushed the kernel_native_restart branch from 55b1935 to 5a0e629 Compare November 25, 2024 01:56
lastNonce *lastNonce
// the channel used to send domains to dns resolver. key is domain name and value is refreshrate
DnsResolverChan chan []*config_cluster_v3.Cluster
once [3]sync.Once
Copy link
Member

Choose a reason for hiding this comment

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

This looks tricky.

}

// Should only be used by test
func ResetPersistFile() {
Copy link
Member

Choose a reason for hiding this comment

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

Feel remove is clearer than reset

func (l *BpfLoader) Stop() {
var err error
if restart.GetExitType() == restart.Restart && l.config.DualEngineEnabled() {
C.deserial_uninit()
Copy link
Member

Choose a reason for hiding this comment

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

why remove C.deserial_uninit()

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The deserial logic is updated, and now the default C.deserial_uninit().

Signed-off-by: lec-bit <glfhzmy@126.com>
@lec-bit lec-bit force-pushed the kernel_native_restart branch from 27eaacd to f316c05 Compare November 28, 2024 01:29
if err != nil {
// pin bpf_tail_call map
// tail_call map cannot pin in SetMapPinType->LoadAndAssign, we pin them independently
mapPinPath := filepath.Join(sc.Info.BpfFsPath, constants.TailCallMap)
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
mapPinPath := filepath.Join(sc.Info.BpfFsPath, constants.TailCallMap)
tailCallMapPinPath := filepath.Join(sc.Info.BpfFsPath, constants.TailCallMap)

// pin bpf_link and bpf_tail_call map
// pin bpf_link, after restart, update prog in bpf_link
// tail_call map cannot pin in SetMapPinType->LoadAndAssign, we pin them independently
mapPinPath := filepath.Join(sc.Info.BpfFsPath, constants.TailCallMap)
Copy link
Member

Choose a reason for hiding this comment

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

ditto

Signed-off-by: lec-bit <glfhmzmy@126.com>
@hzxuzhonghu
Copy link
Member

/lgtm
/approve

@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 071bfd8 into kmesh-net:main Nov 28, 2024
12 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.

6 participants