Skip to content

Commit ac5733f

Browse files
Syspretor玖宇
andauthored
Clean up orphaned resources (#4884)
Signed-off-by: 玖宇 <guotongyu.gty@alibaba-inc.com> Co-authored-by: 玖宇 <guotongyu.gty@alibaba-inc.com>
1 parent 64d0c51 commit ac5733f

1 file changed

Lines changed: 13 additions & 4 deletions

File tree

pkg/ddc/thin/shutdown.go

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,13 @@ package thin
1919
import (
2020
"context"
2121
"fmt"
22+
2223
"github.com/fluid-cloudnative/fluid/pkg/common"
2324
"github.com/fluid-cloudnative/fluid/pkg/utils"
2425
"github.com/fluid-cloudnative/fluid/pkg/utils/dataset/lifecycle"
2526
"github.com/fluid-cloudnative/fluid/pkg/utils/helm"
2627
"github.com/fluid-cloudnative/fluid/pkg/utils/kubeclient"
28+
2729
corev1 "k8s.io/api/core/v1"
2830
apierrors "k8s.io/apimachinery/pkg/api/errors"
2931
"k8s.io/apimachinery/pkg/labels"
@@ -221,14 +223,21 @@ func (t *ThinEngine) cleanAll() (err error) {
221223

222224
var (
223225
valueConfigmapName = t.getHelmValuesConfigMapName()
224-
configmapName = t.name + "-config"
226+
thinConfigmapName = t.name + "-config"
225227
namespace = t.namespace
226228
)
227229

228-
cms := []string{valueConfigmapName, configmapName}
230+
cmNames := []string{valueConfigmapName, thinConfigmapName}
229231

230-
for _, cm := range cms {
231-
err = kubeclient.DeleteConfigMap(t.Client, cm, namespace)
232+
for _, cmName := range cmNames {
233+
_, err = kubeclient.GetConfigmapByName(t.Client, cmName, namespace)
234+
if err != nil {
235+
if apierrors.IsNotFound(err) {
236+
return nil
237+
}
238+
return err
239+
}
240+
err = kubeclient.DeleteConfigMap(t.Client, cmName, namespace)
232241
if err != nil {
233242
return
234243
}

0 commit comments

Comments
 (0)