Feat: support pause reconcile (#5732)

Signed-off-by: Somefive <yd219913@alibaba-inc.com>
This commit is contained in:
Somefive
2023-03-24 13:19:44 +08:00
committed by GitHub
parent d694dff4de
commit 4aa14fc337
5 changed files with 45 additions and 3 deletions

View File

@@ -24,6 +24,7 @@ import (
"strings"
"time"
"github.com/kubevela/pkg/controller/reconciler"
workflowv1alpha1 "github.com/kubevela/workflow/api/v1alpha1"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
@@ -987,5 +988,28 @@ var _ = Describe("Test multicluster scenario", func() {
g.Expect(app.Status.Services[0].Traits[0].Healthy).Should(BeTrue())
}).WithTimeout(20 * time.Second).Should(Succeed())
})
It("Test pause application", func() {
app := &v1beta1.Application{}
bs, err := os.ReadFile("./testdata/app/app-pause.yaml")
Expect(err).Should(Succeed())
Expect(yaml.Unmarshal(bs, app)).Should(Succeed())
app.SetNamespace(namespace)
Expect(k8sClient.Create(hubCtx, app)).Should(Succeed())
time.Sleep(10 * time.Second)
appKey := client.ObjectKeyFromObject(app)
Expect(k8sClient.Get(hubCtx, appKey, app)).Should(Succeed())
Expect(app.Status.Workflow).Should(BeNil())
Eventually(func(g Gomega) {
g.Expect(k8sClient.Get(hubCtx, appKey, app)).Should(Succeed())
reconciler.SetPause(app, false)
g.Expect(k8sClient.Update(hubCtx, app)).Should(Succeed())
}).WithTimeout(5 * time.Second).WithPolling(time.Second).Should(Succeed())
Eventually(func(g Gomega) {
g.Expect(k8sClient.Get(hubCtx, appKey, app)).Should(Succeed())
g.Expect(app.Status.Phase).Should(Equal(common.ApplicationRunning))
}).WithTimeout(15 * time.Second).WithPolling(3 * time.Second).Should(Succeed())
Expect(k8sClient.Delete(hubCtx, app)).Should(Succeed())
})
})
})

View File

@@ -0,0 +1,15 @@
apiVersion: core.oam.dev/v1beta1
kind: Application
metadata:
name: busybox
labels:
controller.core.oam.dev/pause: "true"
spec:
components:
- name: data-worker
type: worker
properties:
image: busybox
cmd:
- sleep
- '1000000'