Merge pull request #4866 from wenchajun/gpu
Fix gpu null pointer exception
This commit is contained in:
@@ -20,6 +20,8 @@ import (
|
||||
"github.com/emicklei/go-restful"
|
||||
"k8s.io/apimachinery/pkg/runtime/schema"
|
||||
|
||||
"kubesphere.io/kubesphere/pkg/simple/client/gpu"
|
||||
|
||||
kubesphereconfig "kubesphere.io/kubesphere/pkg/apiserver/config"
|
||||
"kubesphere.io/kubesphere/pkg/apiserver/runtime"
|
||||
)
|
||||
@@ -48,7 +50,11 @@ func AddToContainer(c *restful.Container, config *kubesphereconfig.Config) error
|
||||
webservice.Route(webservice.GET("/configs/gpu/kinds").
|
||||
Doc("Get all supported GPU kinds.").
|
||||
To(func(request *restful.Request, response *restful.Response) {
|
||||
response.WriteAsJson(config.GPUOptions.Kinds)
|
||||
var kinds []gpu.GPUKind
|
||||
if config.GPUOptions != nil {
|
||||
kinds = config.GPUOptions.Kinds
|
||||
}
|
||||
response.WriteAsJson(kinds)
|
||||
}))
|
||||
|
||||
c.Add(webservice)
|
||||
|
||||
@@ -24,7 +24,7 @@ func (s *Options) Validate() []error {
|
||||
}
|
||||
|
||||
func (s *Options) ApplyTo(options *Options) {
|
||||
if len(s.Kinds) > 0 {
|
||||
if s != nil && len(s.Kinds) > 0 {
|
||||
options.Kinds = s.Kinds
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user