From e768debef8cbb9ca3f0e491f2cc42a13bed3df89 Mon Sep 17 00:00:00 2001 From: lucasliang Date: Tue, 3 Dec 2024 11:20:01 +0800 Subject: [PATCH] Del paths if needs. Signed-off-by: lucasliang --- pkg/cluster/operation/destroy.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/pkg/cluster/operation/destroy.go b/pkg/cluster/operation/destroy.go index 08e53b9e8d..49985942d5 100644 --- a/pkg/cluster/operation/destroy.go +++ b/pkg/cluster/operation/destroy.go @@ -382,6 +382,15 @@ func DestroyComponent(ctx context.Context, instances []spec.Instance, cls spec.T } } + // For TiKV, we need to delete all extra data directories if the data is not retained. + if ins.ComponentName() == spec.ComponentTiKV { + for _, dir := range ins.UsedDirs() { + if !dataRetained { + delPaths.Insert(dir) + } + } + } + // For TiFlash, we need to delete storage.remote.cache.dir if ins.ComponentName() == spec.ComponentTiFlash { tiflashInstance := ins.(*spec.TiFlashInstance)