redhat-developer / odo

odo - Developer-focused CLI for fast & iterative container-based application development on Podman and Kubernetes. Implementation of the open Devfile standard.
https://odo.dev
Apache License 2.0
788 stars 243 forks source link

API Server panics when Devfile Volume component has no `ephemeral` field set #7079

Closed rm3l closed 1 year ago

rm3l commented 1 year ago

/kind bug /area dev /area Web-UI

What versions of software are you using?

Operating System: Fedora 38, kernel 6.4.14-200.fc38.x86_64

Output of odo version:

odo v3.14.0 (56b868d16)

How did you run odo exactly?

odo init \
  --name java-wildfly \
  --devfile java-wildfly-bootable-jar \
  --devfile-registry DefaultDevfileRegistry \
  --starter microprofile-config

odo dev

Navigate to the Web UI.

Actual behavior

Web UI is not able to load the Devfile: image

And looking at the odo dev logs, we can see the following stacktrace:

2023/09/08 11:19:07 http: panic serving 127.0.0.1:52286: runtime error: invalid memory address or nil pointer dereference                                                                      
goroutine 118 [running]:                                                                       
net/http.(*conn).serve.func1()                                                                 
        /home/asoro/.asdf/installs/golang/1.19.6/go/src/net/http/server.go:1850 +0xbf                                                                                                          
panic({0x3159380, 0x5b84b40})                                                                                                                                                                  
        /home/asoro/.asdf/installs/golang/1.19.6/go/src/runtime/panic.go:890 +0x262                                                                                                            
github.com/redhat-developer/odo/pkg/apiserver-impl/devstate.(*DevfileState).getVolumes(0xc00057e150?)
        /home/asoro/work/projects/odo/pkg/apiserver-impl/devstate/content.go:322 +0x17d                                                                                                        
github.com/redhat-developer/odo/pkg/apiserver-impl/devstate.(*DevfileState).GetContent(_)                                                                                                      
        /home/asoro/work/projects/odo/pkg/apiserver-impl/devstate/content.go:50 +0x1f3
github.com/redhat-developer/odo/pkg/apiserver-impl/devstate.(*DevfileState).SetDevfileContent(_, {_, _})
        /home/asoro/work/projects/odo/pkg/apiserver-impl/devstate/state.go:46 +0x35a                                                                                                           
github.com/redhat-developer/odo/pkg/apiserver-impl.(*DevstateApiService).DevstateDevfilePut(0xc000d80000?, {0x2f55ee0?, 0xc000ccd370?}, {{0xc000d80000?, 0x8?}})
        /home/asoro/work/projects/odo/pkg/apiserver-impl/devstate.go:274 +0x69
github.com/redhat-developer/odo/pkg/apiserver-gen/go.(*DevstateApiController).DevstateDevfilePut(0xc000c090f8, {0x47b6990, 0xc0009c41c0}, 0xc00015e500)
        /home/asoro/work/projects/odo/pkg/apiserver-gen/go/api_devstate.go:529 +0x1be
net/http.HandlerFunc.ServeHTTP(0x7f91a8eb8108?, {0x47b6990?, 0xc0009c41c0?}, 0x0?)
        /home/asoro/.asdf/installs/golang/1.19.6/go/src/net/http/server.go:2109 +0x2f
github.com/redhat-developer/odo/pkg/apiserver-gen/go.Logger.func1({0x47b6990, 0xc0009c41c0}, 0xc00015e500)
        /home/asoro/work/projects/odo/pkg/apiserver-gen/go/logger.go:23 +0x9e
net/http.HandlerFunc.ServeHTTP(0xc0001b7e00?, {0x47b6990?, 0xc0009c41c0?}, 0xc0004d19e0?)
        /home/asoro/.asdf/installs/golang/1.19.6/go/src/net/http/server.go:2109 +0x2f
github.com/gorilla/mux.(*Router).ServeHTTP(0xc00041afc0, {0x47b6990, 0xc0009c41c0}, 0xc0009fe700)
        /home/asoro/work/projects/odo/vendor/github.com/gorilla/mux/mux.go:210 +0x1cf
net/http.serverHandler.ServeHTTP({0x47a3af0?}, {0x47b6990, 0xc0009c41c0}, 0xc0009fe700)
        /home/asoro/.asdf/installs/golang/1.19.6/go/src/net/http/server.go:2947 +0x30c
net/http.(*conn).serve(0xc000907b80, {0x47b86f8, 0xc000b16120})
        /home/asoro/.asdf/installs/golang/1.19.6/go/src/net/http/server.go:1991 +0x607
created by net/http.(*Server).Serve
        /home/asoro/.asdf/installs/golang/1.19.6/go/src/net/http/server.go:3102 +0x4db

Expected behavior

No panic ;-) And users should be able to use the Web UI against this Devfile.

Any logs, error output, etc?