Skip to content

Commit

Permalink
[fix] some bug fix, and support clean walfiles
Browse files Browse the repository at this point in the history
Signed-off-by: zyb521 <[email protected]>
  • Loading branch information
zyb521 committed Jul 20, 2023
1 parent ab13de3 commit e2eea99
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 0 deletions.
6 changes: 6 additions & 0 deletions internal/configure/topology/dc_get.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ const (
LAYOUT_TOOLS_DIR = "/tools"
LAYOUT_TOOLS_V2_DIR = "/tools-v2"
LAYOUT_CURVEBS_CHUNKFILE_POOL_DIR = "chunkfilepool"
LAYOUT_CURVEBS_WALFILE_POOL_DIR = "walfilepool"
LAYOUT_CURVEBS_COPYSETS_DIR = "copysets"
LAYOUT_CURVEBS_RECYCLER_DIR = "recycler"
LAYOUT_CURVEBS_TOOLS_CONFIG_SYSTEM_PATH = "/etc/curve/tools.conf"
Expand All @@ -58,6 +59,7 @@ const (
BINARY_CURVEFS_TOOL = "curvefs_tool"
BINARY_CURVE_TOOL_V2 = "curve"
METAFILE_CHUNKFILE_POOL = "chunkfilepool.meta"
METAFILE_WALFILE_POOL = "walfilepool.meta"
METAFILE_CHUNKSERVER_ID = "chunkserver.dat"
)

Expand Down Expand Up @@ -285,6 +287,7 @@ func (dc *DeployConfig) GetProjectLayout() Layout {

// format
chunkserverDataDir := fmt.Sprintf("%s/%s%s", root, ROLE_CHUNKSERVER, LAYOUT_SERVICE_DATA_DIR)
chunkserverWalDir := fmt.Sprintf("%s/%s%s", root, ROLE_CHUNKSERVER, LAYOUT_SERVICE_WAL_DIR)

return Layout{
// project
Expand Down Expand Up @@ -324,6 +327,9 @@ func (dc *DeployConfig) GetProjectLayout() Layout {
ChunkfilePoolRootDir: chunkserverDataDir,
ChunkfilePoolDir: fmt.Sprintf("%s/%s", chunkserverDataDir, LAYOUT_CURVEBS_CHUNKFILE_POOL_DIR),
ChunkfilePoolMetaPath: fmt.Sprintf("%s/%s", chunkserverDataDir, METAFILE_CHUNKFILE_POOL),
WalfilePoolRootDir: chunkserverWalDir,
WalfilePoolDir: fmt.Sprintf("%s/%s", chunkserverWalDir, LAYOUT_CURVEBS_WALFILE_POOL_DIR),
WalfilePoolMetaPath: fmt.Sprintf("%s/%s", chunkserverWalDir, METAFILE_WALFILE_POOL),

// core
CoreSystemDir: LAYOUT_CORE_SYSTEM_DIR,
Expand Down
17 changes: 17 additions & 0 deletions internal/task/task/common/clean_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ import (

const (
LAYOUT_CURVEBS_CHUNKFILE_POOL_DIR = topology.LAYOUT_CURVEBS_CHUNKFILE_POOL_DIR
LAYOUT_CURVEBS_WALFILE_POOL_DIR = topology.LAYOUT_CURVEBS_WALFILE_POOL_DIR
LAYOUT_CURVEBS_COPYSETS_DIR = topology.LAYOUT_CURVEBS_COPYSETS_DIR
LAYOUT_CURVEBS_RECYCLER_DIR = topology.LAYOUT_CURVEBS_RECYCLER_DIR
METAFILE_CHUNKSERVER_ID = topology.METAFILE_CHUNKSERVER_ID
Expand Down Expand Up @@ -97,6 +98,17 @@ func (s *step2RecycleChunk) Execute(ctx *context.Context) error {
if err != nil {
errno.ERR_RUN_SCRIPT_FAILED.E(err)
}

walDir := dc.GetWalDir()
if walDir != "" {
source = fmt.Sprintf("%s/%s", walDir, LAYOUT_CURVEBS_COPYSETS_DIR)
dest = fmt.Sprintf("%s/%s", walDir, LAYOUT_CURVEBS_WALFILE_POOL_DIR)
cmd = ctx.Module().Shell().BashScript(s.recycleScriptPath, source, dest, chunkSize)
_, err = cmd.Execute(s.execOptions)
if err != nil {
errno.ERR_RUN_SCRIPT_FAILED.E(err)
}
}
return nil
}

Expand Down Expand Up @@ -133,9 +145,14 @@ func getCleanFiles(clean map[string]bool, dc *topology.DeployConfig, recycle boo
files = append(files, dc.GetDataDir())
} else {
dataDir := dc.GetDataDir()
walDir := dc.GetWalDir()
copysetsDir := fmt.Sprintf("%s/%s", dataDir, LAYOUT_CURVEBS_COPYSETS_DIR)
chunkserverIdMetafile := fmt.Sprintf("%s/%s", dataDir, METAFILE_CHUNKSERVER_ID)
files = append(files, copysetsDir, chunkserverIdMetafile)
if walDir != "" {
walCopysetsDir := fmt.Sprintf("%s/%s", walDir, LAYOUT_CURVEBS_COPYSETS_DIR)
files = append(files, walCopysetsDir)
}
}
}
}
Expand Down
3 changes: 3 additions & 0 deletions internal/task/task/common/create_container.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,9 @@ func getArguments(dc *topology.DeployConfig) string {
layout := dc.GetProjectLayout()
dataDir := layout.ServiceDataDir
walDir := layout.ServiceWalDir
if dc.GetWalDir() == "" {
walDir = dataDir
}
chunkserverArguments := map[string]interface{}{
// chunkserver
"conf": layout.ServiceConfPath,
Expand Down

0 comments on commit e2eea99

Please sign in to comment.