diff --git a/internal/configure/topology/dc_get.go b/internal/configure/topology/dc_get.go index 948b16bf1..9b464a6d7 100644 --- a/internal/configure/topology/dc_get.go +++ b/internal/configure/topology/dc_get.go @@ -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" @@ -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" ) @@ -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 @@ -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, diff --git a/internal/task/task/common/clean_service.go b/internal/task/task/common/clean_service.go index e800e70f1..ec3b4c693 100644 --- a/internal/task/task/common/clean_service.go +++ b/internal/task/task/common/clean_service.go @@ -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 @@ -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 } @@ -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) + } } } } diff --git a/internal/task/task/common/create_container.go b/internal/task/task/common/create_container.go index 30b0d6afe..1afabbf6a 100644 --- a/internal/task/task/common/create_container.go +++ b/internal/task/task/common/create_container.go @@ -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,