mirror of
https://github.com/kubevela/kubevela.git
synced 2026-08-18 20:17:04 +00:00
Feat: Refer to the generation when checking the application status (#4901)
* Feat: Refer to the generation when checking the application status Signed-off-by: barnettZQG <barnett.zqg@gmail.com> * Fix: add the test Signed-off-by: barnettZQG <barnett.zqg@gmail.com> * Fix: the starting status overrided the deleting status Signed-off-by: barnettZQG <barnett.zqg@gmail.com> Signed-off-by: barnettZQG <barnett.zqg@gmail.com>
This commit is contained in:
@@ -291,8 +291,11 @@ func (c *applicationServiceImpl) GetApplicationStatus(ctx context.Context, appmo
|
||||
}
|
||||
return nil, err
|
||||
}
|
||||
if app.Generation > app.Status.ObservedGeneration {
|
||||
app.Status.Phase = common.ApplicationStarting
|
||||
}
|
||||
if !app.DeletionTimestamp.IsZero() {
|
||||
app.Status.Phase = "deleting"
|
||||
app.Status.Phase = common.ApplicationDeleting
|
||||
}
|
||||
return &app.Status, nil
|
||||
}
|
||||
|
||||
@@ -442,6 +442,11 @@ var _ = Describe("Test application service function", func() {
|
||||
Expect(err).Should(BeNil())
|
||||
Expect(revision.DeployUser.Name).Should(Equal(model.DefaultAdminUserName))
|
||||
Expect(revision.DeployUser.Alias).Should(Equal(model.DefaultAdminUserAlias))
|
||||
|
||||
appStats, err := appService.GetApplicationStatus(context.TODO(), appModel, "app-dev")
|
||||
Expect(err).Should(BeNil())
|
||||
Expect(appStats.Phase).Should(Equal(common.ApplicationStarting))
|
||||
|
||||
err = envBindingService.ApplicationEnvRecycle(context.TODO(), &model.Application{
|
||||
Name: testApp,
|
||||
}, &model.EnvBinding{Name: "app-dev"})
|
||||
|
||||
+15
-9
@@ -995,17 +995,23 @@ func waitApplicationRunning(k8sClient client.Client, addonName string) error {
|
||||
if err != nil {
|
||||
return client.IgnoreNotFound(err)
|
||||
}
|
||||
|
||||
phase := app.Status.Phase
|
||||
switch app.Status.Phase {
|
||||
case common2.ApplicationRunning:
|
||||
return nil
|
||||
case common2.ApplicationWorkflowSuspending:
|
||||
fmt.Printf("Enabling suspend, please run \"vela workflow resume %s -n vela-system\" to continue", addonutil.Addon2AppName(addonName))
|
||||
return nil
|
||||
case common2.ApplicationWorkflowTerminated, common2.ApplicationWorkflowFailed:
|
||||
return errors.Errorf("Enabling failed, please run \"vela status %s -n vela-system\" to check the status of the addon", addonutil.Addon2AppName(addonName))
|
||||
default:
|
||||
if app.Generation > app.Status.ObservedGeneration {
|
||||
phase = common2.ApplicationStarting
|
||||
} else {
|
||||
switch app.Status.Phase {
|
||||
case common2.ApplicationRunning:
|
||||
return nil
|
||||
case common2.ApplicationWorkflowSuspending:
|
||||
fmt.Printf("Enabling suspend, please run \"vela workflow resume %s -n vela-system\" to continue", addonutil.Addon2AppName(addonName))
|
||||
return nil
|
||||
case common2.ApplicationWorkflowTerminated, common2.ApplicationWorkflowFailed:
|
||||
return errors.Errorf("Enabling failed, please run \"vela status %s -n vela-system\" to check the status of the addon", addonutil.Addon2AppName(addonName))
|
||||
default:
|
||||
}
|
||||
}
|
||||
|
||||
timeConsumed := int(time.Since(start).Seconds())
|
||||
applySpinnerNewSuffix(spinner, fmt.Sprintf("Waiting addon application running. It is now in phase: %s (timeout %d/%d seconds)...",
|
||||
phase, timeConsumed, int(timeout.Seconds())))
|
||||
|
||||
Reference in New Issue
Block a user