Improve console message in case no k8s connection possible

This commit is contained in:
Andrei Pohilko
2023-03-13 15:26:32 +00:00
parent 57d4d073e9
commit e9ee10287b
2 changed files with 10 additions and 3 deletions

View File

@@ -3,6 +3,7 @@ package main
import (
"context"
"fmt"
"github.com/joomcode/errorx"
"os"
"os/signal"
"strings"
@@ -73,7 +74,13 @@ func main() {
address, webServerDone, err := server.StartServer(ctx, cancel)
if err != nil {
log.Fatalf("Failed to start Helm Dashboard: %+v", err)
if errorx.IsOfType(err, errorx.InitializationFailed) {
log.Debugf("Full error: %+v", err)
log.Errorf("No Kubernetes cluster connection possible. Make sure you have valid kubeconfig file or run dashboard from inside cluster. See https://kubernetes.io/docs/concepts/configuration/organize-cluster-access-kubeconfig/")
os.Exit(1)
} else {
log.Fatalf("Failed to start Helm Dashboard: %+v", err)
}
}
if !opts.NoTracking {

View File

@@ -46,7 +46,7 @@ func (s *Server) StartServer(ctx context.Context, cancel context.CancelFunc) (st
err = s.detectClusterMode(data)
if err != nil {
return "", nil, err
return "", nil, errorx.Decorate(err, "Failed to detect cluster mode")
}
go checkUpgrade(data.StatusInfo)
@@ -80,7 +80,7 @@ func (s *Server) detectClusterMode(data *objects.DataLayer) error {
}
ns, err := app.K8s.GetNameSpaces()
if err != nil { // no point in continuing without kubectl context and k8s connection
return err
return errorx.InitializationFailed.Wrap(err, "No k8s cluster connection")
}
log.Debugf("Got %d namespaces listed", len(ns.Items))
data.StatusInfo.ClusterMode = true