Skip to content

Commit ae3a6fc

Browse files
author
玖宇
committed
Clean up orphaned resources
Signed-off-by: 玖宇 <guotongyu.gty@alibaba-inc.com>
1 parent 21c9735 commit ae3a6fc

1 file changed

Lines changed: 14 additions & 4 deletions

File tree

pkg/ddc/thin/shutdown.go

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,16 @@ 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"
31+
k8serrors "k8s.io/apimachinery/pkg/api/errors"
2932
"k8s.io/apimachinery/pkg/labels"
3033
"k8s.io/client-go/util/retry"
3134
"sigs.k8s.io/controller-runtime/pkg/client"
@@ -221,14 +224,21 @@ func (t *ThinEngine) cleanAll() (err error) {
221224

222225
var (
223226
valueConfigmapName = t.getHelmValuesConfigMapName()
224-
configmapName = t.name + "-config"
227+
thinConfigmapName = t.name + "-config"
225228
namespace = t.namespace
226229
)
227230

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

230-
for _, cm := range cms {
231-
err = kubeclient.DeleteConfigMap(t.Client, cm, namespace)
233+
for _, cmName := range cmNames {
234+
_, err = kubeclient.GetConfigmapByName(t.Client, cmName, namespace)
235+
if err != nil {
236+
if k8serrors.IsNotFound(err) {
237+
return nil
238+
}
239+
return err
240+
}
241+
err = kubeclient.DeleteConfigMap(t.Client, cmName, namespace)
232242
if err != nil {
233243
return
234244
}

0 commit comments

Comments
 (0)