Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: deployment history release not found err handling #3811

Merged
merged 3 commits into from
Sep 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions api/helm-app/applicationClient.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import (
"context"
"fmt"
"github.com/caarlos0/env"
"github.com/devtron-labs/devtron/internal/constants"
"github.com/devtron-labs/devtron/internal/util"
"go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc"
"go.uber.org/zap"
"google.golang.org/grpc"
Expand Down Expand Up @@ -156,6 +158,13 @@ func (impl *HelmAppClientImpl) GetDeploymentHistory(ctx context.Context, in *App
}
history, err := applicationClient.GetDeploymentHistory(ctx, in)
if err != nil {
if util.GetGRPCErrorDetailedMessage(err) == ErrReleaseNotFound {
err = &util.ApiError{
Code: constants.HelmReleaseNotFound,
InternalMessage: ErrReleaseNotFound,
UserMessage: fmt.Sprintf("no release found with release name '%s'", in.ReleaseName),
}
}
return nil, err
}
return history, nil
Expand Down
1 change: 1 addition & 0 deletions api/helm-app/bean.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ const (
SOURCE_HELM_APP SourceAppType = "helm-app"
SOURCE_EXTERNAL_HELM_APP SourceAppType = "external-helm-app"
SOURCE_UNKNOWN SourceAppType = "unknown"
ErrReleaseNotFound string = "release: not found"
)

type SourceAppType string
Expand Down
1 change: 1 addition & 0 deletions internal/constants/InternalErrorCode.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ const (
UserUpdateFetchRoleFailed string = "6008"

AppDetailResourceTreeNotFound string = "7000"
HelmReleaseNotFound string = "7001"

CasbinPolicyNotCreated string = "8000"

Expand Down
10 changes: 9 additions & 1 deletion internal/util/ErrorUtil.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ package util
import (
"fmt"
"github.com/go-pg/pg"
"google.golang.org/grpc/status"
)

type ApiError struct {
Expand All @@ -39,11 +40,18 @@ func (e *ApiError) ErrorfInternal(format string, a ...interface{}) error {
return &ApiError{InternalMessage: fmt.Sprintf(format, a...)}
}

//default user message will be set
// default user message will be set
func (e ApiError) ErrorfUser(format string, a ...interface{}) error {
return &ApiError{InternalMessage: fmt.Sprintf(format, a...)}
}

func IsErrNoRows(err error) bool {
return pg.ErrNoRows == err
}

func GetGRPCErrorDetailedMessage(err error) string {
if errStatus, ok := status.FromError(err); ok {
return errStatus.Message()
}
return ""
}
Loading