Skip to content

Commit 6552f30

Browse files
authored
cluster: remove created directories after fio test in tiup cluster check (#2511)
* remove checkDir * update to dir * use iteration
1 parent 5454848 commit 6552f30

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

pkg/cluster/task/check.go

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,19 @@ func (c *CheckSys) runFIO(ctx context.Context) (outRR []byte, outRW []byte, outL
188188
testWd := filepath.Join(checkDir, "tiup-fio-test")
189189
fioBin := filepath.Join(CheckToolsPathDir, "bin", "fio")
190190

191+
notExistDir := testWd
192+
for {
193+
parent := filepath.Dir(notExistDir)
194+
if len(parent) <= 1 {
195+
break
196+
}
197+
results := operator.CheckDirIsExist(ctx, e, parent)
198+
if len(results) > 0 {
199+
break
200+
}
201+
notExistDir = parent
202+
}
203+
191204
var stderr []byte
192205

193206
// rand read
@@ -309,7 +322,7 @@ func (c *CheckSys) runFIO(ctx context.Context) (outRR []byte, outRW []byte, outL
309322
// cleanup
310323
_, stderr, err = e.Execute(
311324
ctx,
312-
fmt.Sprintf("rm -rf %s", testWd),
325+
fmt.Sprintf("rm -rf %s", notExistDir),
313326
false,
314327
)
315328
if err != nil {

0 commit comments

Comments
 (0)