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
427 stars 48 forks source link

Failed to create resource by importing a yaml file when run Walrus by Kubernetes: unexpected status code 500 #2030

Closed Finenyaco closed 9 months ago

Finenyaco commented 9 months ago

Describe the bug

Steps to reproduce

  1. Run Walrus by Kubernetes.
  2. Create a resource by importing a yaml file

Result

  1. Failed to create resource: failed to apply walrus file: unexpected status code 500,
image
2024-01-25T08:10:07.464Z    E   api error requesting POST /v1/projects/497651653571248146/environments/497651653588025362/apply: 1 error occurred:
    * failed to apply walrus file: unexpected status code 500,

github.com/seal-io/walrus/pkg/apis/runtime.erroring
    github.com/seal-io/walrus/pkg/apis/runtime/middleware_error.go:45
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:194
net/http.serverHandler.ServeHTTP
    net/http/server.go:2938
net/http.(*conn).serve
    net/http/server.go:2009
2024-01-25T08:10:07.465Z    D   api 500 | HTTP/1.1 |      419 B |      121 B |   11.579407ms |   52.220.111.59 | POST    /v1/projects/497651653571248146/environments/497651653588025362/apply

Expected behavior

Environment

Additional context Add any other context about the problem here.

Finenyaco commented 9 months ago

Panic when creating resource.

2024-01-25T08:16:54.992Z    E   api panic observing: runtime error: invalid memory address or nil pointer dereference, callstack:
runtime.panicmem
    runtime/panic.go:261 (0x452917)
runtime.sigpanic
    runtime/signal_unix.go:861 (0x4528e5)
github.com/seal-io/walrus/pkg/templates/openapi.GenSchemaDefaultWithAttribute
    github.com/seal-io/walrus/pkg/templates/openapi/default.go:185 (0xfed6f1)
github.com/seal-io/walrus/pkg/resource.computedAttributeWithResourceDefinition
    github.com/seal-io/walrus/pkg/resource/computed_attributes.go:202 (0x594e6ea)
github.com/seal-io/walrus/pkg/resource.GenComputedAttributes
    github.com/seal-io/walrus/pkg/resource/computed_attributes.go:106 (0x594d48a)
github.com/seal-io/walrus/pkg/apis/resource.ValidateCreateInput
    github.com/seal-io/walrus/pkg/apis/resource/basic_view.go:637 (0x5ae7104)
github.com/seal-io/walrus/pkg/apis/resource.(*CreateRequest).Validate
    github.com/seal-io/walrus/pkg/apis/resource/basic_view.go:46 (0x5ae13f4)
github.com/seal-io/walrus/pkg/apis/runtime.(*Router).Routes.func1
    github.com/seal-io/walrus/pkg/apis/runtime/router_route.go:124 (0x59141c5)
github.com/gin-gonic/gin.(*Context).Next
    github.com/gin-gonic/gin@v1.9.1/context.go:174 (0x5933005)
github.com/seal-io/walrus/pkg/auths.Account.Filter
    github.com/seal-io/walrus/pkg/auths/account.go:56 (0x5932ff3)
github.com/gin-gonic/gin.(*Context).Next
    github.com/gin-gonic/gin@v1.9.1/context.go:174 (0x15a874a)
github.com/seal-io/walrus/pkg/apis.(*Server).Setup.If.func5
    github.com/seal-io/walrus/pkg/apis/runtime/middleware_filter.go:54 (0x5fec7aa)
github.com/gin-gonic/gin.(*Context).Next
    github.com/gin-gonic/gin@v1.9.1/context.go:174 (0x15a874a)
github.com/seal-io/walrus/pkg/apis.(*Server).Setup.RequestThrottling.func3
    github.com/seal-io/walrus/pkg/apis/runtime/middleware_flowcontrol.go:86 (0x5fecbe4)
github.com/gin-gonic/gin.(*Context).Next
    github.com/gin-gonic/gin@v1.9.1/context.go:174 (0x15a874a)
github.com/seal-io/walrus/pkg/apis.(*Server).Setup.I18n.func6
    github.com/seal-io/walrus/pkg/apis/runtime/middleware_i18n.go:30 (0x5fee064)
github.com/gin-gonic/gin.(*Context).Next
    github.com/gin-gonic/gin@v1.9.1/context.go:174 (0x590d0fd)
github.com/seal-io/walrus/pkg/apis/runtime.erroring
    github.com/seal-io/walrus/pkg/apis/runtime/middleware_error.go:20 (0x590d0eb)
github.com/gin-gonic/gin.(*Context).Next
    github.com/gin-gonic/gin@v1.9.1/context.go:174 (0x590fc01)
github.com/seal-io/walrus/pkg/apis/runtime.recovering
    github.com/seal-io/walrus/pkg/apis/runtime/middleware_recovery.go:39 (0x590fbef)
github.com/gin-gonic/gin.(*Context).Next
    github.com/gin-gonic/gin@v1.9.1/context.go:174 (0x590ef7b)
github.com/seal-io/walrus/pkg/apis/runtime.observing
    github.com/seal-io/walrus/pkg/apis/runtime/middleware_observation.go:89 (0x590ef62)
github.com/gin-gonic/gin.(*Context).Next
    github.com/gin-gonic/gin@v1.9.1/context.go:174 (0x15b365a)
github.com/gin-gonic/gin.(*Engine).handleHTTPRequest
    github.com/gin-gonic/gin@v1.9.1/gin.go:620 (0x15b32ed)
github.com/gin-gonic/gin.(*Engine).ServeHTTP
    github.com/gin-gonic/gin@v1.9.1/gin.go:576 (0x15b2e1c)
github.com/seal-io/walrus/pkg/apis/runtime.(*Router).ServeHTTP
    github.com/seal-io/walrus/pkg/apis/runtime/router.go:194 (0x5912c24)
net/http.serverHandler.ServeHTTP
    net/http/server.go:2938 (0x79958d)
net/http.(*conn).serve
    net/http/server.go:2009 (0x795473)
runtime.goexit
    runtime/asm_amd64.s:1650 (0x471d80)

github.com/seal-io/walrus/pkg/apis/runtime.recovering.func1
    github.com/seal-io/walrus/pkg/apis/runtime/middleware_recovery.go:26
runtime.gopanic
    runtime/panic.go:914
runtime.panicmem
    runtime/panic.go:261
runtime.sigpanic
    runtime/signal_unix.go:861
github.com/seal-io/walrus/pkg/templates/openapi.GenSchemaDefaultWithAttribute
    github.com/seal-io/walrus/pkg/templates/openapi/default.go:185
github.com/seal-io/walrus/pkg/resource.computedAttributeWithResourceDefinition
    github.com/seal-io/walrus/pkg/resource/computed_attributes.go:202
github.com/seal-io/walrus/pkg/resource.GenComputedAttributes
    github.com/seal-io/walrus/pkg/resource/computed_attributes.go:106
github.com/seal-io/walrus/pkg/apis/resource.ValidateCreateInput
    github.com/seal-io/walrus/pkg/apis/resource/basic_view.go:637
github.com/seal-io/walrus/pkg/apis/resource.(*CreateRequest).Validate
    github.com/seal-io/walrus/pkg/apis/resource/basic_view.go:46
github.com/seal-io/walrus/pkg/apis/runtime.(*Router).Routes.func1
    github.com/seal-io/walrus/pkg/apis/runtime/router_route.go:124
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.(*Server).Setup.If.func5
    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.(*Server).Setup.RequestThrottling.func3
    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.(*Server).Setup.I18n.func6
    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:194
net/http.serverHandler.ServeHTTP
    net/http/server.go:2938
net/http.(*conn).serve
    net/http/server.go:2009
2024-01-25T08:16:54.992Z    D   api 500 | HTTP/1.1 |      264 B |        0 B |   13.948752ms |   52.220.111.59 | POST    /v1/projects/497651653571248146/environments/497651653588025362/resources
Finenyaco commented 9 months ago

Steps to reproduce

  1. Delete the 'Components' of 'kuberntes-containerservice' template in UI schema.
image
  1. Using the 'containerservice' type to create a resource. A panic occurs
  2. Importing a yaml file that using the 'containerservice' type will return an error.
Finenyaco commented 9 months ago

Environment

Test Result: pass

The deployment will be failed and no panic.

image