diff --git a/pkg/addon/addon.go b/pkg/addon/addon.go index 99c617272..fad950053 100644 --- a/pkg/addon/addon.go +++ b/pkg/addon/addon.go @@ -755,10 +755,6 @@ func (h *Handler) checkDependencies() error { if err != nil { return errors.Wrap(err, "fail to find dependent addon in source repository") } - if !depAddon.Invisible { - return fmt.Errorf("dependent addon %s cannot be enabled automatically", depAddon.Name) - } - // invisible addon SHOULD be enabled without argument depHandler := *h depHandler.addon = depAddon depHandler.args = nil diff --git a/pkg/apiserver/rest/usecase/addon.go b/pkg/apiserver/rest/usecase/addon.go index 511ae52cf..ed8b21f17 100644 --- a/pkg/apiserver/rest/usecase/addon.go +++ b/pkg/apiserver/rest/usecase/addon.go @@ -364,10 +364,14 @@ func (u *addonUsecaseImpl) EnableAddon(ctx context.Context, name string, args ap if addon, exist = u.tryGetAddonFromCache(r.Name, name); !exist { addon, err = SourceOf(*r).GetAddon(name, pkgaddon.EnableLevelOptions) } - if err != nil && !errors.Is(err, pkgaddon.ErrNotExist) { - return bcode.WrapGithubRateLimitErr(err) + + if err != nil { + // one registry return error, should not break other registry func + continue } - if addon == nil { + + // cannot find this addon in the registry + if addon == nil || len(addon.Name) == 0 { continue } diff --git a/references/cli/addon.go b/references/cli/addon.go index 511e0f5f1..796debd99 100644 --- a/references/cli/addon.go +++ b/references/cli/addon.go @@ -54,9 +54,12 @@ const ( AddonTerraformProviderNameArgument = "providerName" ) -var statusUninstalled = "uninstalled" -var statusEnabled = "enabled" -var statusEnabling = "enabling" +const ( + statusUninstalled = "uninstalled" + statusEnabled = "enabled" + statusEnabling = "enabling" +) + var clt client.Client var clientArgs common.Args @@ -232,10 +235,13 @@ func enableAddon(ctx context.Context, k8sClient client.Client, config *rest.Conf source = registry.Git } addon, err = source.GetAddon(name, pkgaddon.EnableLevelOptions) - if err != nil && !errors.Is(err, pkgaddon.ErrNotExist) { - return err + + if err != nil { + continue } - if addon == nil { + + // cannot find this addon in the registry + if addon == nil || addon.Name == "" { continue } err = pkgaddon.EnableAddon(ctx, addon, k8sClient, apply.NewAPIApplicator(k8sClient), config, source, args) @@ -264,7 +270,7 @@ func statusAddon(name string) error { } fmt.Printf("addon %s status is %s \n", name, status) if status == statusEnabling { - fmt.Printf("please check addon related application: namespace: %s name: %s", types.DefaultKubeVelaNS, pkgaddon.Convert2AppName(name)) + fmt.Printf("this addon is still enabling, please run \"vela status %s -n vela-system \" to check the status of the addon related app", pkgaddon.Convert2AppName(name)) } return nil } diff --git a/references/cli/status.go b/references/cli/status.go index 035b0f753..f7552e26e 100644 --- a/references/cli/status.go +++ b/references/cli/status.go @@ -129,8 +129,11 @@ func printAppStatus(_ context.Context, c client.Client, ioStreams cmdutil.IOStre table.AddRow(" Name:", appName) table.AddRow(" Namespace:", namespace) table.AddRow(" Created at:", app.CreationTimestamp.String()) + table.AddRow(" Status:", getAppPhaseColor(app.Status.Phase).Sprint(app.Status.Phase)) cmd.Printf("%s\n\n", table.String()) - + if err := printWorkflowStatus(c, ioStreams, appName, namespace); err != nil { + return err + } cmd.Printf("Services:\n\n") return loopCheckStatus(c, ioStreams, appName, namespace) } @@ -153,6 +156,29 @@ func getComponentType(app *v1beta1.Application, name string) string { return "webservice" } +func printWorkflowStatus(c client.Client, ioStreams cmdutil.IOStreams, appName string, namespace string) error { + remoteApp, err := loadRemoteApplication(c, namespace, appName) + if err != nil { + return err + } + workflowStatus := remoteApp.Status.Workflow + ioStreams.Info("Workflow:\n") + ioStreams.Infof(" mode: %s\n", workflowStatus.Mode) + ioStreams.Infof(" finished: %t\n", workflowStatus.Finished) + ioStreams.Infof(" Suspend: %t\n", workflowStatus.Suspend) + ioStreams.Infof(" Terminated: %t\n", workflowStatus.Terminated) + ioStreams.Info(" Steps") + for _, step := range workflowStatus.Steps { + ioStreams.Infof(" - id:%s\n", step.ID) + ioStreams.Infof(" name:%s\n", step.Name) + ioStreams.Infof(" type:%s\n", step.Type) + ioStreams.Infof(" phase:%s \n", getWfStepColor(step.Phase).Sprint(step.Phase)) + ioStreams.Infof(" message:%s\n", step.Message) + } + ioStreams.Infof("\n") + return nil +} + func loopCheckStatus(c client.Client, ioStreams cmdutil.IOStreams, appName string, namespace string) error { remoteApp, err := loadRemoteApplication(c, namespace, appName) if err != nil { @@ -254,3 +280,21 @@ func getHealthStatusColor(s bool) *color.Color { } return yellow } + +func getWfStepColor(phase commontypes.WorkflowStepPhase) *color.Color { + switch phase { + case commontypes.WorkflowStepPhaseSucceeded: + return green + case commontypes.WorkflowStepPhaseFailed: + return red + default: + return yellow + } +} + +func getAppPhaseColor(appPhase commontypes.ApplicationPhase) *color.Color { + if appPhase == commontypes.ApplicationRunning { + return green + } + return yellow +}