Unified Storage: Return an already exists error (#102857)

* Unified Storage: Return an already exists error

When inserting a resource that already exists (i.e. race condition), we can safely catch UNIQUE constraint violations
and transform them into a `k8s.io/apimachinery/pkg/api/errors` error that stands the test of `errors.IsAlreadyExists`.

* feat: clarify existing conflict error

* chore: make update-workspace

* feat: make new package for backend error

* fix: assign dependency owner

* feat: use dialect for checking error type

* chore: go generate

* revert: to 5af369166d
This commit is contained in:
Mariell Hoversholm
2025-03-26 14:44:44 +01:00
committed by GitHub
parent 9f7df8b788
commit f7b9f1ce69
6 changed files with 91 additions and 1 deletions
+1
View File
@@ -480,6 +480,7 @@ func (s *server) Create(ctx context.Context, req *CreateRequest) (*CreateRespons
if found != nil && len(found.Value) > 0 {
rsp.Error = &ErrorResult{
Code: http.StatusConflict,
Reason: string(metav1.StatusReasonAlreadyExists),
Message: "key already exists", // TODO?? soft delete replace?
}
return rsp, nil