seal-io / walrus

Walrus is an open-source application management platform based on IaC tools including OpenTofu, Terraform and others. It helps platform engineers build golden paths for developers and empowers developers with self-service capabilities.
Apache License 2.0
428 stars 42 forks source link

Failed to delete a resource that does not match any resource definition rules #1442

Closed Finenyaco closed 10 months ago

Finenyaco commented 10 months ago

Describe the bug

Failed to delete a resource that does not match any resource definition rules

Steps to reproduce

  1. Create a resource definition.
  2. Create a resource doesn't match any resource type.
  3. Delete the resource created in step 2.

Result

  1. Prompts for succeed but the actual deletion failed.
  2. Check walrus logs.
2023-11-16T12:15:58.240Z    E   fail to destroy resource: %!w(*errors.errorString=&{resource definition  does not match resource })
github.com/seal-io/walrus/utils/log.DelegatedLogger.Errorf
    github.com/seal-io/walrus/utils@v0.0.0-00010101000000-000000000000/log/delegate.go:168
github.com/seal-io/walrus/utils/log.Errorf
    github.com/seal-io/walrus/utils@v0.0.0-00010101000000-000000000000/log/logger.go:174
github.com/seal-io/walrus/pkg/resource.Destroy
    github.com/seal-io/walrus/pkg/resource/resource.go:164
github.com/seal-io/walrus/pkg/apis/resource.Handler.CollectionDelete.func1
    github.com/seal-io/walrus/pkg/apis/resource/basic.go:304
github.com/seal-io/walrus/pkg/dao/model.(*Client).WithTx
    github.com/seal-io/walrus/pkg/dao/model/client.go:558
github.com/seal-io/walrus/pkg/apis/resource.Handler.CollectionDelete
    github.com/seal-io/walrus/pkg/apis/resource/basic.go:271
reflect.Value.call
    reflect/value.go:584
reflect.Value.Call
    reflect/value.go:368
github.com/seal-io/walrus/pkg/apis/runtime.(*Router).Routes.func1
    github.com/seal-io/walrus/pkg/apis/runtime/router_route.go:150
github.com/gin-gonic/gin.(*Context).Next
    github.com/gin-gonic/gin@v1.9.1/context.go:174
github.com/seal-io/walrus/pkg/auths.Account.Filter
    github.com/seal-io/walrus/pkg/auths/account.go:56
github.com/gin-gonic/gin.(*Context).Next
    github.com/gin-gonic/gin@v1.9.1/context.go:174
github.com/seal-io/walrus/pkg/apis/runtime.If.func1
    github.com/seal-io/walrus/pkg/apis/runtime/middleware_filter.go:54
github.com/gin-gonic/gin.(*Context).Next
    github.com/gin-gonic/gin@v1.9.1/context.go:174
github.com/seal-io/walrus/pkg/apis/runtime.RequestThrottling.func2
    github.com/seal-io/walrus/pkg/apis/runtime/middleware_flowcontrol.go:86
github.com/gin-gonic/gin.(*Context).Next
    github.com/gin-gonic/gin@v1.9.1/context.go:174
github.com/seal-io/walrus/pkg/apis/runtime.I18n.func1
    github.com/seal-io/walrus/pkg/apis/runtime/middleware_i18n.go:30
github.com/gin-gonic/gin.(*Context).Next
    github.com/gin-gonic/gin@v1.9.1/context.go:174
github.com/seal-io/walrus/pkg/apis/runtime.erroring
    github.com/seal-io/walrus/pkg/apis/runtime/middleware_error.go:20
github.com/gin-gonic/gin.(*Context).Next
    github.com/gin-gonic/gin@v1.9.1/context.go:174
github.com/seal-io/walrus/pkg/apis/runtime.recovering
    github.com/seal-io/walrus/pkg/apis/runtime/middleware_recovery.go:39
github.com/gin-gonic/gin.(*Context).Next
    github.com/gin-gonic/gin@v1.9.1/context.go:174
github.com/seal-io/walrus/pkg/apis/runtime.observing
    github.com/seal-io/walrus/pkg/apis/runtime/middleware_observation.go:89
github.com/gin-gonic/gin.(*Context).Next
    github.com/gin-gonic/gin@v1.9.1/context.go:174
github.com/gin-gonic/gin.(*Engine).handleHTTPRequest
    github.com/gin-gonic/gin@v1.9.1/gin.go:620
github.com/gin-gonic/gin.(*Engine).ServeHTTP
    github.com/gin-gonic/gin@v1.9.1/gin.go:576
github.com/seal-io/walrus/pkg/apis/runtime.(*Router).ServeHTTP
    github.com/seal-io/walrus/pkg/apis/runtime/router.go:191
net/http.serverHandler.ServeHTTP
    net/http/server.go:2947
net/http.initALPNRequest.ServeHTTP
    net/http/server.go:3556
net/http.(*http2serverConn).runHandler
    net/http/h2_bundle.go:5910
2023-11-16T12:15:58.242Z    D   api 202 | HTTP/2.0 |       39 B |        0 B |    6.812471ms |   52.220.111.59 | DELETE  /v1/projects/487397017002180610/environments/487397878596108290/resources?withoutCleanup=false

Expected behavior

Delete successfully.

Environment

Additional context Add any other context about the problem here.

Finenyaco commented 10 months ago

Environment

Test Result: Currently ,each time a resource definition is saved, the UI schema is reset to overwrite the user modifications.

Expected behavior: Retains the user's modifications and update the UI schema if user resets it manually.

shanewxy commented 10 months ago

Environment

Walrus version: v0.4.0-rc2 UI version: v0.4.0-rc2

Test Result: Pass