mirror of
https://github.com/kubevela/kubevela.git
synced 2026-05-06 01:17:09 +00:00
Fix: conflict while using gc policy and shared-resource policy concurrently
Signed-off-by: Somefive <yd219913@alibaba-inc.com>
This commit is contained in:
@@ -371,6 +371,7 @@ func DeleteManagedResourceInApplication(ctx context.Context, cli client.Client,
|
||||
}
|
||||
return nil
|
||||
}
|
||||
util.RemoveAnnotations(obj, []string{oam.AnnotationAppSharedBy})
|
||||
}
|
||||
if mr.SkipGC || hasOrphanFinalizer(app) {
|
||||
if labels := obj.GetLabels(); labels != nil {
|
||||
|
||||
@@ -912,5 +912,26 @@ var _ = Describe("Test multicluster scenario", func() {
|
||||
g.Expect(cnt).Should(Equal(1))
|
||||
}).WithTimeout(30 * time.Second).WithPolling(2 * time.Second).Should(Succeed())
|
||||
})
|
||||
|
||||
It("Test application with gc policy and shared-resource policy", func() {
|
||||
app := &v1beta1.Application{}
|
||||
bs, err := os.ReadFile("./testdata/app/app-gc-shared.yaml")
|
||||
Expect(err).Should(Succeed())
|
||||
Expect(yaml.Unmarshal(bs, app)).Should(Succeed())
|
||||
app.SetNamespace(namespace)
|
||||
Expect(k8sClient.Create(hubCtx, app)).Should(Succeed())
|
||||
appKey := client.ObjectKeyFromObject(app)
|
||||
Eventually(func(g Gomega) {
|
||||
g.Expect(k8sClient.Get(hubCtx, appKey, app)).Should(Succeed())
|
||||
g.Expect(app.Status.Phase).Should(Equal(common.ApplicationRunning))
|
||||
g.Expect(k8sClient.Get(hubCtx, appKey, &corev1.ConfigMap{})).Should(Succeed())
|
||||
}).WithTimeout(10 * time.Second).Should(Succeed())
|
||||
Expect(k8sClient.Get(hubCtx, appKey, app)).Should(Succeed())
|
||||
Expect(k8sClient.Delete(hubCtx, app)).Should(Succeed())
|
||||
Eventually(func(g Gomega) {
|
||||
g.Expect(kerrors.IsNotFound(k8sClient.Get(hubCtx, appKey, app))).Should(BeTrue())
|
||||
g.Expect(k8sClient.Get(hubCtx, appKey, &corev1.ConfigMap{})).Should(Succeed())
|
||||
}).WithTimeout(10 * time.Second).Should(Succeed())
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
26
test/e2e-multicluster-test/testdata/app/app-gc-shared.yaml
vendored
Normal file
26
test/e2e-multicluster-test/testdata/app/app-gc-shared.yaml
vendored
Normal file
@@ -0,0 +1,26 @@
|
||||
apiVersion: core.oam.dev/v1beta1
|
||||
kind: Application
|
||||
metadata:
|
||||
name: app-gc-shared
|
||||
spec:
|
||||
components:
|
||||
- type: k8s-objects
|
||||
name: app-gc-shared
|
||||
properties:
|
||||
objects:
|
||||
- apiVersion: v1
|
||||
kind: ConfigMap
|
||||
policies:
|
||||
- name: gc-policy
|
||||
type: garbage-collect
|
||||
properties:
|
||||
rules:
|
||||
- selector:
|
||||
resourceTypes: ["ConfigMap"]
|
||||
strategy: never
|
||||
- name: shared-policy
|
||||
type: shared-resource
|
||||
properties:
|
||||
rules:
|
||||
- selector:
|
||||
resourceTypes: ["ConfigMap"]
|
||||
Reference in New Issue
Block a user