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
375e2d03
Commit
375e2d03
authored
Nov 13, 2017
by
Joe Betz
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove is_system_ns from admission metrics
parent
2643c6ae
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
10 additions
and
24 deletions
+10
-24
BUILD
staging/src/k8s.io/apiserver/pkg/admission/BUILD
+0
-1
chain_test.go
staging/src/k8s.io/apiserver/pkg/admission/chain_test.go
+2
-5
metrics.go
staging/src/k8s.io/apiserver/pkg/admission/metrics.go
+7
-14
metrics_test.go
staging/src/k8s.io/apiserver/pkg/admission/metrics_test.go
+1
-4
No files found.
staging/src/k8s.io/apiserver/pkg/admission/BUILD
View file @
375e2d03
...
...
@@ -51,7 +51,6 @@ go_library(
"//vendor/k8s.io/apimachinery/pkg/api/meta:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/apimachinery/announced:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/apimachinery/registered:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/runtime:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/runtime/schema:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/runtime/serializer:go_default_library",
...
...
staging/src/k8s.io/apiserver/pkg/admission/chain_test.go
View file @
375e2d03
...
...
@@ -17,7 +17,6 @@ limitations under the License.
package
admission
import
(
"strconv"
"testing"
metav1
"k8s.io/apimachinery/pkg/apis/meta/v1"
...
...
@@ -109,8 +108,7 @@ func TestAdmitAndValidate(t *testing.T) {
}
labelFilter
:=
map
[
string
]
string
{
"is_system_ns"
:
strconv
.
FormatBool
(
test
.
ns
==
sysns
),
"type"
:
"mutating"
,
"type"
:
"mutating"
,
}
checkAdmitAndValidateMetrics
(
t
,
labelFilter
,
test
.
accept
,
test
.
calls
)
...
...
@@ -136,8 +134,7 @@ func TestAdmitAndValidate(t *testing.T) {
}
labelFilter
=
map
[
string
]
string
{
"is_system_ns"
:
strconv
.
FormatBool
(
test
.
ns
==
sysns
),
"type"
:
"validating"
,
"type"
:
"validating"
,
}
checkAdmitAndValidateMetrics
(
t
,
labelFilter
,
test
.
accept
,
test
.
calls
)
...
...
staging/src/k8s.io/apiserver/pkg/admission/metrics.go
View file @
375e2d03
...
...
@@ -24,8 +24,6 @@ import (
"k8s.io/api/admissionregistration/v1alpha1"
"github.com/prometheus/client_golang/prometheus"
metav1
"k8s.io/apimachinery/pkg/apis/meta/v1"
)
const
(
...
...
@@ -59,17 +57,17 @@ func newAdmissionMetrics() *AdmissionMetrics {
// Admission metrics for a step of the admission flow. The entire admission flow is broken down into a series of steps
// Each step is identified by a distinct type label value.
step
:=
newMetricSet
(
"step"
,
[]
string
{
"type"
,
"operation"
,
"group"
,
"version"
,
"resource"
,
"subresource"
,
"
is_system_ns"
,
"
rejected"
},
[]
string
{
"type"
,
"operation"
,
"group"
,
"version"
,
"resource"
,
"subresource"
,
"rejected"
},
"Admission sub-step %s, broken out for each operation and API resource and step type (validating or mutating)."
)
// Built-in admission controller metrics. Each admission controller is identified by name.
controller
:=
newMetricSet
(
"controller"
,
[]
string
{
"name"
,
"type"
,
"operation"
,
"group"
,
"version"
,
"resource"
,
"subresource"
,
"
is_system_ns"
,
"
rejected"
},
[]
string
{
"name"
,
"type"
,
"operation"
,
"group"
,
"version"
,
"resource"
,
"subresource"
,
"rejected"
},
"Admission controller %s, identified by name and broken out for each operation and API resource and type (validating or mutating)."
)
// External admission webhook metrics. Each webhook is identified by name.
externalWebhook
:=
newMetricSet
(
"external_webhook"
,
[]
string
{
"name"
,
"type"
,
"operation"
,
"group"
,
"version"
,
"resource"
,
"subresource"
,
"
is_system_ns"
,
"
rejected"
},
[]
string
{
"name"
,
"type"
,
"operation"
,
"group"
,
"version"
,
"resource"
,
"subresource"
,
"rejected"
},
"External admission webhook %s, identified by name and broken out for each operation and API resource and type (validating or mutating)."
)
step
.
mustRegister
()
...
...
@@ -87,25 +85,20 @@ func (m *AdmissionMetrics) reset() {
// ObserveAdmissionStep records admission related metrics for a admission step, identified by step type.
func
(
m
*
AdmissionMetrics
)
ObserveAdmissionStep
(
elapsed
time
.
Duration
,
rejected
bool
,
attr
Attributes
,
stepType
string
)
{
gvr
:=
attr
.
GetResource
()
m
.
step
.
observe
(
elapsed
,
stepType
,
string
(
attr
.
GetOperation
()),
gvr
.
Group
,
gvr
.
Version
,
gvr
.
Resource
,
attr
.
GetSubresource
(),
isSystemNsLabel
(
attr
),
strconv
.
FormatBool
(
rejected
))
m
.
step
.
observe
(
elapsed
,
stepType
,
string
(
attr
.
GetOperation
()),
gvr
.
Group
,
gvr
.
Version
,
gvr
.
Resource
,
attr
.
GetSubresource
(),
strconv
.
FormatBool
(
rejected
))
}
// ObserveAdmissionController records admission related metrics for a built-in admission controller, identified by it's plugin handler name.
func
(
m
*
AdmissionMetrics
)
ObserveAdmissionController
(
elapsed
time
.
Duration
,
rejected
bool
,
handler
NamedHandler
,
attr
Attributes
,
stepType
string
)
{
gvr
:=
attr
.
GetResource
()
m
.
controller
.
observe
(
elapsed
,
handler
.
Name
(),
stepType
,
string
(
attr
.
GetOperation
()),
gvr
.
Group
,
gvr
.
Version
,
gvr
.
Resource
,
attr
.
GetSubresource
(),
isSystemNsLabel
(
attr
),
strconv
.
FormatBool
(
rejected
))
m
.
controller
.
observe
(
elapsed
,
handler
.
Name
(),
stepType
,
string
(
attr
.
GetOperation
()),
gvr
.
Group
,
gvr
.
Version
,
gvr
.
Resource
,
attr
.
GetSubresource
(),
strconv
.
FormatBool
(
rejected
))
}
// ObserveExternalWebhook records admission related metrics for a external admission webhook.
func
(
m
*
AdmissionMetrics
)
ObserveExternalWebhook
(
elapsed
time
.
Duration
,
rejected
bool
,
hook
*
v1alpha1
.
ExternalAdmissionH
ook
,
attr
Attributes
)
{
func
(
m
*
AdmissionMetrics
)
ObserveExternalWebhook
(
elapsed
time
.
Duration
,
rejected
bool
,
hook
*
v1alpha1
.
Webh
ook
,
attr
Attributes
)
{
t
:=
"validating"
// TODO: pass in type (validating|mutating) once mutating webhook functionality has been implemented
gvr
:=
attr
.
GetResource
()
m
.
externalWebhook
.
observe
(
elapsed
,
hook
.
Name
,
t
,
string
(
attr
.
GetOperation
()),
gvr
.
Group
,
gvr
.
Version
,
gvr
.
Resource
,
attr
.
GetSubresource
(),
isSystemNsLabel
(
attr
),
strconv
.
FormatBool
(
rejected
))
}
// isSystemNsLabel returns the value to use for the `is_system_ns` metric label.
func
isSystemNsLabel
(
a
Attributes
)
string
{
return
strconv
.
FormatBool
(
a
.
GetNamespace
()
==
metav1
.
NamespaceSystem
)
m
.
externalWebhook
.
observe
(
elapsed
,
hook
.
Name
,
t
,
string
(
attr
.
GetOperation
()),
gvr
.
Group
,
gvr
.
Version
,
gvr
.
Resource
,
attr
.
GetSubresource
(),
strconv
.
FormatBool
(
rejected
))
}
type
metricSet
struct
{
...
...
staging/src/k8s.io/apiserver/pkg/admission/metrics_test.go
View file @
375e2d03
...
...
@@ -41,7 +41,6 @@ func TestObserveAdmissionStep(t *testing.T) {
"resource"
:
resource
.
Resource
,
"subresource"
:
"subresource"
,
"type"
:
"mutating"
,
"isSystemNs"
:
"false"
,
"rejected"
:
"false"
,
}
expectHistogramCountTotal
(
t
,
"apiserver_admission_step_latencies"
,
wantLabels
,
1
)
...
...
@@ -60,7 +59,6 @@ func TestObserveAdmissionController(t *testing.T) {
"resource"
:
resource
.
Resource
,
"subresource"
:
"subresource"
,
"type"
:
"validating"
,
"isSystemNs"
:
"false"
,
"rejected"
:
"false"
,
}
expectHistogramCountTotal
(
t
,
"apiserver_admission_controller_latencies"
,
wantLabels
,
1
)
...
...
@@ -69,7 +67,7 @@ func TestObserveAdmissionController(t *testing.T) {
func
TestObserveExternalWebhook
(
t
*
testing
.
T
)
{
Metrics
.
reset
()
hook
:=
&
v1alpha1
.
ExternalAdmissionH
ook
{
Name
:
"x"
}
hook
:=
&
v1alpha1
.
Webh
ook
{
Name
:
"x"
}
Metrics
.
ObserveExternalWebhook
(
2
*
time
.
Second
,
false
,
hook
,
attr
)
wantLabels
:=
map
[
string
]
string
{
"name"
:
"x"
,
...
...
@@ -79,7 +77,6 @@ func TestObserveExternalWebhook(t *testing.T) {
"resource"
:
resource
.
Resource
,
"subresource"
:
"subresource"
,
"type"
:
"validating"
,
"isSystemNs"
:
"false"
,
"rejected"
:
"false"
,
}
expectHistogramCountTotal
(
t
,
"apiserver_admission_external_webhook_latencies"
,
wantLabels
,
1
)
...
...
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