Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
Signed-off-by: Zhonghu Xu <[email protected]>
  • Loading branch information
hzxuzhonghu committed Sep 30, 2024
1 parent 6ce9bca commit 9b3bf5f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
3 changes: 2 additions & 1 deletion pkg/bpf/bpf.go
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,7 @@ func NewVersionMap(config *options.BpfConfig) *ebpf.Map {
return nil
}

log.Infof("create version map path %s", versionPath)
if err := os.MkdirAll(versionPath,
syscall.S_IRUSR|syscall.S_IWUSR|syscall.S_IXUSR|syscall.S_IRGRP|syscall.S_IXGRP); err != nil && !os.IsExist(err) {
log.Errorf("mkdir failed %v", err)
Expand All @@ -223,7 +224,7 @@ func NewVersionMap(config *options.BpfConfig) *ebpf.Map {
}

storeVersionInfo(m)
log.Infof("kmesh start with Normal")
log.Infof("store kmesh version successfully")
restart.SetStartType(restart.Normal)
return m
}
Expand Down
9 changes: 7 additions & 2 deletions pkg/bpf/bpf_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import (

"kmesh.net/kmesh/daemon/options"
"kmesh.net/kmesh/pkg/bpf/restart"
"kmesh.net/kmesh/pkg/constants"
)

func TestRestart(t *testing.T) {
Expand Down Expand Up @@ -71,6 +72,10 @@ func runTestNormal(t *testing.T) {
if err := bpfLoader.Start(); err != nil {
assert.ErrorIsf(t, err, nil, "bpfLoader start failed %v", err)
}

versionPath := filepath.Join(config.BpfFsPath, constants.WorkloadVersionPath)
_, err := os.Stat(versionPath)
assert.NoError(t, err)
assert.Equal(t, restart.Normal, restart.GetStartType(), "set kmesh start status failed")
restart.SetExitType(restart.Normal)
bpfLoader.Stop()
Expand All @@ -87,9 +92,9 @@ func runTestRestart(t *testing.T) {
assert.Equal(t, restart.Normal, restart.GetStartType(), "set kmesh start status failed")
restart.SetExitType(restart.Restart)
if config.AdsEnabled() {
versionPath = filepath.Join(config.BpfFsPath + "/bpf_kmesh/map/")
versionPath = filepath.Join(config.BpfFsPath, constants.VersionPath)
} else if config.WdsEnabled() {
versionPath = filepath.Join(config.BpfFsPath + "/bpf_kmesh_workload/map/")
versionPath = filepath.Join(config.BpfFsPath, constants.WorkloadVersionPath)
}
_, err := os.Stat(versionPath)
assert.NoError(t, err)
Expand Down

0 comments on commit 9b3bf5f

Please sign in to comment.