Skip to content

Commit

Permalink
fix: delete test returns error only when deleting test CR fails other…
Browse files Browse the repository at this point in the history
…wise it returns warnings (#3813)

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

* fix: upgrade open api lint action

* fix: open api error

* fix: test
  • Loading branch information
nicufk authored Jun 22, 2023
1 parent 9d07344 commit 9e1f4ae
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
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 @@ -16,6 +16,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 @@ -532,12 +533,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

0 comments on commit 9e1f4ae

Please sign in to comment.