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
912e6741
Commit
912e6741
authored
Oct 31, 2016
by
deads2k
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
promote /metrics to genericapiserver
parent
f56cbfa8
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
21 additions
and
15 deletions
+21
-15
BUILD
pkg/genericapiserver/BUILD
+2
-0
config.go
pkg/genericapiserver/config.go
+8
-0
BUILD
pkg/genericapiserver/routes/BUILD
+4
-0
metrics.go
pkg/genericapiserver/routes/metrics.go
+2
-0
master.go
pkg/master/master.go
+3
-11
BUILD
pkg/routes/BUILD
+0
-4
master_utils.go
test/integration/framework/master_utils.go
+2
-0
No files found.
pkg/genericapiserver/BUILD
View file @
912e6741
...
...
@@ -17,6 +17,7 @@ go_library(
"default_storage_factory_builder.go",
"doc.go",
"genericapiserver.go",
"healthz.go",
"hooks.go",
"resource_config.go",
"resource_encoding_config.go",
...
...
@@ -48,6 +49,7 @@ go_library(
"//pkg/genericapiserver/options:go_default_library",
"//pkg/genericapiserver/routes:go_default_library",
"//pkg/genericapiserver/validation:go_default_library",
"//pkg/healthz:go_default_library",
"//pkg/registry/core/service/ipallocator:go_default_library",
"//pkg/registry/generic:go_default_library",
"//pkg/runtime:go_default_library",
...
...
pkg/genericapiserver/config.go
View file @
912e6741
...
...
@@ -81,6 +81,7 @@ type Config struct {
// allow downstream consumers to disable the index route
EnableIndex
bool
EnableProfiling
bool
EnableMetrics
bool
EnableGarbageCollection
bool
Version
*
version
.
Info
...
...
@@ -524,6 +525,13 @@ func (s *GenericAPIServer) installAPI(c *Config) {
if
c
.
EnableProfiling
{
routes
.
Profiling
{}
.
Install
(
s
.
HandlerContainer
)
}
if
c
.
EnableMetrics
{
if
c
.
EnableProfiling
{
routes
.
MetricsWithReset
{}
.
Install
(
s
.
HandlerContainer
)
}
else
{
routes
.
DefaultMetrics
{}
.
Install
(
s
.
HandlerContainer
)
}
}
routes
.
Version
{
Version
:
c
.
Version
}
.
Install
(
s
.
HandlerContainer
)
s
.
HandlerContainer
.
Add
(
s
.
DynamicApisDiscovery
())
}
...
...
pkg/genericapiserver/routes/BUILD
View file @
912e6741
...
...
@@ -15,6 +15,7 @@ go_library(
srcs = [
"doc.go",
"index.go",
"metrics.go",
"openapi.go",
"profiling.go",
"swagger.go",
...
...
@@ -25,15 +26,18 @@ go_library(
deps = [
"//pkg/api/unversioned:go_default_library",
"//pkg/apiserver:go_default_library",
"//pkg/apiserver/metrics:go_default_library",
"//pkg/genericapiserver/mux:go_default_library",
"//pkg/genericapiserver/openapi:go_default_library",
"//pkg/genericapiserver/openapi/common:go_default_library",
"//pkg/genericapiserver/routes/data/swagger:go_default_library",
"//pkg/storage/etcd/metrics:go_default_library",
"//pkg/version:go_default_library",
"//vendor:github.com/elazarl/go-bindata-assetfs",
"//vendor:github.com/emicklei/go-restful",
"//vendor:github.com/emicklei/go-restful/swagger",
"//vendor:github.com/golang/glog",
"//vendor:github.com/prometheus/client_golang/prometheus",
],
)
...
...
pkg/routes/metrics.go
→
pkg/
genericapiserver/
routes/metrics.go
View file @
912e6741
...
...
@@ -30,6 +30,7 @@ import (
// DefaultMetrics installs the default prometheus metrics handler
type
DefaultMetrics
struct
{}
// Install adds the DefaultMetrics handler
func
(
m
DefaultMetrics
)
Install
(
c
*
mux
.
APIContainer
)
{
c
.
NonSwaggerRoutes
.
Handle
(
"/metrics"
,
prometheus
.
Handler
())
}
...
...
@@ -38,6 +39,7 @@ func (m DefaultMetrics) Install(c *mux.APIContainer) {
// which resets the metrics.
type
MetricsWithReset
struct
{}
// Install adds the MetricsWithReset handler
func
(
m
MetricsWithReset
)
Install
(
c
*
mux
.
APIContainer
)
{
defaultMetricsHandler
:=
prometheus
.
Handler
()
.
ServeHTTP
c
.
NonSwaggerRoutes
.
HandleFunc
(
"/metrics"
,
func
(
w
http
.
ResponseWriter
,
req
*
http
.
Request
)
{
...
...
pkg/master/master.go
View file @
912e6741
...
...
@@ -119,6 +119,9 @@ func (c *Config) Complete() completedConfig {
c
.
EndpointReconcilerConfig
.
Reconciler
=
NewMasterCountEndpointReconciler
(
c
.
GenericConfig
.
MasterCount
,
endpointClient
)
}
// this has always been hardcoded true in the past
c
.
GenericConfig
.
EnableMetrics
=
true
return
completedConfig
{
c
}
}
...
...
@@ -195,7 +198,6 @@ func (c completedConfig) New() (*Master, error) {
if
c
.
Tunneler
!=
nil
{
m
.
installTunneler
(
c
.
Tunneler
,
coreclient
.
NewForConfigOrDie
(
c
.
GenericConfig
.
LoopbackClientConfig
)
.
Nodes
())
}
m
.
InstallGeneralEndpoints
(
c
.
Config
)
return
m
,
nil
}
...
...
@@ -227,16 +229,6 @@ func (m *Master) installTunneler(tunneler genericapiserver.Tunneler, nodeClient
},
func
()
float64
{
return
float64
(
tunneler
.
SecondsSinceSync
())
})
}
// TODO this needs to be refactored so we have a way to add general health checks to genericapiserver
// TODO profiling should be generic
func
(
m
*
Master
)
InstallGeneralEndpoints
(
c
*
Config
)
{
if
c
.
GenericConfig
.
EnableProfiling
{
routes
.
MetricsWithReset
{}
.
Install
(
m
.
GenericAPIServer
.
HandlerContainer
)
}
else
{
routes
.
DefaultMetrics
{}
.
Install
(
m
.
GenericAPIServer
.
HandlerContainer
)
}
}
// InstallAPIs will install the APIs for the restStorageProviders if they are enabled.
func
(
m
*
Master
)
InstallAPIs
(
apiResourceConfigSource
genericapiserver
.
APIResourceConfigSource
,
restOptionsGetter
genericapiserver
.
RESTOptionsGetter
,
restStorageProviders
...
genericapiserver
.
RESTStorageProvider
)
{
apiGroupsInfo
:=
[]
genericapiserver
.
APIGroupInfo
{}
...
...
pkg/routes/BUILD
View file @
912e6741
...
...
@@ -15,15 +15,11 @@ go_library(
srcs = [
"doc.go",
"logs.go",
"metrics.go",
"ui.go",
],
tags = ["automanaged"],
deps = [
"//pkg/apiserver/metrics:go_default_library",
"//pkg/genericapiserver/mux:go_default_library",
"//pkg/storage/etcd/metrics:go_default_library",
"//vendor:github.com/emicklei/go-restful",
"//vendor:github.com/prometheus/client_golang/prometheus",
],
)
test/integration/framework/master_utils.go
View file @
912e6741
...
...
@@ -180,6 +180,7 @@ func startMasterOrDie(masterConfig *master.Config, incomingServer *httptest.Serv
if
masterConfig
==
nil
{
masterConfig
=
NewMasterConfig
()
masterConfig
.
GenericConfig
.
EnableProfiling
=
true
masterConfig
.
GenericConfig
.
EnableMetrics
=
true
masterConfig
.
GenericConfig
.
EnableSwaggerSupport
=
true
masterConfig
.
GenericConfig
.
EnableOpenAPISupport
=
true
masterConfig
.
GenericConfig
.
OpenAPIConfig
.
Info
=
&
spec
.
Info
{
...
...
@@ -451,6 +452,7 @@ func RunAMaster(masterConfig *master.Config) (*master.Master, *httptest.Server)
if
masterConfig
==
nil
{
masterConfig
=
NewMasterConfig
()
masterConfig
.
GenericConfig
.
EnableProfiling
=
true
masterConfig
.
GenericConfig
.
EnableMetrics
=
true
}
return
startMasterOrDie
(
masterConfig
,
nil
,
nil
)
}
...
...
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