Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
K
k3s
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jacklull
k3s
Commits
7342b6ce
Commit
7342b6ce
authored
Jun 13, 2014
by
brendandburns
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #100 from lavalamp/fix_panic
Add nice(r) error message on api server panic. Fix nil ptr derefs.
parents
505f01a7
b95eef52
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
16 additions
and
0 deletions
+16
-0
api_server.go
pkg/apiserver/api_server.go
+7
-0
controller_registry.go
pkg/registry/controller_registry.go
+3
-0
service_registry.go
pkg/registry/service_registry.go
+6
-0
No files found.
pkg/apiserver/api_server.go
View file @
7342b6ce
...
@@ -70,6 +70,13 @@ func (server *ApiServer) handleIndex(w http.ResponseWriter) {
...
@@ -70,6 +70,13 @@ func (server *ApiServer) handleIndex(w http.ResponseWriter) {
// HTTP Handler interface
// HTTP Handler interface
func
(
server
*
ApiServer
)
ServeHTTP
(
w
http
.
ResponseWriter
,
req
*
http
.
Request
)
{
func
(
server
*
ApiServer
)
ServeHTTP
(
w
http
.
ResponseWriter
,
req
*
http
.
Request
)
{
defer
func
()
{
if
x
:=
recover
();
x
!=
nil
{
w
.
WriteHeader
(
http
.
StatusInternalServerError
)
fmt
.
Fprint
(
w
,
"apiserver panic. Look in log for details."
)
log
.
Printf
(
"ApiServer panic'd: %#v
\n
"
,
x
)
}
}()
log
.
Printf
(
"%s %s"
,
req
.
Method
,
req
.
RequestURI
)
log
.
Printf
(
"%s %s"
,
req
.
Method
,
req
.
RequestURI
)
url
,
err
:=
url
.
ParseRequestURI
(
req
.
RequestURI
)
url
,
err
:=
url
.
ParseRequestURI
(
req
.
RequestURI
)
if
err
!=
nil
{
if
err
!=
nil
{
...
...
pkg/registry/controller_registry.go
View file @
7342b6ce
...
@@ -49,6 +49,9 @@ func (storage *ControllerRegistryStorage) List(*url.URL) (interface{}, error) {
...
@@ -49,6 +49,9 @@ func (storage *ControllerRegistryStorage) List(*url.URL) (interface{}, error) {
func
(
storage
*
ControllerRegistryStorage
)
Get
(
id
string
)
(
interface
{},
error
)
{
func
(
storage
*
ControllerRegistryStorage
)
Get
(
id
string
)
(
interface
{},
error
)
{
controller
,
err
:=
storage
.
registry
.
GetController
(
id
)
controller
,
err
:=
storage
.
registry
.
GetController
(
id
)
if
err
!=
nil
{
return
nil
,
err
}
controller
.
Kind
=
"cluster#replicationController"
controller
.
Kind
=
"cluster#replicationController"
return
controller
,
err
return
controller
,
err
}
}
...
...
pkg/registry/service_registry.go
View file @
7342b6ce
...
@@ -61,12 +61,18 @@ func GetServiceEnvironmentVariables(registry ServiceRegistry, machine string) ([
...
@@ -61,12 +61,18 @@ func GetServiceEnvironmentVariables(registry ServiceRegistry, machine string) ([
func
(
sr
*
ServiceRegistryStorage
)
List
(
*
url
.
URL
)
(
interface
{},
error
)
{
func
(
sr
*
ServiceRegistryStorage
)
List
(
*
url
.
URL
)
(
interface
{},
error
)
{
list
,
err
:=
sr
.
registry
.
ListServices
()
list
,
err
:=
sr
.
registry
.
ListServices
()
if
err
!=
nil
{
return
nil
,
err
}
list
.
Kind
=
"cluster#serviceList"
list
.
Kind
=
"cluster#serviceList"
return
list
,
err
return
list
,
err
}
}
func
(
sr
*
ServiceRegistryStorage
)
Get
(
id
string
)
(
interface
{},
error
)
{
func
(
sr
*
ServiceRegistryStorage
)
Get
(
id
string
)
(
interface
{},
error
)
{
service
,
err
:=
sr
.
registry
.
GetService
(
id
)
service
,
err
:=
sr
.
registry
.
GetService
(
id
)
if
err
!=
nil
{
return
nil
,
err
}
service
.
Kind
=
"cluster#service"
service
.
Kind
=
"cluster#service"
return
service
,
err
return
service
,
err
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment