add version info in fission support (#2645)

This commit is contained in:
neha_gupta
2022-11-30 13:51:24 +05:30
committed by GitHub
parent 918214c0a9
commit e015d6d61f
3 changed files with 42 additions and 12 deletions
+8 -7
View File
@@ -101,13 +101,14 @@ func (opts *DumpSubCommand) do(input cli.Input) error {
"fission-function-pod-log": resources.NewKubernetesPodLogDumper(k8sClient, "executorType in (poolmgr, newdeploy)"),
// CRD resources
"fission-crd-packages": resources.NewCrdDumper(opts.Client(), resources.CrdPackage),
"fission-crd-environments": resources.NewCrdDumper(opts.Client(), resources.CrdEnvironment),
"fission-crd-functions": resources.NewCrdDumper(opts.Client(), resources.CrdFunction),
"fission-crd-httptriggers": resources.NewCrdDumper(opts.Client(), resources.CrdHttpTrigger),
"fission-crd-kubewatchers": resources.NewCrdDumper(opts.Client(), resources.CrdKubeWatcher),
"fission-crd-mqtriggers": resources.NewCrdDumper(opts.Client(), resources.CrdMessageQueueTrigger),
"fission-crd-timetriggers": resources.NewCrdDumper(opts.Client(), resources.CrdTimeTrigger),
"fission-crd-packages": resources.NewCrdDumper(opts.Client(), resources.CrdPackage),
"fission-crd-environments": resources.NewCrdDumper(opts.Client(), resources.CrdEnvironment),
"fission-crd-functions": resources.NewCrdDumper(opts.Client(), resources.CrdFunction),
"fission-crd-httptriggers": resources.NewCrdDumper(opts.Client(), resources.CrdHttpTrigger),
"fission-crd-kubewatchers": resources.NewCrdDumper(opts.Client(), resources.CrdKubeWatcher),
"fission-crd-mqtriggers": resources.NewCrdDumper(opts.Client(), resources.CrdMessageQueueTrigger),
"fission-crd-timetriggers": resources.NewCrdDumper(opts.Client(), resources.CrdTimeTrigger),
"fission-crd-canaryconfigs": resources.NewCrdDumper(opts.Client(), resources.CrdCanaryConfig),
}
dumpName := fmt.Sprintf("%v_%v", DUMP_ARCHIVE_PREFIX, time.Now().Unix())
@@ -36,6 +36,8 @@ const (
CrdKubeWatcher = "KubeWatcher"
CrdMessageQueueTrigger = "MessageQueue"
CrdTimeTrigger = "TimeTrigger"
CrdCanaryConfig = "CanaryConfig"
)
type CrdDumper struct {
@@ -138,6 +140,18 @@ func (res CrdDumper) Dump(ctx context.Context, dumpDir string) {
writeToFile(f, item)
}
case CrdCanaryConfig:
items, err := res.client.FissionClientSet.CoreV1().CanaryConfigs(metav1.NamespaceAll).List(ctx, metav1.ListOptions{})
if err != nil {
console.Warn(fmt.Sprintf("Error getting %v list: %v", res.crdType, err))
return
}
for _, item := range items.Items {
f := getFileName(dumpDir, item.ObjectMeta)
writeToFile(f, item)
}
default:
console.Warn(fmt.Sprintf("Unknown type: %v", res.crdType))
}
+20 -5
View File
@@ -26,6 +26,7 @@ import (
fv1 "github.com/fission/fission/pkg/apis/core/v1"
"github.com/fission/fission/pkg/fission-cli/cliwrapper/cli"
"github.com/fission/fission/pkg/fission-cli/cmd"
"github.com/fission/fission/pkg/fission-cli/console"
"github.com/fission/fission/pkg/fission-cli/util"
)
@@ -96,7 +97,7 @@ func (hc *HealthChecker) CheckKubeVersion() (err error) {
return nil
}
func (hc *HealthChecker) CheckServiceStatus(ctx context.Context, namespace string, name string) (err error) {
func (hc *HealthChecker) CheckServiceStatus(ctx context.Context, namespace, name, svcName string) (err error) {
depl, err := hc.kubeAPI.AppsV1().Deployments(namespace).Get(ctx, name, metav1.GetOptions{})
if err != nil {
return fmt.Errorf("failed to get %s deployment status", name)
@@ -106,7 +107,7 @@ func (hc *HealthChecker) CheckServiceStatus(ctx context.Context, namespace strin
return fmt.Errorf("%s deployment is not running", name)
}
_, err = hc.kubeAPI.CoreV1().Services(namespace).Get(ctx, name, metav1.GetOptions{})
_, err = hc.kubeAPI.CoreV1().Services(namespace).Get(ctx, svcName, metav1.GetOptions{})
if err != nil {
return fmt.Errorf("failed to get %s service status", name)
}
@@ -120,6 +121,9 @@ func (hc *HealthChecker) CheckFissionVersion(ctx context.Context, input cli.Inpu
clientVersion := ver.Client["fission/core"].Version
serverVersion := ver.Server["fission/core"].Version
console.Verbose(2, "clientVersion: %s", clientVersion)
console.Verbose(2, "serverVersion: %s", serverVersion)
if clientVersion != serverVersion {
return fmt.Errorf("client version %s does not match with server version %s", clientVersion, serverVersion)
}
@@ -155,19 +159,30 @@ func (hc *HealthChecker) allCategories() []*Category {
{
successMsg: "executor is running fine",
check: func(ctx context.Context, input cli.Input, client cmd.Client) error {
return hc.CheckServiceStatus(ctx, hc.fissionNamespace, "executor")
return hc.CheckServiceStatus(ctx, hc.fissionNamespace, "executor", "executor")
},
},
{
successMsg: "router is running fine",
check: func(ctx context.Context, input cli.Input, client cmd.Client) error {
return hc.CheckServiceStatus(ctx, hc.fissionNamespace, "router")
return hc.CheckServiceStatus(ctx, hc.fissionNamespace, "router", "router")
},
},
{
successMsg: "storagesvc is running fine",
check: func(ctx context.Context, input cli.Input, client cmd.Client) error {
return hc.CheckServiceStatus(ctx, hc.fissionNamespace, "storagesvc")
return hc.CheckServiceStatus(ctx, hc.fissionNamespace, "storagesvc", "storagesvc")
},
},
{
successMsg: "webhook is running fine",
check: func(ctx context.Context, input cli.Input, client cmd.Client) error {
err := hc.CheckServiceStatus(ctx, hc.fissionNamespace, "webhook", "webhook-service")
if err != nil {
console.Errorf("Error found: %s", err.Error())
}
return err
},
},
},