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

fix: delete test returns error only when deleting test CR fails otherwise it returns warnings #3813

Merged
merged 4 commits into from
Jun 22, 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
2 changes: 1 addition & 1 deletion api/v1/testkube.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -649,7 +649,7 @@ paths:
- test-suites
- api
parameters:
- $ref: "#/components/parameters/Name"
- $ref: "#/components/parameters/ID"
summary: "Abort all executions of a test suite"
description: "Abort all test executions of a test suite"
operationId: abortTestSuiteExecutions
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ require (
github.com/gorilla/websocket v1.5.0
github.com/joshdk/go-junit v1.0.0
github.com/kelseyhightower/envconfig v1.4.0
github.com/kubeshop/testkube-operator v1.10.8-0.20230615105405-95faaa73d012
github.com/kubeshop/testkube-operator v1.10.8-0.20230621113013-570eb19fe281
github.com/minio/minio-go/v7 v7.0.47
github.com/montanaflynn/stats v0.6.6
github.com/moogar0880/problems v0.1.1
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -387,8 +387,8 @@ github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
github.com/kubeshop/testkube-operator v1.10.8-0.20230615105405-95faaa73d012 h1:O8nDxO4TGDm6nv8ZjEbnHaBDEPZZQiVE9tJtIN7qkic=
github.com/kubeshop/testkube-operator v1.10.8-0.20230615105405-95faaa73d012/go.mod h1:6Rs8MugOzaMcthGzobf6GBlRzbOFiK/GJiuYN6MCfEw=
github.com/kubeshop/testkube-operator v1.10.8-0.20230621113013-570eb19fe281 h1:5CBaQvzt2BPvI0PiZmdVgHr7t0pUN9fovTk9TpvXwqU=
github.com/kubeshop/testkube-operator v1.10.8-0.20230621113013-570eb19fe281/go.mod h1:6Rs8MugOzaMcthGzobf6GBlRzbOFiK/GJiuYN6MCfEw=
github.com/leodido/go-urn v1.2.1 h1:BqpAaACuzVSgi/VLzGZIobT2z4v53pjosyNd9Yv6n/w=
github.com/leodido/go-urn v1.2.1/go.mod h1:zt4jvISO2HfUBqxjfIshjdMTYS56ZS/qv49ictyFfxY=
github.com/lithammer/fuzzysearch v1.1.8 h1:/HIuJnjHuXS8bKaiTMeeDlW2/AyIWk2brx1V8LFgLN4=
Expand Down
9 changes: 7 additions & 2 deletions internal/app/api/v1/tests.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import (

testsv3 "github.com/kubeshop/testkube-operator/apis/tests/v3"
"github.com/kubeshop/testkube-operator/client/tests/v3"
testsclientv3 "github.com/kubeshop/testkube-operator/client/tests/v3"
"github.com/kubeshop/testkube-operator/pkg/secret"
"github.com/kubeshop/testkube/pkg/api/v1/testkube"
"github.com/kubeshop/testkube/pkg/crd"
Expand Down Expand Up @@ -505,12 +506,16 @@ func (s TestkubeAPI) DeleteTestHandler() fiber.Handler {
return s.Warn(c, http.StatusNotFound, fmt.Errorf("%s: client could not find test: %w", errPrefix, err))
}

return s.Error(c, http.StatusBadGateway, fmt.Errorf("%s: client could not delete test: %w", errPrefix, err))
if _, ok := err.(*testsclientv3.DeleteDependenciesError); ok {
return s.Warn(c, http.StatusInternalServerError, fmt.Errorf("client deleted test %s but deleting test dependencies(secrets) returned errors: %w", name, err))
}

return s.Error(c, http.StatusInternalServerError, fmt.Errorf("%s: client could not delete test: %w", errPrefix, err))
}

// delete executions for test
if err = s.ExecutionResults.DeleteByTest(c.Context(), name); err != nil {
return s.Error(c, http.StatusInternalServerError, fmt.Errorf("%s: could not delete the executions of the test: %w", errPrefix, err))
return s.Warn(c, http.StatusInternalServerError, fmt.Errorf("test %s was deleted but deleting test executions returned error: %w", name, err))
}

return c.SendStatus(http.StatusNoContent)
Expand Down