diff --git a/api/openapi-spec/swagger.json b/api/openapi-spec/swagger.json index ad25f0ab8db..bc168932b42 100644 --- a/api/openapi-spec/swagger.json +++ b/api/openapi-spec/swagger.json @@ -3055,6 +3055,104 @@ }, "type": "object" }, + "io.k8s.api.authentication.v1.BoundObjectReference": { + "description": "BoundObjectReference is a reference to an object that a token is bound to.", + "properties": { + "apiVersion": { + "description": "API version of the referent.", + "type": "string" + }, + "kind": { + "description": "Kind of the referent. Valid kinds are 'Pod' and 'Secret'.", + "type": "string" + }, + "name": { + "description": "Name of the referent.", + "type": "string" + }, + "uid": { + "description": "UID of the referent.", + "type": "string" + } + }, + "type": "object" + }, + "io.k8s.api.authentication.v1.TokenRequest": { + "description": "TokenRequest requests a token for a given service account.", + "properties": { + "apiVersion": { + "description": "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#resources", + "type": "string" + }, + "kind": { + "description": "Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#types-kinds", + "type": "string" + }, + "metadata": { + "$ref": "#/definitions/io.k8s.apimachinery.pkg.apis.meta.v1.ObjectMeta" + }, + "spec": { + "$ref": "#/definitions/io.k8s.api.authentication.v1.TokenRequestSpec" + }, + "status": { + "$ref": "#/definitions/io.k8s.api.authentication.v1.TokenRequestStatus" + } + }, + "required": [ + "spec" + ], + "type": "object", + "x-kubernetes-group-version-kind": [ + { + "group": "authentication.k8s.io", + "kind": "TokenRequest", + "version": "v1" + } + ] + }, + "io.k8s.api.authentication.v1.TokenRequestSpec": { + "description": "TokenRequestSpec contains client provided parameters of a token request.", + "properties": { + "audiences": { + "description": "Audiences are the intendend audiences of the token. A recipient of a token must identitfy themself with an identifier in the list of audiences of the token, and otherwise should reject the token. A token issued for multiple audiences may be used to authenticate against any of the audiences listed but implies a high degree of trust between the target audiences.", + "items": { + "type": "string" + }, + "type": "array" + }, + "boundObjectRef": { + "$ref": "#/definitions/io.k8s.api.authentication.v1.BoundObjectReference", + "description": "BoundObjectRef is a reference to an object that the token will be bound to. The token will only be valid for as long as the bound object exists. NOTE: The API server's TokenReview endpoint will validate the BoundObjectRef, but other audiences may not. Keep ExpirationSeconds small if you want prompt revocation." + }, + "expirationSeconds": { + "description": "ExpirationSeconds is the requested duration of validity of the request. The token issuer may return a token with a different validity duration so a client needs to check the 'expiration' field in a response.", + "format": "int64", + "type": "integer" + } + }, + "required": [ + "audiences" + ], + "type": "object" + }, + "io.k8s.api.authentication.v1.TokenRequestStatus": { + "description": "TokenRequestStatus is the result of a token request.", + "properties": { + "expirationTimestamp": { + "$ref": "#/definitions/io.k8s.apimachinery.pkg.apis.meta.v1.Time", + "description": "ExpirationTimestamp is the time of expiration of the returned token." + }, + "token": { + "description": "Token is the opaque bearer token.", + "type": "string" + } + }, + "required": [ + "token", + "expirationTimestamp" + ], + "type": "object" + }, "io.k8s.api.authentication.v1.TokenReview": { "description": "TokenReview attempts to authenticate a token to a known user. Note: TokenReview requests may be cached by the webhook token authenticator plugin in the kube-apiserver.", "properties": { @@ -19434,7 +19532,7 @@ }, "info": { "title": "Arktos", - "version": "v0.2" + "version": "v0.7.0" }, "paths": { "/api/": { @@ -31531,6 +31629,104 @@ } } }, + "/api/v1/namespaces/{namespace}/serviceaccounts/{name}/token": { + "parameters": [ + { + "description": "When present, indicates that modifications should not be persisted. An invalid or unrecognized dryRun directive will result in an error response and no further processing of the request. Valid values are: - All: all dry run stages will be processed", + "in": "query", + "name": "dryRun", + "type": "string", + "uniqueItems": true + }, + { + "description": "fieldManager is a name associated with the actor or entity that is making these changes. The value must be less than or 128 characters long, and only contain printable characters, as defined by https://golang.org/pkg/unicode/#IsPrint.", + "in": "query", + "name": "fieldManager", + "type": "string", + "uniqueItems": true + }, + { + "description": "name of the TokenRequest", + "in": "path", + "name": "name", + "required": true, + "type": "string", + "uniqueItems": true + }, + { + "description": "object name and auth scope, such as for teams and projects", + "in": "path", + "name": "namespace", + "required": true, + "type": "string", + "uniqueItems": true + }, + { + "description": "If 'true', then the output is pretty printed.", + "in": "query", + "name": "pretty", + "type": "string", + "uniqueItems": true + } + ], + "post": { + "consumes": [ + "*/*" + ], + "description": "create token of a ServiceAccount", + "operationId": "createCoreV1LegacyNamespacedServiceAccountToken", + "parameters": [ + { + "in": "body", + "name": "body", + "required": true, + "schema": { + "$ref": "#/definitions/io.k8s.api.authentication.v1.TokenRequest" + } + } + ], + "produces": [ + "application/json", + "application/yaml", + "application/vnd.kubernetes.protobuf" + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/io.k8s.api.authentication.v1.TokenRequest" + } + }, + "201": { + "description": "Created", + "schema": { + "$ref": "#/definitions/io.k8s.api.authentication.v1.TokenRequest" + } + }, + "202": { + "description": "Accepted", + "schema": { + "$ref": "#/definitions/io.k8s.api.authentication.v1.TokenRequest" + } + }, + "401": { + "description": "Unauthorized" + } + }, + "schemes": [ + "https" + ], + "tags": [ + "core_v1" + ], + "x-kubernetes-action": "post", + "x-kubernetes-group-version-kind": { + "group": "authentication.k8s.io", + "kind": "TokenRequest", + "version": "v1" + } + } + }, "/api/v1/namespaces/{namespace}/services": { "get": { "consumes": [ @@ -48620,6 +48816,112 @@ } } }, + "/api/v1/tenants/{tenant}/namespaces/{namespace}/serviceaccounts/{name}/token": { + "parameters": [ + { + "description": "When present, indicates that modifications should not be persisted. An invalid or unrecognized dryRun directive will result in an error response and no further processing of the request. Valid values are: - All: all dry run stages will be processed", + "in": "query", + "name": "dryRun", + "type": "string", + "uniqueItems": true + }, + { + "description": "fieldManager is a name associated with the actor or entity that is making these changes. The value must be less than or 128 characters long, and only contain printable characters, as defined by https://golang.org/pkg/unicode/#IsPrint.", + "in": "query", + "name": "fieldManager", + "type": "string", + "uniqueItems": true + }, + { + "description": "name of the TokenRequest", + "in": "path", + "name": "name", + "required": true, + "type": "string", + "uniqueItems": true + }, + { + "description": "object name and auth scope, such as for teams and projects", + "in": "path", + "name": "namespace", + "required": true, + "type": "string", + "uniqueItems": true + }, + { + "description": "If 'true', then the output is pretty printed.", + "in": "query", + "name": "pretty", + "type": "string", + "uniqueItems": true + }, + { + "description": "object name and auth scope, for different end users", + "in": "path", + "name": "tenant", + "required": true, + "type": "string", + "uniqueItems": true + } + ], + "post": { + "consumes": [ + "*/*" + ], + "description": "create token of a ServiceAccount", + "operationId": "createCoreV1NamespacedServiceAccountToken", + "parameters": [ + { + "in": "body", + "name": "body", + "required": true, + "schema": { + "$ref": "#/definitions/io.k8s.api.authentication.v1.TokenRequest" + } + } + ], + "produces": [ + "application/json", + "application/yaml", + "application/vnd.kubernetes.protobuf" + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/io.k8s.api.authentication.v1.TokenRequest" + } + }, + "201": { + "description": "Created", + "schema": { + "$ref": "#/definitions/io.k8s.api.authentication.v1.TokenRequest" + } + }, + "202": { + "description": "Accepted", + "schema": { + "$ref": "#/definitions/io.k8s.api.authentication.v1.TokenRequest" + } + }, + "401": { + "description": "Unauthorized" + } + }, + "schemes": [ + "https" + ], + "tags": [ + "core_v1" + ], + "x-kubernetes-action": "post", + "x-kubernetes-group-version-kind": { + "group": "authentication.k8s.io", + "kind": "TokenRequest", + "version": "v1" + } + } + }, "/api/v1/tenants/{tenant}/namespaces/{namespace}/services": { "get": { "consumes": [ diff --git a/cmd/cloud-controller-manager/BUILD b/cmd/cloud-controller-manager/BUILD index 29a29722b18..cc25f935b33 100644 --- a/cmd/cloud-controller-manager/BUILD +++ b/cmd/cloud-controller-manager/BUILD @@ -21,9 +21,8 @@ go_library( deps = [ "//cmd/cloud-controller-manager/app:go_default_library", "//pkg/cloudprovider/providers:go_default_library", - "//pkg/util/prometheusclientgo:go_default_library", - "//pkg/version/prometheus:go_default_library", "//staging/src/k8s.io/component-base/logs:go_default_library", + "//staging/src/k8s.io/component-base/metrics/prometheus/clientgo:go_default_library", ], ) diff --git a/cmd/cloud-controller-manager/app/BUILD b/cmd/cloud-controller-manager/app/BUILD index 4d215ba845a..4b7c5e64a6f 100644 --- a/cmd/cloud-controller-manager/app/BUILD +++ b/cmd/cloud-controller-manager/app/BUILD @@ -17,7 +17,6 @@ go_library( "//pkg/controller/service:go_default_library", "//pkg/util/configz:go_default_library", "//pkg/util/flag:go_default_library", - "//pkg/version:go_default_library", "//pkg/version/verflag:go_default_library", "//staging/src/k8s.io/apimachinery/pkg/util/sets:go_default_library", "//staging/src/k8s.io/apimachinery/pkg/util/uuid:go_default_library", @@ -30,6 +29,7 @@ go_library( "//staging/src/k8s.io/cloud-provider:go_default_library", "//staging/src/k8s.io/component-base/cli/flag:go_default_library", "//staging/src/k8s.io/component-base/cli/globalflag:go_default_library", + "//staging/src/k8s.io/component-base/version:go_default_library", "//vendor/github.com/spf13/cobra:go_default_library", "//vendor/k8s.io/klog:go_default_library", ], diff --git a/cmd/cloud-controller-manager/app/controllermanager.go b/cmd/cloud-controller-manager/app/controllermanager.go index d9d9ca71365..5993b674fd1 100644 --- a/cmd/cloud-controller-manager/app/controllermanager.go +++ b/cmd/cloud-controller-manager/app/controllermanager.go @@ -37,13 +37,13 @@ import ( cloudprovider "k8s.io/cloud-provider" cliflag "k8s.io/component-base/cli/flag" "k8s.io/component-base/cli/globalflag" + "k8s.io/component-base/version" "k8s.io/klog" cloudcontrollerconfig "k8s.io/kubernetes/cmd/cloud-controller-manager/app/config" "k8s.io/kubernetes/cmd/cloud-controller-manager/app/options" genericcontrollermanager "k8s.io/kubernetes/cmd/controller-manager/app" "k8s.io/kubernetes/pkg/util/configz" utilflag "k8s.io/kubernetes/pkg/util/flag" - "k8s.io/kubernetes/pkg/version" "k8s.io/kubernetes/pkg/version/verflag" ) diff --git a/cmd/cloud-controller-manager/controller-manager.go b/cmd/cloud-controller-manager/controller-manager.go index b00af712b7f..64de4bbfb0c 100644 --- a/cmd/cloud-controller-manager/controller-manager.go +++ b/cmd/cloud-controller-manager/controller-manager.go @@ -30,9 +30,8 @@ import ( // NOTE: Importing all in-tree cloud-providers is not required when // implementing an out-of-tree cloud-provider. + _ "k8s.io/component-base/metrics/prometheus/clientgo" // load all the prometheus client-go plugins _ "k8s.io/kubernetes/pkg/cloudprovider/providers" - _ "k8s.io/kubernetes/pkg/util/prometheusclientgo" // load all the prometheus client-go plugins - _ "k8s.io/kubernetes/pkg/version/prometheus" // for version metric registration ) func main() { diff --git a/cmd/controller-manager/app/BUILD b/cmd/controller-manager/app/BUILD index f88adc9ef20..984cf2b7676 100644 --- a/cmd/controller-manager/app/BUILD +++ b/cmd/controller-manager/app/BUILD @@ -22,7 +22,7 @@ go_library( "//staging/src/k8s.io/apiserver/pkg/server/routes:go_default_library", "//staging/src/k8s.io/client-go/kubernetes:go_default_library", "//staging/src/k8s.io/component-base/config:go_default_library", - "//vendor/github.com/prometheus/client_golang/prometheus:go_default_library", + "//staging/src/k8s.io/component-base/metrics/legacyregistry:go_default_library", "//vendor/k8s.io/klog:go_default_library", ], ) diff --git a/cmd/controller-manager/app/serve.go b/cmd/controller-manager/app/serve.go index 86e7e4136ef..ad0639866a9 100644 --- a/cmd/controller-manager/app/serve.go +++ b/cmd/controller-manager/app/serve.go @@ -17,7 +17,6 @@ limitations under the License. package app import ( - "github.com/prometheus/client_golang/prometheus" "net/http" goruntime "runtime" @@ -29,6 +28,7 @@ import ( "k8s.io/apiserver/pkg/server/mux" "k8s.io/apiserver/pkg/server/routes" componentbaseconfig "k8s.io/component-base/config" + "k8s.io/component-base/metrics/legacyregistry" "k8s.io/kubernetes/pkg/api/legacyscheme" "k8s.io/kubernetes/pkg/util/configz" ) @@ -62,7 +62,7 @@ func NewBaseHandler(c *componentbaseconfig.DebuggingConfiguration, checks ...hea } } configz.InstallHandler(mux) - mux.Handle("/metrics", prometheus.Handler()) + mux.Handle("/metrics", legacyregistry.Handler()) return mux } diff --git a/cmd/hyperkube/BUILD b/cmd/hyperkube/BUILD index 41c086780a4..df5d3c2254c 100644 --- a/cmd/hyperkube/BUILD +++ b/cmd/hyperkube/BUILD @@ -24,11 +24,11 @@ go_library( "//cmd/kube-proxy/app:go_default_library", "//cmd/kube-scheduler/app:go_default_library", "//cmd/kubelet/app:go_default_library", - "//pkg/client/metrics/prometheus:go_default_library", "//pkg/kubectl/cmd:go_default_library", "//pkg/version/prometheus:go_default_library", "//staging/src/k8s.io/component-base/cli/flag:go_default_library", "//staging/src/k8s.io/component-base/logs:go_default_library", + "//staging/src/k8s.io/component-base/metrics/prometheus/restclient:go_default_library", "//vendor/github.com/spf13/cobra:go_default_library", "//vendor/github.com/spf13/pflag:go_default_library", ], diff --git a/cmd/hyperkube/main.go b/cmd/hyperkube/main.go index 7f7034423a9..8698700ca7f 100644 --- a/cmd/hyperkube/main.go +++ b/cmd/hyperkube/main.go @@ -34,13 +34,13 @@ import ( cliflag "k8s.io/component-base/cli/flag" "k8s.io/component-base/logs" + _ "k8s.io/component-base/metrics/prometheus/restclient" // for client metric registration cloudcontrollermanager "k8s.io/kubernetes/cmd/cloud-controller-manager/app" kubeapiserver "k8s.io/kubernetes/cmd/kube-apiserver/app" kubecontrollermanager "k8s.io/kubernetes/cmd/kube-controller-manager/app" kubeproxy "k8s.io/kubernetes/cmd/kube-proxy/app" kubescheduler "k8s.io/kubernetes/cmd/kube-scheduler/app" kubelet "k8s.io/kubernetes/cmd/kubelet/app" - _ "k8s.io/kubernetes/pkg/client/metrics/prometheus" // for client metric registration kubectl "k8s.io/kubernetes/pkg/kubectl/cmd" _ "k8s.io/kubernetes/pkg/version/prometheus" // for version metric registration ) diff --git a/cmd/kube-apiserver/BUILD b/cmd/kube-apiserver/BUILD index 1e9207a7801..a2c7666db2d 100644 --- a/cmd/kube-apiserver/BUILD +++ b/cmd/kube-apiserver/BUILD @@ -20,9 +20,8 @@ go_library( importpath = "k8s.io/kubernetes/cmd/kube-apiserver", deps = [ "//cmd/kube-apiserver/app:go_default_library", - "//pkg/util/prometheusclientgo:go_default_library", - "//pkg/version/prometheus:go_default_library", "//staging/src/k8s.io/component-base/logs:go_default_library", + "//staging/src/k8s.io/component-base/metrics/prometheus/clientgo:go_default_library", ], ) diff --git a/cmd/kube-apiserver/apiserver.go b/cmd/kube-apiserver/apiserver.go index 98002a16b0a..041707e4090 100644 --- a/cmd/kube-apiserver/apiserver.go +++ b/cmd/kube-apiserver/apiserver.go @@ -25,9 +25,8 @@ import ( "time" "k8s.io/component-base/logs" + _ "k8s.io/component-base/metrics/prometheus/clientgo" // load all the prometheus client-go plugins "k8s.io/kubernetes/cmd/kube-apiserver/app" - _ "k8s.io/kubernetes/pkg/util/prometheusclientgo" // load all the prometheus client-go plugins - _ "k8s.io/kubernetes/pkg/version/prometheus" // for version metric registration ) func main() { diff --git a/cmd/kube-apiserver/app/BUILD b/cmd/kube-apiserver/app/BUILD index 222944fcdfc..927ef5d3f4b 100644 --- a/cmd/kube-apiserver/app/BUILD +++ b/cmd/kube-apiserver/app/BUILD @@ -29,8 +29,6 @@ go_library( "//pkg/registry/rbac/rest:go_default_library", "//pkg/serviceaccount:go_default_library", "//pkg/util/flag:go_default_library", - "//pkg/util/workqueue/prometheus:go_default_library", - "//pkg/version:go_default_library", "//pkg/version/verflag:go_default_library", "//plugin/pkg/auth/authenticator/token/bootstrap:go_default_library", "//staging/src/k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1beta1:go_default_library", @@ -67,6 +65,8 @@ go_library( "//staging/src/k8s.io/cloud-provider:go_default_library", "//staging/src/k8s.io/component-base/cli/flag:go_default_library", "//staging/src/k8s.io/component-base/cli/globalflag:go_default_library", + "//staging/src/k8s.io/component-base/metrics/prometheus/workqueue:go_default_library", + "//staging/src/k8s.io/component-base/version:go_default_library", "//staging/src/k8s.io/kube-aggregator/pkg/apis/apiregistration:go_default_library", "//staging/src/k8s.io/kube-aggregator/pkg/apis/apiregistration/v1:go_default_library", "//staging/src/k8s.io/kube-aggregator/pkg/apis/apiregistration/v1beta1:go_default_library", diff --git a/cmd/kube-apiserver/app/server.go b/cmd/kube-apiserver/app/server.go index bed51681581..80c5af9d887 100644 --- a/cmd/kube-apiserver/app/server.go +++ b/cmd/kube-apiserver/app/server.go @@ -61,6 +61,8 @@ import ( cloudprovider "k8s.io/cloud-provider" cliflag "k8s.io/component-base/cli/flag" "k8s.io/component-base/cli/globalflag" + _ "k8s.io/component-base/metrics/prometheus/workqueue" // for workqueue metric registration + "k8s.io/component-base/version" "k8s.io/klog" aggregatorapiserver "k8s.io/kube-aggregator/pkg/apiserver" aggregatorscheme "k8s.io/kube-aggregator/pkg/apiserver/scheme" @@ -82,8 +84,6 @@ import ( rbacrest "k8s.io/kubernetes/pkg/registry/rbac/rest" "k8s.io/kubernetes/pkg/serviceaccount" utilflag "k8s.io/kubernetes/pkg/util/flag" - _ "k8s.io/kubernetes/pkg/util/workqueue/prometheus" // for workqueue metric registration - "k8s.io/kubernetes/pkg/version" "k8s.io/kubernetes/pkg/version/verflag" "k8s.io/kubernetes/plugin/pkg/auth/authenticator/token/bootstrap" ) diff --git a/cmd/kube-controller-manager/BUILD b/cmd/kube-controller-manager/BUILD index 6e9b0b68288..b77adbe6a7e 100644 --- a/cmd/kube-controller-manager/BUILD +++ b/cmd/kube-controller-manager/BUILD @@ -20,9 +20,8 @@ go_library( importpath = "k8s.io/kubernetes/cmd/kube-controller-manager", deps = [ "//cmd/kube-controller-manager/app:go_default_library", - "//pkg/util/prometheusclientgo:go_default_library", - "//pkg/version/prometheus:go_default_library", "//staging/src/k8s.io/component-base/logs:go_default_library", + "//staging/src/k8s.io/component-base/metrics/prometheus/clientgo:go_default_library", ], ) diff --git a/cmd/kube-controller-manager/controller-manager.go b/cmd/kube-controller-manager/controller-manager.go index b5f94549b5a..6e71dabde9f 100644 --- a/cmd/kube-controller-manager/controller-manager.go +++ b/cmd/kube-controller-manager/controller-manager.go @@ -27,9 +27,8 @@ import ( "time" "k8s.io/component-base/logs" + _ "k8s.io/component-base/metrics/prometheus/clientgo" // load all the prometheus client-go plugin "k8s.io/kubernetes/cmd/kube-controller-manager/app" - _ "k8s.io/kubernetes/pkg/util/prometheusclientgo" // load all the prometheus client-go plugin - _ "k8s.io/kubernetes/pkg/version/prometheus" // for version metric registration ) func main() { diff --git a/cmd/kube-proxy/BUILD b/cmd/kube-proxy/BUILD index 29e5743beb1..ed4156c8740 100644 --- a/cmd/kube-proxy/BUILD +++ b/cmd/kube-proxy/BUILD @@ -20,10 +20,9 @@ go_library( importpath = "k8s.io/kubernetes/cmd/kube-proxy", deps = [ "//cmd/kube-proxy/app:go_default_library", - "//pkg/client/metrics/prometheus:go_default_library", - "//pkg/version/prometheus:go_default_library", "//staging/src/k8s.io/component-base/cli/flag:go_default_library", "//staging/src/k8s.io/component-base/logs:go_default_library", + "//staging/src/k8s.io/component-base/metrics/prometheus/restclient:go_default_library", "//vendor/github.com/spf13/pflag:go_default_library", ], ) diff --git a/cmd/kube-proxy/app/BUILD b/cmd/kube-proxy/app/BUILD index c26483055ff..d7ae3e31249 100644 --- a/cmd/kube-proxy/app/BUILD +++ b/cmd/kube-proxy/app/BUILD @@ -64,9 +64,9 @@ go_library( "//staging/src/k8s.io/client-go/tools/record:go_default_library", "//staging/src/k8s.io/component-base/cli/flag:go_default_library", "//staging/src/k8s.io/component-base/config:go_default_library", + "//staging/src/k8s.io/component-base/metrics/legacyregistry:go_default_library", "//staging/src/k8s.io/kube-proxy/config/v1alpha1:go_default_library", "//vendor/github.com/fsnotify/fsnotify:go_default_library", - "//vendor/github.com/prometheus/client_golang/prometheus:go_default_library", "//vendor/github.com/spf13/cobra:go_default_library", "//vendor/github.com/spf13/pflag:go_default_library", "//vendor/k8s.io/klog:go_default_library", diff --git a/cmd/kube-proxy/app/server.go b/cmd/kube-proxy/app/server.go index 35b0d9c3089..b277bc2982f 100644 --- a/cmd/kube-proxy/app/server.go +++ b/cmd/kube-proxy/app/server.go @@ -24,6 +24,7 @@ import ( "fmt" "io/ioutil" "k8s.io/client-go/datapartition" + "k8s.io/component-base/metrics/legacyregistry" "net/http" "os" goruntime "runtime" @@ -78,7 +79,6 @@ import ( utilpointer "k8s.io/utils/pointer" "github.com/fsnotify/fsnotify" - "github.com/prometheus/client_golang/prometheus" "github.com/spf13/cobra" "github.com/spf13/pflag" "k8s.io/klog" @@ -571,7 +571,7 @@ func (s *ProxyServer) Run() error { proxyMux.HandleFunc("/proxyMode", func(w http.ResponseWriter, r *http.Request) { fmt.Fprintf(w, "%s", s.ProxyMode) }) - proxyMux.Handle("/metrics", prometheus.Handler()) + proxyMux.Handle("/metrics", legacyregistry.Handler()) if s.EnableProfiling { routes.Profiling{}.Install(proxyMux) } diff --git a/cmd/kube-proxy/proxy.go b/cmd/kube-proxy/proxy.go index 9b0e31d9ba7..a7545d3672d 100644 --- a/cmd/kube-proxy/proxy.go +++ b/cmd/kube-proxy/proxy.go @@ -27,9 +27,8 @@ import ( cliflag "k8s.io/component-base/cli/flag" "k8s.io/component-base/logs" + _ "k8s.io/component-base/metrics/prometheus/restclient" // for client metric registration "k8s.io/kubernetes/cmd/kube-proxy/app" - _ "k8s.io/kubernetes/pkg/client/metrics/prometheus" // for client metric registration - _ "k8s.io/kubernetes/pkg/version/prometheus" // for version metric registration ) func main() { diff --git a/cmd/kube-scheduler/BUILD b/cmd/kube-scheduler/BUILD index 42aa06ed0f2..72f6c49af5e 100644 --- a/cmd/kube-scheduler/BUILD +++ b/cmd/kube-scheduler/BUILD @@ -20,10 +20,9 @@ go_library( importpath = "k8s.io/kubernetes/cmd/kube-scheduler", deps = [ "//cmd/kube-scheduler/app:go_default_library", - "//pkg/util/prometheusclientgo:go_default_library", - "//pkg/version/prometheus:go_default_library", "//staging/src/k8s.io/component-base/cli/flag:go_default_library", "//staging/src/k8s.io/component-base/logs:go_default_library", + "//staging/src/k8s.io/component-base/metrics/prometheus/clientgo:go_default_library", "//vendor/github.com/spf13/pflag:go_default_library", ], ) diff --git a/cmd/kube-scheduler/app/BUILD b/cmd/kube-scheduler/app/BUILD index 75d1736f578..1c9b916d867 100644 --- a/cmd/kube-scheduler/app/BUILD +++ b/cmd/kube-scheduler/app/BUILD @@ -39,7 +39,7 @@ go_library( "//staging/src/k8s.io/client-go/tools/leaderelection:go_default_library", "//staging/src/k8s.io/component-base/cli/flag:go_default_library", "//staging/src/k8s.io/component-base/cli/globalflag:go_default_library", - "//vendor/github.com/prometheus/client_golang/prometheus:go_default_library", + "//staging/src/k8s.io/component-base/metrics/legacyregistry:go_default_library", "//vendor/github.com/spf13/cobra:go_default_library", "//vendor/k8s.io/klog:go_default_library", ], diff --git a/cmd/kube-scheduler/app/server.go b/cmd/kube-scheduler/app/server.go index da7d3b020cd..9de8456341f 100644 --- a/cmd/kube-scheduler/app/server.go +++ b/cmd/kube-scheduler/app/server.go @@ -27,6 +27,8 @@ import ( "os" goruntime "runtime" + "github.com/spf13/cobra" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" utilerrors "k8s.io/apimachinery/pkg/util/errors" utilruntime "k8s.io/apimachinery/pkg/util/runtime" @@ -43,6 +45,8 @@ import ( "k8s.io/client-go/tools/leaderelection" cliflag "k8s.io/component-base/cli/flag" "k8s.io/component-base/cli/globalflag" + "k8s.io/component-base/metrics/legacyregistry" + "k8s.io/klog" schedulerserverconfig "k8s.io/kubernetes/cmd/kube-scheduler/app/config" "k8s.io/kubernetes/cmd/kube-scheduler/app/options" "k8s.io/kubernetes/pkg/api/legacyscheme" @@ -55,10 +59,6 @@ import ( utilflag "k8s.io/kubernetes/pkg/util/flag" "k8s.io/kubernetes/pkg/version" "k8s.io/kubernetes/pkg/version/verflag" - - "github.com/prometheus/client_golang/prometheus" - "github.com/spf13/cobra" - "k8s.io/klog" ) // NewSchedulerCommand creates a *cobra.Command object with default parameters @@ -289,7 +289,7 @@ func buildHandlerChain(handler http.Handler, authn authenticator.Request, authz func installMetricHandler(pathRecorderMux *mux.PathRecorderMux) { configz.InstallHandler(pathRecorderMux) - defaultMetricsHandler := prometheus.Handler().ServeHTTP + defaultMetricsHandler := legacyregistry.Handler().ServeHTTP pathRecorderMux.HandleFunc("/metrics", func(w http.ResponseWriter, req *http.Request) { if req.Method == "DELETE" { metrics.Reset() diff --git a/cmd/kube-scheduler/scheduler.go b/cmd/kube-scheduler/scheduler.go index 5f4af458dc6..b7dcdc46ca9 100644 --- a/cmd/kube-scheduler/scheduler.go +++ b/cmd/kube-scheduler/scheduler.go @@ -26,9 +26,8 @@ import ( cliflag "k8s.io/component-base/cli/flag" "k8s.io/component-base/logs" + _ "k8s.io/component-base/metrics/prometheus/clientgo" "k8s.io/kubernetes/cmd/kube-scheduler/app" - _ "k8s.io/kubernetes/pkg/util/prometheusclientgo" // load all the prometheus client-go plugins - _ "k8s.io/kubernetes/pkg/version/prometheus" // for version metric registration ) func main() { diff --git a/go.mod b/go.mod index 941bb2d7fba..7726e402fde 100644 --- a/go.mod +++ b/go.mod @@ -391,7 +391,7 @@ replace ( github.com/grafov/bcast => github.com/grafov/bcast v0.0.0-20190217190352-1447f067e08d github.com/gregjones/httpcache => github.com/gregjones/httpcache v0.0.0-20180305231024-9cad4c3443a7 github.com/grpc-ecosystem/go-grpc-middleware => github.com/grpc-ecosystem/go-grpc-middleware v0.0.0-20190222133341-cfaf5686ec79 - github.com/grpc-ecosystem/go-grpc-prometheus => github.com/grpc-ecosystem/go-grpc-prometheus v0.0.0-20170330212424-2500245aa611 + github.com/grpc-ecosystem/go-grpc-prometheus => github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0 github.com/grpc-ecosystem/grpc-gateway => github.com/grpc-ecosystem/grpc-gateway v1.3.0 github.com/h2non/parth => github.com/h2non/parth v0.0.0-20190131123155-b4df798d6542 github.com/hashicorp/consul/api => github.com/hashicorp/consul/api v1.8.1 @@ -673,7 +673,7 @@ replace ( mvdan.cc/lint => mvdan.cc/lint v0.0.0-20170908181259-adc824a0674b mvdan.cc/unparam => mvdan.cc/unparam v0.0.0-20190209190245-fbb59629db34 sigs.k8s.io/kustomize => sigs.k8s.io/kustomize v2.0.3+incompatible - sigs.k8s.io/structured-merge-diff => sigs.k8s.io/structured-merge-diff v0.0.0-20190302045857-e85c7b244fd2 + sigs.k8s.io/structured-merge-diff => sigs.k8s.io/structured-merge-diff v0.0.0-20190719182312-e94e05bfbbe3 sigs.k8s.io/yaml => sigs.k8s.io/yaml v1.1.0 sourcegraph.com/sqs/pbtypes => sourcegraph.com/sqs/pbtypes v0.0.0-20180604144634-d3ebe8f20ae4 vbom.ml/util => vbom.ml/util v0.0.0-20160121211510-db5cfe13f5cc diff --git a/go.sum b/go.sum index 71df8be23c8..bb086064506 100644 --- a/go.sum +++ b/go.sum @@ -2,18 +2,27 @@ bitbucket.org/bertimus9/systemstat v0.0.0-20180207000608-0eeff89b0690 h1:N9r8OBS bitbucket.org/bertimus9/systemstat v0.0.0-20180207000608-0eeff89b0690/go.mod h1:Ulb78X89vxKYgdL24HMTiXYHlyHEvruOj1ZPlqeNEZM= cloud.google.com/go v0.34.0 h1:eOI3/cP2VTU6uZLDYAoic+eyzzB9YyGmJ7eIjl8rOPg= cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= +github.com/Azure/azure-sdk-for-go v35.0.0+incompatible h1:PkmdmQUmeSdQQ5258f4SyCf2Zcz0w67qztEg37cOR7U= github.com/Azure/azure-sdk-for-go v35.0.0+incompatible/go.mod h1:9XXNKU+eRnpl9moKnB4QOLf1HestfXbmab5FXxiDBjc= github.com/Azure/go-ansiterm v0.0.0-20170929234023-d6e3b3328b78 h1:w+iIsaOQNcT7OZ575w+acHgRric5iCyQh+xv+KJ4HB8= github.com/Azure/go-ansiterm v0.0.0-20170929234023-d6e3b3328b78/go.mod h1:LmzpDX56iTiv29bbRTIsUNlaFfuhWRQBWjQdVyAevI8= +github.com/Azure/go-autorest/autorest v0.9.0 h1:MRvx8gncNaXJqOoLmhNjUAKh33JJF8LyxPhomEtOsjs= github.com/Azure/go-autorest/autorest v0.9.0/go.mod h1:xyHB1BMZT0cuDHU7I0+g046+BFDTQ8rEZB0s4Yfa6bI= +github.com/Azure/go-autorest/autorest/adal v0.5.0 h1:q2gDruN08/guU9vAjuPWff0+QIrpH6ediguzdAzXAUU= github.com/Azure/go-autorest/autorest/adal v0.5.0/go.mod h1:8Z9fGy2MpX0PvDjB1pEgQTmVqjGhiHBW7RJJEciWzS0= github.com/Azure/go-autorest/autorest/azure/auth v0.1.0/go.mod h1:Gf7/i2FUpyb/sGBLIFxTBzrNzBo7aPXXE3ZVeDRwdpM= github.com/Azure/go-autorest/autorest/azure/cli v0.1.0/go.mod h1:Dk8CUAt/b/PzkfeRsWzVG9Yj3ps8mS8ECztu43rdU8U= +github.com/Azure/go-autorest/autorest/date v0.1.0 h1:YGrhWfrgtFs84+h0o46rJrlmsZtyZRg470CqAXTZaGM= github.com/Azure/go-autorest/autorest/date v0.1.0/go.mod h1:plvfp3oPSKwf2DNjlBjWF/7vwR+cUD/ELuzDCXwHUVA= +github.com/Azure/go-autorest/autorest/mocks v0.2.0 h1:Ww5g4zThfD/6cLb4z6xxgeyDa7QDkizMkJKe0ysZXp0= github.com/Azure/go-autorest/autorest/mocks v0.2.0/go.mod h1:OTyCOPRA2IgIlWxVYxBee2F5Gr4kF2zd2J5cFRaIDN0= +github.com/Azure/go-autorest/autorest/to v0.2.0 h1:nQOZzFCudTh+TvquAtCRjM01VEYx85e9qbwt5ncW4L8= github.com/Azure/go-autorest/autorest/to v0.2.0/go.mod h1:GunWKJp1AEqgMaGLV+iocmRAJWqST1wQYhyyjXJ3SJc= +github.com/Azure/go-autorest/autorest/validation v0.1.0 h1:ISSNzGUh+ZSzizJWOWzs8bwpXIePbGLW4z/AmUFGH5A= github.com/Azure/go-autorest/autorest/validation v0.1.0/go.mod h1:Ha3z/SqBeaalWQvokg3NZAlQTalVMtOIAs1aGK7G6u8= +github.com/Azure/go-autorest/logger v0.1.0 h1:ruG4BSDXONFRrZZJ2GUXDiUyVpayPmb1GnWeHDdaNKY= github.com/Azure/go-autorest/logger v0.1.0/go.mod h1:oExouG+K6PryycPJfVSxi/koC6LSNgds39diKLz7Vrc= +github.com/Azure/go-autorest/tracing v0.5.0 h1:TRn4WjSnkcSy5AEG3pnbtFSwNtwzjr4VYyQflFE619k= github.com/Azure/go-autorest/tracing v0.5.0/go.mod h1:r/s2XiOKccPW3HrqB+W0TQzfbtp2fGCgRFtBroKn4Dk= github.com/BurntSushi/toml v0.3.1 h1:WXkYYl6Yr3qBf1K79EBnL4mak0OimBfB0XUf9Vl28OQ= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= @@ -70,6 +79,7 @@ github.com/blang/semver v3.5.0+incompatible/go.mod h1:kRBLl5iJ+tD4TcOOxsy/0fnweb github.com/boltdb/bolt v1.3.1 h1:JQmyP4ZBrce+ZQu0dY660FMfatumYDLun9hBCUVIkF4= github.com/boltdb/bolt v1.3.1/go.mod h1:clJnj/oiGkjum5o1McbSZDSLxVThjynRyGBgiAx27Ps= github.com/bradfitz/go-smtpd v0.0.0-20170404230938-deb6d6237625/go.mod h1:HYsPBTaaSFSlLx/70C2HPIMNZpVV8+vt/A+FMnYP11g= +github.com/caddyserver/caddy v1.0.3 h1:i9gRhBgvc5ifchwWtSe7pDpsdS9+Q0Rw9oYQmYUTw1w= github.com/caddyserver/caddy v1.0.3/go.mod h1:G+ouvOY32gENkJC+jhgl62TyhvqEsFaDiZ4uw0RzP1E= github.com/cenkalti/backoff/v3 v3.0.0/go.mod h1:cIeZDE3IrqwwJl6VUwCN6trj1oXrTS4rc0ij+ULvLYs= github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= @@ -82,6 +92,7 @@ github.com/checkpoint-restore/go-criu v0.0.0-20181120144056-17b0214f6c48/go.mod github.com/cheekybits/genny v1.0.0/go.mod h1:+tQajlRqAUrPI7DOSpB0XAqZYtQakVtB7wXkRAgjxjQ= github.com/cilium/ebpf v0.0.0-20191025125908-95b36a581eed h1:/UgmF+cZTm9kp4uJ122y/9cVhczNJCgAgAeH2FfzPeg= github.com/cilium/ebpf v0.0.0-20191025125908-95b36a581eed/go.mod h1:MA5e5Lr8slmEg9bt0VpxxWqJlO4iwu3FBdHUzV7wQVg= +github.com/client9/misspell v0.3.4 h1:ta993UF76GwbvJcIo3Y68y/M3WxlpEHPWIGDkJYwzJI= github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= github.com/cloudflare/cfssl v0.0.0-20180726162950-56268a613adf h1:eOyFuj3h/Vj5e4voOM16NNrHsUR3jhD0duh76LHMj6Y= github.com/cloudflare/cfssl v0.0.0-20180726162950-56268a613adf/go.mod h1:yMWuSON2oQp+43nFtAV/uvKQIFpSPerB57DCt9t8sSA= @@ -108,6 +119,7 @@ github.com/coreos/etcd v3.3.25+incompatible/go.mod h1:uF7uidLiAD3TWHmW31ZFd/JWoc github.com/coreos/go-etcd v2.0.0+incompatible/go.mod h1:Jez6KQU2B/sWsbdaef3ED8NzMklzPG4d5KIOhIy30Tk= github.com/coreos/go-oidc v0.0.0-20180117170138-065b426bd416 h1:X+JQSgXg3CcxgcBoMAqU8NoS0fch8zHxjiKWcXclxaI= github.com/coreos/go-oidc v0.0.0-20180117170138-065b426bd416/go.mod h1:CgnwVTmzoESiwO9qyAFEMiHoZ1nMCKZlZ9V6mm3/LKc= +github.com/coreos/go-semver v0.3.0 h1:wkHLiw0WNATZnSG7epLsujiMCgPAc9xhjJ4tgnAxmfM= github.com/coreos/go-semver v0.3.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk= github.com/coreos/go-systemd v0.0.0-20190321100706-95778dfbb74e h1:Wf6HqHfScWJN9/ZjdUKyjop4mf3Qdd+1TvvltAvM3m8= github.com/coreos/go-systemd v0.0.0-20190321100706-95778dfbb74e/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4= @@ -116,8 +128,10 @@ github.com/coreos/pkg v0.0.0-20180108230652-97fdf19511ea/go.mod h1:E3G3o1h8I7cfc github.com/coreos/rkt v1.30.0 h1:Kkt6sYeEGKxA3Y7SCrY+nHoXkWed6Jr2BBY42GqMymM= github.com/coreos/rkt v1.30.0/go.mod h1:O634mlH6U7qk87poQifK6M2rsFNt+FyUTWNMnP1hF1U= github.com/cpu/goacmedns v0.0.1/go.mod h1:sesf/pNnCYwUevQEQfEwY0Y3DydlQWSGZbaMElOWxok= +github.com/cpuguy83/go-md2man v1.0.10 h1:BSKMNlYxDvnunlTymqtgONjNnaRV1sTpcovwwjF22jk= github.com/cpuguy83/go-md2man v1.0.10/go.mod h1:SmD6nW6nTyfqj6ABTjUi3V3JVMnlJmwcJI5acqYI6dE= github.com/creack/pty v1.1.7/go.mod h1:lj5s0c3V2DBrqTV7llrYr5NG6My20zk30Fl46Y7DoTY= +github.com/cyphar/filepath-securejoin v0.2.2 h1:jCwT2GTP+PY5nBz3c/YL5PAIbusElVrPujOBSCj8xRg= github.com/cyphar/filepath-securejoin v0.2.2/go.mod h1:FpkQEhXnPnOthhzymB7CGsFk2G9VLXONKD9G7QGMM+4= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= @@ -285,8 +299,8 @@ github.com/gregjones/httpcache v0.0.0-20180305231024-9cad4c3443a7 h1:pdN6V1QBWet github.com/gregjones/httpcache v0.0.0-20180305231024-9cad4c3443a7/go.mod h1:FecbI9+v66THATjSRHfNgh1IVFe/9kFxbXtjV0ctIMA= github.com/grpc-ecosystem/go-grpc-middleware v0.0.0-20190222133341-cfaf5686ec79 h1:lR9ssWAqp9qL0bALxqEEkuudiP1eweOdv9jsRK3e7lE= github.com/grpc-ecosystem/go-grpc-middleware v0.0.0-20190222133341-cfaf5686ec79/go.mod h1:FiyG127CGDf3tlThmgyCl78X/SZQqEOJBCDaAfeWzPs= -github.com/grpc-ecosystem/go-grpc-prometheus v0.0.0-20170330212424-2500245aa611 h1:f5vL2EW5pL274ztMNnizZAEa457nKyKPEaN/sm/kdBk= -github.com/grpc-ecosystem/go-grpc-prometheus v0.0.0-20170330212424-2500245aa611/go.mod h1:8NvIoxWQoOIhqOTXgfV/d3M/q6VIi02HzZEHgUlZvzk= +github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0 h1:Ovs26xHkKqVztRpIrF/92BcuyuQ/YW4NSIpoGtfXNho= +github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0/go.mod h1:8NvIoxWQoOIhqOTXgfV/d3M/q6VIi02HzZEHgUlZvzk= github.com/grpc-ecosystem/grpc-gateway v1.3.0 h1:HJtP6RRwj2EpPCD/mhAWzSvLL/dFTdPm1UrWwanoFos= github.com/grpc-ecosystem/grpc-gateway v1.3.0/go.mod h1:RSKVYQBd5MCa4OVpNdGskqpgL2+G+NZTnrVHpWWfpdw= github.com/h2non/parth v0.0.0-20190131123155-b4df798d6542/go.mod h1:Ow0tF8D4Kplbc8s8sSb3V2oUCygFHVp8gC3Dn6U4MNI= @@ -455,6 +469,7 @@ github.com/robfig/cron v1.1.0/go.mod h1:JGuDeoQd7Z6yL4zQhZ3OPEVHB7fL6Ka6skscFHfm github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= github.com/rubiojr/go-vhd v0.0.0-20160810183302-0bfd3b39853c h1:ht7N4d/B7Ezf58nvMNVF3OlvDlz9pp+WHVcRNS0nink= github.com/rubiojr/go-vhd v0.0.0-20160810183302-0bfd3b39853c/go.mod h1:DM5xW0nvfNNm2uytzsvhI3OnX8uzaRAg8UX/CnDqbto= +github.com/russross/blackfriday v1.5.2 h1:HyvC0ARfnZBqnXwABFeSZHpKvJHJJfPz81GNueLj0oo= github.com/russross/blackfriday v1.5.2/go.mod h1:JO/DiYxRf+HjHt06OyowR9PTA263kcR/rfWxYHBV53g= github.com/ryanuber/go-glob v0.0.0-20170128012129-256dc444b735/go.mod h1:807d1WSdnB0XRJzKNil9Om6lcp/3a0v4qIHxIXzX/Yc= github.com/sacloud/libsacloud v1.26.1/go.mod h1:79ZwATmHLIFZIMd7sxA3LwzVy/B77uj3LDoToVTxDoQ= @@ -626,6 +641,7 @@ k8s.io/gengo v0.0.0-20200205140755-e0e292d8aa12 h1:pZzawYyz6VRNPVYpqGv61LWCimQv1 k8s.io/gengo v0.0.0-20200205140755-e0e292d8aa12/go.mod h1:ezvh/TsK7cY6rbqRK0oQQ8IAqLxYwwyPxAX1Pzy0ii0= k8s.io/heapster v1.2.0-beta.1 h1:lUsE/AHOMHpi3MLlBEkaU8Esxm5QhdyCrv1o7ot0s84= k8s.io/heapster v1.2.0-beta.1/go.mod h1:h1uhptVXMwC8xtZBYsPXKVi8fpdlYkTs6k949KozGrM= +k8s.io/klog v1.0.0 h1:Pt+yjF5aB1xDSVbau4VsWe+dQNzA0qv1LlXdC2dF6Q8= k8s.io/klog v1.0.0/go.mod h1:4Bi6QPql/J/LkTDqv7R/cd3hPo4k2DG6Ptcz060Ez5I= k8s.io/kube-openapi v0.0.0-20190228160746-b3a7cee44a30 h1:TRb4wNWoBVrH9plmkp2q86FIDppkbrEXdXlxU3a3BMI= k8s.io/kube-openapi v0.0.0-20190228160746-b3a7cee44a30/go.mod h1:BXM9ceUBTj2QnfH2MK1odQs778ajze1RxcmP6S8RVVc= @@ -643,8 +659,8 @@ mvdan.cc/lint v0.0.0-20170908181259-adc824a0674b/go.mod h1:2odslEg/xrtNQqCYg2/jC mvdan.cc/unparam v0.0.0-20190209190245-fbb59629db34/go.mod h1:H6SUd1XjIs+qQCyskXg5OFSrilMRUkD8ePJpHKDPaeY= sigs.k8s.io/kustomize v2.0.3+incompatible h1:JUufWFNlI44MdtnjUqVnvh29rR37PQFzPbLXqhyOyX0= sigs.k8s.io/kustomize v2.0.3+incompatible/go.mod h1:MkjgH3RdOWrievjo6c9T245dYlB5QeXV4WCbnt/PEpU= -sigs.k8s.io/structured-merge-diff v0.0.0-20190302045857-e85c7b244fd2 h1:9r5DY45ef9LtcA6BnkhW8MPV7OKAfbf2AUwUhq3LeRk= -sigs.k8s.io/structured-merge-diff v0.0.0-20190302045857-e85c7b244fd2/go.mod h1:wWxsB5ozmmv/SG7nM11ayaAW51xMvak/t1r0CSlcokI= +sigs.k8s.io/structured-merge-diff v0.0.0-20190719182312-e94e05bfbbe3 h1:yCY9zAYErawYwXdOYmwEBzcGCr/6eIUujYZE2DIQve8= +sigs.k8s.io/structured-merge-diff v0.0.0-20190719182312-e94e05bfbbe3/go.mod h1:wWxsB5ozmmv/SG7nM11ayaAW51xMvak/t1r0CSlcokI= sigs.k8s.io/yaml v1.1.0 h1:4A07+ZFc2wgJwo8YNlQpr1rVlgUDlxXHhPJciaPY5gs= sigs.k8s.io/yaml v1.1.0/go.mod h1:UJmg0vDUVViEyp3mgSv9WPwZCDxu4rQW1olrI1uml+o= sourcegraph.com/sqs/pbtypes v0.0.0-20180604144634-d3ebe8f20ae4/go.mod h1:ketZ/q3QxT9HOBeFhu6RdvsftgpsbFHBF5Cas6cDKZ0= diff --git a/hack/.shellcheck_failures b/hack/.shellcheck_failures index c7c0224ca04..268a239c4c5 100644 --- a/hack/.shellcheck_failures +++ b/hack/.shellcheck_failures @@ -17,10 +17,7 @@ ./cluster/restore-from-backup.sh ./cluster/test-e2e.sh ./cluster/validate-cluster.sh -./hack/lib/init.sh -./hack/lib/swagger.sh ./hack/lib/test.sh -./hack/lib/version.sh ./hack/make-rules/make-help.sh ./hack/test-integration.sh ./hack/verify-test-featuregates.sh diff --git a/hack/arktos_copyright_copied_k8s_files b/hack/arktos_copyright_copied_k8s_files index 4ed0612b15c..7acc695b6a4 100644 --- a/hack/arktos_copyright_copied_k8s_files +++ b/hack/arktos_copyright_copied_k8s_files @@ -1,5 +1,14 @@ cmd/cloud-controller-manager/app/controllermanager.go +cmd/cloud-controller-manager/controller-manager.go cmd/controller-manager/app/serve.go +cmd/hyperkube/main.go +cmd/kube-apiserver/apiserver.go +cmd/kube-controller-manager/controller-manager.go +cmd/kube-proxy/proxy.go +cmd/kube-scheduler/scheduler.go +hack/lib/swagger.sh +hack/lib/version.sh +hack/update-openapi-spec.sh pkg/cloudfabric-controller/client_builder.go pkg/cloudfabric-controller/controller_ref_manager.go pkg/cloudfabric-controller/controller_ref_manager_test.go @@ -13,20 +22,50 @@ pkg/cloudfabric-controller/replicaset/doc.go pkg/cloudfabric-controller/replicaset/replica_set_utils.go pkg/cloudfabric-controller/replicaset/replica_set_utils_test.go pkg/cloudfabric-controller/testutil/test_utils.go +pkg/cloudprovider/providers/openstack/openstack_metrics.go pkg/controller/informer_factory.go +pkg/controller/nodelifecycle/metrics.go +pkg/controller/volume/persistentvolume/metrics/metrics.go +pkg/controller/volume/scheduling/scheduler_bind_cache_metrics.go pkg/kubectl/cmd/create/create_clusterrolebinding_test.go pkg/kubectl/cmd/create/create_namespace_test.go pkg/kubectl/cmd/taint/taint_test.go +pkg/kubelet/certificate/kubelet.go pkg/kubelet/container/ref_test.go +pkg/kubelet/dockershim/metrics/metrics.go +pkg/kubelet/dockershim/network/metrics/metrics.go +pkg/kubelet/kuberuntime/instrumented_services_test.go +pkg/kubelet/metrics/metrics.go +pkg/kubelet/server/metrics/metrics.go +pkg/kubelet/volumemanager/metrics/metrics.go +pkg/proxy/metrics/metrics.go +pkg/proxy/winkernel/metrics.go +pkg/scheduler/metrics/metric_recorder.go +pkg/scheduler/metrics/metrics.go +pkg/ssh/ssh.go +pkg/util/metrics/util.go +pkg/volume/csi/csi_attacher_test.go +pkg/volume/csi/csi_plugin.go +pkg/volume/csi/csi_plugin_test.go +pkg/volume/csi/csi_test.go +pkg/volume/csi/csi_util.go +pkg/volume/csi/testing/testing.go +pkg/volume/util/metrics.go +pkg/volume/util/operationexecutor/operation_generator_test.go +staging/src/k8s.io/apiextensions-apiserver/pkg/apiserver/conversion/metrics.go staging/src/k8s.io/apimachinery/pkg/runtime/negotiate.go staging/src/k8s.io/apimachinery/pkg/runtime/serializer/json/json.go staging/src/k8s.io/apimachinery/pkg/runtime/serializer/protobuf/protobuf.go staging/src/k8s.io/apimachinery/pkg/runtime/serializer/versioning/versioning.go staging/src/k8s.io/apimachinery/pkg/runtime/testing/cacheable_object.go +staging/src/k8s.io/apiserver/pkg/admission/metrics/metrics.go +staging/src/k8s.io/apiserver/pkg/audit/metrics.go staging/src/k8s.io/apiserver/pkg/endpoints/discovery/util.go +staging/src/k8s.io/apiserver/pkg/endpoints/handlers/fieldmanager/internal/pathelement.go staging/src/k8s.io/apiserver/pkg/endpoints/handlers/response_test.go staging/src/k8s.io/apiserver/pkg/endpoints/handlers/responsewriters/writers.go staging/src/k8s.io/apiserver/pkg/endpoints/handlers/responsewriters/writers_test.go +staging/src/k8s.io/apiserver/pkg/endpoints/metrics/metrics.go staging/src/k8s.io/apiserver/pkg/server/filters/goaway.go staging/src/k8s.io/apiserver/pkg/server/filters/goaway_test.go staging/src/k8s.io/apiserver/pkg/server/healthz.go @@ -53,13 +92,27 @@ staging/src/k8s.io/apiserver/pkg/storage/etcd3/testing/test_server.go staging/src/k8s.io/apiserver/pkg/storage/etcd3/testing/testingcert/certificates.go staging/src/k8s.io/apiserver/pkg/storage/etcd3/testing/utils.go staging/src/k8s.io/apiserver/pkg/storage/value/encrypt/envelope/grpc_service.go +staging/src/k8s.io/apiserver/pkg/storage/value/metrics.go +staging/src/k8s.io/apiserver/pkg/storage/value/metrics_test.go +staging/src/k8s.io/apiserver/pkg/storage/value/transformer.go +staging/src/k8s.io/apiserver/pkg/storage/value/transformer_test.go staging/src/k8s.io/cli-runtime/pkg/resource/scheme.go staging/src/k8s.io/client-go/dynamic/scheme.go staging/src/k8s.io/client-go/metadata/metadatainformer/interface.go staging/src/k8s.io/client-go/rest/client.go staging/src/k8s.io/client-go/rest/fake/fake.go staging/src/k8s.io/client-go/rest/request_test.go +staging/src/k8s.io/client-go/transport/round_trippers.go +staging/src/k8s.io/client-go/transport/token_source.go +staging/src/k8s.io/client-go/transport/token_source_test.go +staging/src/k8s.io/client-go/transport/transport.go staging/src/k8s.io/client-go/util/flowcontrol/throttle.go staging/src/k8s.io/client-go/util/flowcontrol/throttle_test.go +staging/src/k8s.io/kube-aggregator/pkg/controllers/status/metrics.go +staging/src/k8s.io/legacy-cloud-providers/aws/aws_metrics.go +staging/src/k8s.io/legacy-cloud-providers/azure/azure_metrics.go +staging/src/k8s.io/legacy-cloud-providers/gce/metrics.go +staging/src/k8s.io/legacy-cloud-providers/gce/token_source.go +staging/src/k8s.io/legacy-cloud-providers/vsphere/vclib/vsphere_metrics.go test/e2e/node/node_problem_detector.go test/integration/garbagecollector/garbage_collector_test.go diff --git a/hack/lib/init.sh b/hack/lib/init.sh index 3d852c8acbc..6465e6d00d7 100755 --- a/hack/lib/init.sh +++ b/hack/lib/init.sh @@ -30,7 +30,7 @@ unset CDPATH export GO111MODULE=off # The root of the build/dist directory -KUBE_ROOT="$(cd "$(dirname "${BASH_SOURCE}")/../.." && pwd -P)" +KUBE_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd -P)" KUBE_OUTPUT_SUBPATH="${KUBE_OUTPUT_SUBPATH:-_output/local}" KUBE_OUTPUT="${KUBE_ROOT}/${KUBE_OUTPUT_SUBPATH}" @@ -45,7 +45,7 @@ KUBE_RSYNC_COMPRESS="${KUBE_RSYNC_COMPRESS:-0}" export no_proxy=127.0.0.1,localhost # This is a symlink to binaries for "this platform", e.g. build tools. -THIS_PLATFORM_BIN="${KUBE_ROOT}/_output/bin" +export THIS_PLATFORM_BIN="${KUBE_ROOT}/_output/bin" source "${KUBE_ROOT}/hack/lib/util.sh" source "${KUBE_ROOT}/hack/lib/logging.sh" @@ -57,6 +57,7 @@ source "${KUBE_ROOT}/hack/lib/golang.sh" source "${KUBE_ROOT}/hack/lib/etcd.sh" KUBE_OUTPUT_HOSTBIN="${KUBE_OUTPUT_BINPATH}/$(kube::util::host_platform)" +export KUBE_OUTPUT_HOSTBIN # list of all available group versions. This should be used when generated code # or when starting an API server that you want to have everything. @@ -111,6 +112,7 @@ KUBE_NONSERVER_GROUP_VERSIONS=" imagepolicy.k8s.io/v1alpha1\ admission.k8s.io/v1beta1\ " +export KUBE_NONSERVER_GROUP_VERSIONS # This emulates "readlink -f" which is not available on MacOS X. # Test: diff --git a/hack/lib/swagger.sh b/hack/lib/swagger.sh index 6865ad35b48..f8c4ba33ccb 100644 --- a/hack/lib/swagger.sh +++ b/hack/lib/swagger.sh @@ -20,9 +20,6 @@ set -o errexit set -o nounset set -o pipefail -# The root of the build/dist directory -KUBE_ROOT="$(cd "$(dirname "${BASH_SOURCE}")/../.." && pwd -P)" - # Generates types_swagger_doc_generated file for the given group version. # $1: Name of the group version # $2: Path to the directory where types.go for that group version exists. This @@ -30,13 +27,15 @@ KUBE_ROOT="$(cd "$(dirname "${BASH_SOURCE}")/../.." && pwd -P)" kube::swagger::gen_types_swagger_doc() { local group_version=$1 local gv_dir=$2 - local TMPFILE="${TMPDIR:-/tmp}/types_swagger_doc_generated.$(date +%s).go" + local TMPFILE + TMPFILE="${TMPDIR:-/tmp}/types_swagger_doc_generated.$(date +%s).go" echo "Generating swagger type docs for ${group_version} at ${gv_dir}" - echo -e "$(cat hack/boilerplate/boilerplate.generatego.txt)\n" > "${TMPFILE}" - echo "package ${group_version##*/}" >> "${TMPFILE}" - cat >> "${TMPFILE}" < "${TMPFILE}" go run cmd/genswaggertypedocs/swagger_type_docs.go -s \ "${gv_dir}/types.go" \ @@ -59,5 +59,5 @@ EOF echo "// AUTO-GENERATED FUNCTIONS END HERE" >> "${TMPFILE}" gofmt -w -s "${TMPFILE}" - mv "${TMPFILE}" ""${gv_dir}"/types_swagger_doc_generated.go" + mv "${TMPFILE}" "${gv_dir}/types_swagger_doc_generated.go" } diff --git a/hack/lib/version.sh b/hack/lib/version.sh index 1b7665b467a..e54ca3989eb 100644 --- a/hack/lib/version.sh +++ b/hack/lib/version.sh @@ -39,6 +39,9 @@ kube::version::get_version_vars() { # If the kubernetes source was exported through git archive, then # we likely don't have a git tree, but these magic values may be filled in. + # shellcheck disable=SC2016,SC2050 + # Disabled as we're not expanding these at runtime, but rather expecting + # that another tool may have expanded these and rewritten the source (!) if [[ '$Format:%%$' == "%" ]]; then KUBE_GIT_COMMIT='$Format:%H$' KUBE_GIT_TREE_STATE="archive" @@ -70,11 +73,17 @@ kube::version::get_version_vars() { # # TODO: We continue calling this "git version" because so many # downstream consumers are expecting it there. + # + # These regexes are painful enough in sed... + # We don't want to do them in pure shell, so disable SC2001 + # shellcheck disable=SC2001 DASHES_IN_VERSION=$(echo "${KUBE_GIT_VERSION}" | sed "s/[^-]//g") if [[ "${DASHES_IN_VERSION}" == "---" ]] ; then + # shellcheck disable=SC2001 # We have distance to subversion (v1.1.0-subversion-1-gCommitHash) KUBE_GIT_VERSION=$(echo "${KUBE_GIT_VERSION}" | sed "s/-\([0-9]\{1,\}\)-g\([0-9a-f]\{14\}\)$/.\1\+\2/") elif [[ "${DASHES_IN_VERSION}" == "--" ]] ; then + # shellcheck disable=SC2001 # We have distance to base tag (v1.1.0-1-gCommitHash) KUBE_GIT_VERSION=$(echo "${KUBE_GIT_VERSION}" | sed "s/-g\([0-9a-f]\{14\}\)$/+\1/") fi @@ -135,16 +144,6 @@ kube::version::load_version_vars() { source "${version_file}" } -kube::version::ldflag() { - local key=${1} - local val=${2} - - # If you update these, also update the list pkg/version/def.bzl. - echo "-X '${KUBE_GO_PACKAGE}/pkg/version.${key}=${val}'" - echo "-X '${KUBE_GO_PACKAGE}/vendor/k8s.io/client-go/pkg/version.${key}=${val}'" - echo "-X '${KUBE_GO_PACKAGE}/pkg/kubectl/version.${key}=${val}'" -} - # Prints the value that needs to be passed to the -ldflags parameter of go build # in order to set the Kubernetes based on the git tree status. # IMPORTANT: if you update any of these, also update the lists in @@ -152,23 +151,32 @@ kube::version::ldflag() { kube::version::ldflags() { kube::version::get_version_vars - local buildDate= - [[ -z ${SOURCE_DATE_EPOCH-} ]] || buildDate="--date=@${SOURCE_DATE_EPOCH}" - local -a ldflags=($(kube::version::ldflag "buildDate" "$(date ${buildDate} -u +'%Y-%m-%dT%H:%M:%SZ')")) + local -a ldflags + function add_ldflag() { + local key=${1} + local val=${2} + # If you update these, also update the list pkg/version/def.bzl. + ldflags+=( + "-X '${KUBE_GO_PACKAGE}/pkg/version.${key}=${val}'" + "-X '${KUBE_GO_PACKAGE}/vendor/k8s.io/client-go/pkg/version.${key}=${val}'" + "-X '${KUBE_GO_PACKAGE}/pkg/kubectl/version.${key}=${val}'" + "-X '${KUBE_GO_PACKAGE}/vendor/k8s.io/component-base/version.${key}=${val}'" + ) + } + + add_ldflag "buildDate" "$(date ${SOURCE_DATE_EPOCH:+"--date=@${SOURCE_DATE_EPOCH}"} -u +'%Y-%m-%dT%H:%M:%SZ')" if [[ -n ${KUBE_GIT_COMMIT-} ]]; then - ldflags+=($(kube::version::ldflag "gitCommit" "${KUBE_GIT_COMMIT}")) - ldflags+=($(kube::version::ldflag "gitTreeState" "${KUBE_GIT_TREE_STATE}")) + add_ldflag "gitCommit" "${KUBE_GIT_COMMIT}" + add_ldflag "gitTreeState" "${KUBE_GIT_TREE_STATE}" fi if [[ -n ${KUBE_GIT_VERSION-} ]]; then - ldflags+=($(kube::version::ldflag "gitVersion" "${KUBE_GIT_VERSION}")) + add_ldflag "gitVersion" "${KUBE_GIT_VERSION}" fi if [[ -n ${KUBE_GIT_MAJOR-} && -n ${KUBE_GIT_MINOR-} ]]; then - ldflags+=( - $(kube::version::ldflag "gitMajor" "${KUBE_GIT_MAJOR}") - $(kube::version::ldflag "gitMinor" "${KUBE_GIT_MINOR}") - ) + add_ldflag "gitMajor" "${KUBE_GIT_MAJOR}" + add_ldflag "gitMinor" "${KUBE_GIT_MINOR}" fi # The -ldflags parameter takes a single string, so join the output. diff --git a/hack/update-openapi-spec.sh b/hack/update-openapi-spec.sh index 6482fde8227..0016f4510de 100755 --- a/hack/update-openapi-spec.sh +++ b/hack/update-openapi-spec.sh @@ -69,6 +69,8 @@ kube::log::status "Starting kube-apiserver" --cert-dir="${TMP_DIR}/certs" \ --runtime-config="api/all=true,extensions/v1beta1/daemonsets=true,extensions/v1beta1/deployments=true,extensions/v1beta1/replicasets=true,extensions/v1beta1/networkpolicies=true,extensions/v1beta1/podsecuritypolicies=true,extensions/v1beta1/replicationcontrollers=true" \ --token-auth-file="${TMP_DIR}/tokenauth.csv" \ + --service-account-issuer="https://kubernetes.devault.svc/" \ + --service-account-signing-key-file="${KUBE_ROOT}/staging/src/k8s.io/client-go/util/cert/testdata/dontUseThisKey.pem" \ --logtostderr \ --v=2 \ --service-cluster-ip-range="10.0.0.0/24" >"${API_LOGFILE}" 2>&1 & diff --git a/pkg/cloudprovider/providers/openstack/BUILD b/pkg/cloudprovider/providers/openstack/BUILD index 33481967944..c251c90d395 100644 --- a/pkg/cloudprovider/providers/openstack/BUILD +++ b/pkg/cloudprovider/providers/openstack/BUILD @@ -37,6 +37,8 @@ go_library( "//staging/src/k8s.io/cloud-provider/volume:go_default_library", "//staging/src/k8s.io/cloud-provider/volume/errors:go_default_library", "//staging/src/k8s.io/cloud-provider/volume/helpers:go_default_library", + "//staging/src/k8s.io/component-base/metrics:go_default_library", + "//staging/src/k8s.io/component-base/metrics/legacyregistry:go_default_library", "//vendor/github.com/gophercloud/gophercloud:go_default_library", "//vendor/github.com/gophercloud/gophercloud/openstack:go_default_library", "//vendor/github.com/gophercloud/gophercloud/openstack/blockstorage/extensions/volumeactions:go_default_library", diff --git a/pkg/cloudprovider/providers/openstack/openstack_metrics.go b/pkg/cloudprovider/providers/openstack/openstack_metrics.go index d24d657352d..08ca9388fc5 100644 --- a/pkg/cloudprovider/providers/openstack/openstack_metrics.go +++ b/pkg/cloudprovider/providers/openstack/openstack_metrics.go @@ -19,7 +19,8 @@ package openstack import ( "sync" - "github.com/prometheus/client_golang/prometheus" + "k8s.io/component-base/metrics" + "k8s.io/component-base/metrics/legacyregistry" ) const ( @@ -29,20 +30,22 @@ const ( ) var ( - openstackOperationsLatency = prometheus.NewHistogramVec( - prometheus.HistogramOpts{ - Subsystem: openstackSubsystem, - Name: openstackOperationKey, - Help: "Latency of openstack api call", + openstackOperationsLatency = metrics.NewHistogramVec( + &metrics.HistogramOpts{ + Subsystem: openstackSubsystem, + Name: openstackOperationKey, + Help: "Latency of openstack api call", + StabilityLevel: metrics.ALPHA, }, []string{"request"}, ) - openstackAPIRequestErrors = prometheus.NewCounterVec( - prometheus.CounterOpts{ - Subsystem: openstackSubsystem, - Name: openstackOperationErrorKey, - Help: "Cumulative number of openstack Api call errors", + openstackAPIRequestErrors = metrics.NewCounterVec( + &metrics.CounterOpts{ + Subsystem: openstackSubsystem, + Name: openstackOperationErrorKey, + Help: "Cumulative number of openstack Api call errors", + StabilityLevel: metrics.ALPHA, }, []string{"request"}, ) @@ -52,7 +55,7 @@ var registerOnce sync.Once func registerMetrics() { registerOnce.Do(func() { - prometheus.MustRegister(openstackOperationsLatency) - prometheus.MustRegister(openstackAPIRequestErrors) + legacyregistry.MustRegister(openstackOperationsLatency) + legacyregistry.MustRegister(openstackAPIRequestErrors) }) } diff --git a/pkg/controller/.import-restrictions b/pkg/controller/.import-restrictions index 38333aea14e..8bceedaca31 100644 --- a/pkg/controller/.import-restrictions +++ b/pkg/controller/.import-restrictions @@ -104,6 +104,7 @@ "github.com/robfig/cron", "github.com/spf13/pflag", "github.com/stretchr/testify/assert", + "github.com/stretchr/testify/mock", "github.com/stretchr/testify/require", "github.com/google/gofuzz", "github.com/golang/protobuf/ptypes/wrappers", @@ -163,6 +164,7 @@ "k8s.io/client-go/util/flowcontrol", "k8s.io/client-go/util/retry", "k8s.io/client-go/util/workqueue", + "k8s.io/client-go/util/testing", "k8s.io/client-go/transport" ] }, diff --git a/pkg/controller/nodelifecycle/BUILD b/pkg/controller/nodelifecycle/BUILD index 8d767087bcb..f61c2aec6a8 100644 --- a/pkg/controller/nodelifecycle/BUILD +++ b/pkg/controller/nodelifecycle/BUILD @@ -39,7 +39,8 @@ go_library( "//staging/src/k8s.io/client-go/tools/record:go_default_library", "//staging/src/k8s.io/client-go/util/flowcontrol:go_default_library", "//staging/src/k8s.io/client-go/util/workqueue:go_default_library", - "//vendor/github.com/prometheus/client_golang/prometheus:go_default_library", + "//staging/src/k8s.io/component-base/metrics:go_default_library", + "//staging/src/k8s.io/component-base/metrics/legacyregistry:go_default_library", "//vendor/k8s.io/klog:go_default_library", ], ) diff --git a/pkg/controller/nodelifecycle/metrics.go b/pkg/controller/nodelifecycle/metrics.go index ae61266c8ad..9314af04291 100644 --- a/pkg/controller/nodelifecycle/metrics.go +++ b/pkg/controller/nodelifecycle/metrics.go @@ -19,7 +19,8 @@ package nodelifecycle import ( "sync" - "github.com/prometheus/client_golang/prometheus" + "k8s.io/component-base/metrics" + "k8s.io/component-base/metrics/legacyregistry" ) const ( @@ -31,35 +32,39 @@ const ( ) var ( - zoneHealth = prometheus.NewGaugeVec( - prometheus.GaugeOpts{ - Subsystem: nodeControllerSubsystem, - Name: zoneHealthStatisticKey, - Help: "Gauge measuring percentage of healthy nodes per zone.", + zoneHealth = metrics.NewGaugeVec( + &metrics.GaugeOpts{ + Subsystem: nodeControllerSubsystem, + Name: zoneHealthStatisticKey, + Help: "Gauge measuring percentage of healthy nodes per zone.", + StabilityLevel: metrics.ALPHA, }, []string{"zone"}, ) - zoneSize = prometheus.NewGaugeVec( - prometheus.GaugeOpts{ - Subsystem: nodeControllerSubsystem, - Name: zoneSizeKey, - Help: "Gauge measuring number of registered Nodes per zones.", + zoneSize = metrics.NewGaugeVec( + &metrics.GaugeOpts{ + Subsystem: nodeControllerSubsystem, + Name: zoneSizeKey, + Help: "Gauge measuring number of registered Nodes per zones.", + StabilityLevel: metrics.ALPHA, }, []string{"zone"}, ) - unhealthyNodes = prometheus.NewGaugeVec( - prometheus.GaugeOpts{ - Subsystem: nodeControllerSubsystem, - Name: zoneNoUnhealthyNodesKey, - Help: "Gauge measuring number of not Ready Nodes per zones.", + unhealthyNodes = metrics.NewGaugeVec( + &metrics.GaugeOpts{ + Subsystem: nodeControllerSubsystem, + Name: zoneNoUnhealthyNodesKey, + Help: "Gauge measuring number of not Ready Nodes per zones.", + StabilityLevel: metrics.ALPHA, }, []string{"zone"}, ) - evictionsNumber = prometheus.NewCounterVec( - prometheus.CounterOpts{ - Subsystem: nodeControllerSubsystem, - Name: evictionsNumberKey, - Help: "Number of Node evictions that happened since current instance of NodeController started.", + evictionsNumber = metrics.NewCounterVec( + &metrics.CounterOpts{ + Subsystem: nodeControllerSubsystem, + Name: evictionsNumberKey, + Help: "Number of Node evictions that happened since current instance of NodeController started.", + StabilityLevel: metrics.ALPHA, }, []string{"zone"}, ) @@ -70,9 +75,9 @@ var registerMetrics sync.Once // Register the metrics that are to be monitored. func Register() { registerMetrics.Do(func() { - prometheus.MustRegister(zoneHealth) - prometheus.MustRegister(zoneSize) - prometheus.MustRegister(unhealthyNodes) - prometheus.MustRegister(evictionsNumber) + legacyregistry.MustRegister(zoneHealth) + legacyregistry.MustRegister(zoneSize) + legacyregistry.MustRegister(unhealthyNodes) + legacyregistry.MustRegister(evictionsNumber) }) } diff --git a/pkg/controller/volume/attachdetach/metrics/BUILD b/pkg/controller/volume/attachdetach/metrics/BUILD index c1efd8ca811..1b13127dcab 100644 --- a/pkg/controller/volume/attachdetach/metrics/BUILD +++ b/pkg/controller/volume/attachdetach/metrics/BUILD @@ -12,6 +12,8 @@ go_library( "//pkg/volume/util:go_default_library", "//staging/src/k8s.io/apimachinery/pkg/labels:go_default_library", "//staging/src/k8s.io/client-go/listers/core/v1:go_default_library", + "//staging/src/k8s.io/component-base/metrics:go_default_library", + "//staging/src/k8s.io/component-base/metrics/legacyregistry:go_default_library", "//vendor/github.com/prometheus/client_golang/prometheus:go_default_library", "//vendor/k8s.io/klog:go_default_library", ], diff --git a/pkg/controller/volume/attachdetach/metrics/metrics.go b/pkg/controller/volume/attachdetach/metrics/metrics.go index 53800f0fed1..d5bca329a94 100644 --- a/pkg/controller/volume/attachdetach/metrics/metrics.go +++ b/pkg/controller/volume/attachdetach/metrics/metrics.go @@ -21,8 +21,11 @@ import ( "sync" "github.com/prometheus/client_golang/prometheus" + "k8s.io/apimachinery/pkg/labels" corelisters "k8s.io/client-go/listers/core/v1" + "k8s.io/component-base/metrics" + "k8s.io/component-base/metrics/legacyregistry" "k8s.io/klog" "k8s.io/kubernetes/pkg/controller/volume/attachdetach/cache" "k8s.io/kubernetes/pkg/controller/volume/attachdetach/util" @@ -43,10 +46,12 @@ var ( "Number of volumes in A/D Controller", []string{"plugin_name", "state"}, nil) - forcedDetachMetricCounter = prometheus.NewCounter( - prometheus.CounterOpts{ - Name: "attachdetach_controller_forced_detaches", - Help: "Number of times the A/D Controller performed a forced detach"}) + forcedDetachMetricCounter = metrics.NewCounter( + &metrics.CounterOpts{ + Name: "attachdetach_controller_forced_detaches", + Help: "Number of times the A/D Controller performed a forced detach", + StabilityLevel: metrics.ALPHA, + }) ) var registerMetrics sync.Once @@ -58,13 +63,13 @@ func Register(pvcLister corelisters.PersistentVolumeClaimLister, dsw cache.DesiredStateOfWorld, pluginMgr *volume.VolumePluginMgr) { registerMetrics.Do(func() { - prometheus.MustRegister(newAttachDetachStateCollector(pvcLister, + legacyregistry.RawMustRegister(newAttachDetachStateCollector(pvcLister, podLister, pvLister, asw, dsw, pluginMgr)) - prometheus.MustRegister(forcedDetachMetricCounter) + legacyregistry.MustRegister(forcedDetachMetricCounter) }) } diff --git a/pkg/controller/volume/persistentvolume/metrics/BUILD b/pkg/controller/volume/persistentvolume/metrics/BUILD index 54c222ec798..e4461663d19 100644 --- a/pkg/controller/volume/persistentvolume/metrics/BUILD +++ b/pkg/controller/volume/persistentvolume/metrics/BUILD @@ -8,6 +8,8 @@ go_library( deps = [ "//pkg/volume/util:go_default_library", "//staging/src/k8s.io/api/core/v1:go_default_library", + "//staging/src/k8s.io/component-base/metrics:go_default_library", + "//staging/src/k8s.io/component-base/metrics/legacyregistry:go_default_library", "//vendor/github.com/prometheus/client_golang/prometheus:go_default_library", "//vendor/k8s.io/klog:go_default_library", ], diff --git a/pkg/controller/volume/persistentvolume/metrics/metrics.go b/pkg/controller/volume/persistentvolume/metrics/metrics.go index bb66fe22422..629745ddf57 100644 --- a/pkg/controller/volume/persistentvolume/metrics/metrics.go +++ b/pkg/controller/volume/persistentvolume/metrics/metrics.go @@ -21,7 +21,10 @@ import ( "time" "github.com/prometheus/client_golang/prometheus" + v1 "k8s.io/api/core/v1" + "k8s.io/component-base/metrics" + "k8s.io/component-base/metrics/legacyregistry" "k8s.io/klog" metricutil "k8s.io/kubernetes/pkg/volume/util" ) @@ -56,8 +59,8 @@ type PVCLister interface { // Register all metrics for pv controller. func Register(pvLister PVLister, pvcLister PVCLister) { registerMetrics.Do(func() { - prometheus.MustRegister(newPVAndPVCCountCollector(pvLister, pvcLister)) - prometheus.MustRegister(volumeOperationErrorsMetric) + legacyregistry.RawMustRegister(newPVAndPVCCountCollector(pvLister, pvcLister)) + legacyregistry.MustRegister(volumeOperationErrorsMetric) }) } @@ -92,10 +95,11 @@ var ( "Gauge measuring number of persistent volume claim currently unbound", []string{namespaceLabel}, nil) - volumeOperationErrorsMetric = prometheus.NewCounterVec( - prometheus.CounterOpts{ - Name: "volume_operation_total_errors", - Help: "Total volume operation erros", + volumeOperationErrorsMetric = metrics.NewCounterVec( + &metrics.CounterOpts{ + Name: "volume_operation_total_errors", + Help: "Total volume operation erros", + StabilityLevel: metrics.ALPHA, }, []string{"plugin_name", "operation_name"}) ) diff --git a/pkg/controller/volume/scheduling/BUILD b/pkg/controller/volume/scheduling/BUILD index 713999e74e3..6fb71631e09 100644 --- a/pkg/controller/volume/scheduling/BUILD +++ b/pkg/controller/volume/scheduling/BUILD @@ -26,6 +26,8 @@ go_library( "//staging/src/k8s.io/client-go/kubernetes:go_default_library", "//staging/src/k8s.io/client-go/listers/storage/v1:go_default_library", "//staging/src/k8s.io/client-go/tools/cache:go_default_library", + "//staging/src/k8s.io/component-base/metrics:go_default_library", + "//staging/src/k8s.io/component-base/metrics/legacyregistry:go_default_library", "//vendor/github.com/prometheus/client_golang/prometheus:go_default_library", "//vendor/k8s.io/klog:go_default_library", ], diff --git a/pkg/controller/volume/scheduling/scheduler_bind_cache_metrics.go b/pkg/controller/volume/scheduling/scheduler_bind_cache_metrics.go index 01a9f1c350c..fef24acb0bd 100644 --- a/pkg/controller/volume/scheduling/scheduler_bind_cache_metrics.go +++ b/pkg/controller/volume/scheduling/scheduler_bind_cache_metrics.go @@ -18,6 +18,9 @@ package scheduling import ( "github.com/prometheus/client_golang/prometheus" + + "k8s.io/component-base/metrics" + "k8s.io/component-base/metrics/legacyregistry" ) // VolumeSchedulerSubsystem - subsystem name used by scheduler @@ -25,30 +28,33 @@ const VolumeSchedulerSubsystem = "scheduler_volume" var ( // VolumeBindingRequestSchedulerBinderCache tracks the number of volume binder cache operations. - VolumeBindingRequestSchedulerBinderCache = prometheus.NewCounterVec( - prometheus.CounterOpts{ - Subsystem: VolumeSchedulerSubsystem, - Name: "binder_cache_requests_total", - Help: "Total number for request volume binding cache", + VolumeBindingRequestSchedulerBinderCache = metrics.NewCounterVec( + &metrics.CounterOpts{ + Subsystem: VolumeSchedulerSubsystem, + Name: "binder_cache_requests_total", + Help: "Total number for request volume binding cache", + StabilityLevel: metrics.ALPHA, }, []string{"operation"}, ) // VolumeSchedulingStageLatency tracks the latency of volume scheduling operations. - VolumeSchedulingStageLatency = prometheus.NewHistogramVec( - prometheus.HistogramOpts{ - Subsystem: VolumeSchedulerSubsystem, - Name: "scheduling_duration_seconds", - Help: "Volume scheduling stage latency", - Buckets: prometheus.ExponentialBuckets(1000, 2, 15), + VolumeSchedulingStageLatency = metrics.NewHistogramVec( + &metrics.HistogramOpts{ + Subsystem: VolumeSchedulerSubsystem, + Name: "scheduling_duration_seconds", + Help: "Volume scheduling stage latency", + Buckets: prometheus.ExponentialBuckets(1000, 2, 15), + StabilityLevel: metrics.ALPHA, }, []string{"operation"}, ) // VolumeSchedulingStageFailed tracks the number of failed volume scheduling operations. - VolumeSchedulingStageFailed = prometheus.NewCounterVec( - prometheus.CounterOpts{ - Subsystem: VolumeSchedulerSubsystem, - Name: "scheduling_stage_error_total", - Help: "Volume scheduling stage error count", + VolumeSchedulingStageFailed = metrics.NewCounterVec( + &metrics.CounterOpts{ + Subsystem: VolumeSchedulerSubsystem, + Name: "scheduling_stage_error_total", + Help: "Volume scheduling stage error count", + StabilityLevel: metrics.ALPHA, }, []string{"operation"}, ) @@ -57,7 +63,7 @@ var ( // RegisterVolumeSchedulingMetrics is used for scheduler, because the volume binding cache is a library // used by scheduler process. func RegisterVolumeSchedulingMetrics() { - prometheus.MustRegister(VolumeBindingRequestSchedulerBinderCache) - prometheus.MustRegister(VolumeSchedulingStageLatency) - prometheus.MustRegister(VolumeSchedulingStageFailed) + legacyregistry.MustRegister(VolumeBindingRequestSchedulerBinderCache) + legacyregistry.MustRegister(VolumeSchedulingStageLatency) + legacyregistry.MustRegister(VolumeSchedulingStageFailed) } diff --git a/pkg/kubelet/certificate/BUILD b/pkg/kubelet/certificate/BUILD index 5c85202a4b7..d61c8184961 100644 --- a/pkg/kubelet/certificate/BUILD +++ b/pkg/kubelet/certificate/BUILD @@ -26,7 +26,8 @@ go_library( "//staging/src/k8s.io/client-go/rest:go_default_library", "//staging/src/k8s.io/client-go/util/certificate:go_default_library", "//staging/src/k8s.io/client-go/util/connrotation:go_default_library", - "//vendor/github.com/prometheus/client_golang/prometheus:go_default_library", + "//staging/src/k8s.io/component-base/metrics:go_default_library", + "//staging/src/k8s.io/component-base/metrics/legacyregistry:go_default_library", "//vendor/k8s.io/klog:go_default_library", ], ) diff --git a/pkg/kubelet/certificate/kubelet.go b/pkg/kubelet/certificate/kubelet.go index cf106c84e10..cea55f0c34e 100644 --- a/pkg/kubelet/certificate/kubelet.go +++ b/pkg/kubelet/certificate/kubelet.go @@ -24,14 +24,14 @@ import ( "net" "sort" - "github.com/prometheus/client_golang/prometheus" - certificates "k8s.io/api/certificates/v1beta1" "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/types" clientset "k8s.io/client-go/kubernetes" certificatesclient "k8s.io/client-go/kubernetes/typed/certificates/v1beta1" "k8s.io/client-go/util/certificate" + compbasemetrics "k8s.io/component-base/metrics" + "k8s.io/component-base/metrics/legacyregistry" kubeletconfig "k8s.io/kubernetes/pkg/kubelet/apis/config" "k8s.io/kubernetes/pkg/kubelet/metrics" ) @@ -52,15 +52,16 @@ func NewKubeletServerCertificateManager(kubeClient clientset.Interface, kubeCfg if err != nil { return nil, fmt.Errorf("failed to initialize server certificate store: %v", err) } - var certificateExpiration = prometheus.NewGauge( - prometheus.GaugeOpts{ - Namespace: metrics.KubeletSubsystem, - Subsystem: "certificate_manager", - Name: "server_expiration_seconds", - Help: "Gauge of the lifetime of a certificate. The value is the date the certificate will expire in seconds since January 1, 1970 UTC.", + var certificateExpiration = compbasemetrics.NewGauge( + &compbasemetrics.GaugeOpts{ + Namespace: metrics.KubeletSubsystem, + Subsystem: "certificate_manager", + Name: "server_expiration_seconds", + Help: "Gauge of the lifetime of a certificate. The value is the date the certificate will expire in seconds since January 1, 1970 UTC.", + StabilityLevel: compbasemetrics.ALPHA, }, ) - prometheus.MustRegister(certificateExpiration) + legacyregistry.MustRegister(certificateExpiration) getTemplate := func() *x509.CertificateRequest { hostnames, ips := addressesToHostnamesAndIPs(getAddresses()) @@ -166,15 +167,16 @@ func NewKubeletClientCertificateManager( if err != nil { return nil, fmt.Errorf("failed to initialize client certificate store: %v", err) } - var certificateExpiration = prometheus.NewGauge( - prometheus.GaugeOpts{ - Namespace: metrics.KubeletSubsystem, - Subsystem: "certificate_manager", - Name: "client_expiration_seconds", - Help: "Gauge of the lifetime of a certificate. The value is the date the certificate will expire in seconds since January 1, 1970 UTC.", + var certificateExpiration = compbasemetrics.NewGauge( + &compbasemetrics.GaugeOpts{ + Namespace: metrics.KubeletSubsystem, + Subsystem: "certificate_manager", + Name: "client_expiration_seconds", + Help: "Gauge of the lifetime of a certificate. The value is the date the certificate will expire in seconds since January 1, 1970 UTC.", + StabilityLevel: compbasemetrics.ALPHA, }, ) - prometheus.Register(certificateExpiration) + legacyregistry.Register(certificateExpiration) m, err := certificate.NewManager(&certificate.Config{ ClientFn: clientFn, diff --git a/pkg/kubelet/dockershim/metrics/BUILD b/pkg/kubelet/dockershim/metrics/BUILD index 3ea7d9321d5..23d95719007 100644 --- a/pkg/kubelet/dockershim/metrics/BUILD +++ b/pkg/kubelet/dockershim/metrics/BUILD @@ -5,7 +5,11 @@ go_library( srcs = ["metrics.go"], importpath = "k8s.io/kubernetes/pkg/kubelet/dockershim/metrics", visibility = ["//visibility:public"], - deps = ["//vendor/github.com/prometheus/client_golang/prometheus:go_default_library"], + deps = [ + "//staging/src/k8s.io/component-base/metrics:go_default_library", + "//staging/src/k8s.io/component-base/metrics/legacyregistry:go_default_library", + "//vendor/github.com/prometheus/client_golang/prometheus:go_default_library", + ], ) filegroup( diff --git a/pkg/kubelet/dockershim/metrics/metrics.go b/pkg/kubelet/dockershim/metrics/metrics.go index fb6433daa8b..228856e988e 100644 --- a/pkg/kubelet/dockershim/metrics/metrics.go +++ b/pkg/kubelet/dockershim/metrics/metrics.go @@ -21,6 +21,9 @@ import ( "time" "github.com/prometheus/client_golang/prometheus" + + "k8s.io/component-base/metrics" + "k8s.io/component-base/metrics/legacyregistry" ) const ( @@ -49,79 +52,87 @@ const ( var ( // DockerOperationsLatency collects operation latency numbers by operation // type. - DockerOperationsLatency = prometheus.NewHistogramVec( - prometheus.HistogramOpts{ - Subsystem: kubeletSubsystem, - Name: DockerOperationsLatencyKey, - Help: "Latency in seconds of Docker operations. Broken down by operation type.", - Buckets: prometheus.DefBuckets, + DockerOperationsLatency = metrics.NewHistogramVec( + &metrics.HistogramOpts{ + Subsystem: kubeletSubsystem, + Name: DockerOperationsLatencyKey, + Help: "Latency in seconds of Docker operations. Broken down by operation type.", + Buckets: prometheus.DefBuckets, + StabilityLevel: metrics.ALPHA, }, []string{"operation_type"}, ) // DockerOperations collects operation counts by operation type. - DockerOperations = prometheus.NewCounterVec( - prometheus.CounterOpts{ - Subsystem: kubeletSubsystem, - Name: DockerOperationsKey, - Help: "Cumulative number of Docker operations by operation type.", + DockerOperations = metrics.NewCounterVec( + &metrics.CounterOpts{ + Subsystem: kubeletSubsystem, + Name: DockerOperationsKey, + Help: "Cumulative number of Docker operations by operation type.", + StabilityLevel: metrics.ALPHA, }, []string{"operation_type"}, ) // DockerOperationsErrors collects operation errors by operation // type. - DockerOperationsErrors = prometheus.NewCounterVec( - prometheus.CounterOpts{ - Subsystem: kubeletSubsystem, - Name: DockerOperationsErrorsKey, - Help: "Cumulative number of Docker operation errors by operation type.", + DockerOperationsErrors = metrics.NewCounterVec( + &metrics.CounterOpts{ + Subsystem: kubeletSubsystem, + Name: DockerOperationsErrorsKey, + Help: "Cumulative number of Docker operation errors by operation type.", + StabilityLevel: metrics.ALPHA, }, []string{"operation_type"}, ) // DockerOperationsTimeout collects operation timeouts by operation type. - DockerOperationsTimeout = prometheus.NewCounterVec( - prometheus.CounterOpts{ - Subsystem: kubeletSubsystem, - Name: DockerOperationsTimeoutKey, - Help: "Cumulative number of Docker operation timeout by operation type.", + DockerOperationsTimeout = metrics.NewCounterVec( + &metrics.CounterOpts{ + Subsystem: kubeletSubsystem, + Name: DockerOperationsTimeoutKey, + Help: "Cumulative number of Docker operation timeout by operation type.", + StabilityLevel: metrics.ALPHA, }, []string{"operation_type"}, ) // DeprecatedDockerOperationsLatency collects operation latency numbers by operation // type. - DeprecatedDockerOperationsLatency = prometheus.NewSummaryVec( - prometheus.SummaryOpts{ - Subsystem: kubeletSubsystem, - Name: DeprecatedDockerOperationsLatencyKey, - Help: "(Deprecated) Latency in microseconds of Docker operations. Broken down by operation type.", + DeprecatedDockerOperationsLatency = metrics.NewSummaryVec( + &metrics.SummaryOpts{ + Subsystem: kubeletSubsystem, + Name: DeprecatedDockerOperationsLatencyKey, + Help: "(Deprecated) Latency in microseconds of Docker operations. Broken down by operation type.", + StabilityLevel: metrics.ALPHA, }, []string{"operation_type"}, ) // DeprecatedDockerOperations collects operation counts by operation type. - DeprecatedDockerOperations = prometheus.NewCounterVec( - prometheus.CounterOpts{ - Subsystem: kubeletSubsystem, - Name: DeprecatedDockerOperationsKey, - Help: "(Deprecated) Cumulative number of Docker operations by operation type.", + DeprecatedDockerOperations = metrics.NewCounterVec( + &metrics.CounterOpts{ + Subsystem: kubeletSubsystem, + Name: DeprecatedDockerOperationsKey, + Help: "(Deprecated) Cumulative number of Docker operations by operation type.", + StabilityLevel: metrics.ALPHA, }, []string{"operation_type"}, ) // DeprecatedDockerOperationsErrors collects operation errors by operation // type. - DeprecatedDockerOperationsErrors = prometheus.NewCounterVec( - prometheus.CounterOpts{ - Subsystem: kubeletSubsystem, - Name: DeprecatedDockerOperationsErrorsKey, - Help: "(Deprecated) Cumulative number of Docker operation errors by operation type.", + DeprecatedDockerOperationsErrors = metrics.NewCounterVec( + &metrics.CounterOpts{ + Subsystem: kubeletSubsystem, + Name: DeprecatedDockerOperationsErrorsKey, + Help: "(Deprecated) Cumulative number of Docker operation errors by operation type.", + StabilityLevel: metrics.ALPHA, }, []string{"operation_type"}, ) // DeprecatedDockerOperationsTimeout collects operation timeouts by operation type. - DeprecatedDockerOperationsTimeout = prometheus.NewCounterVec( - prometheus.CounterOpts{ - Subsystem: kubeletSubsystem, - Name: DeprecatedDockerOperationsTimeoutKey, - Help: "(Deprecated) Cumulative number of Docker operation timeout by operation type.", + DeprecatedDockerOperationsTimeout = metrics.NewCounterVec( + &metrics.CounterOpts{ + Subsystem: kubeletSubsystem, + Name: DeprecatedDockerOperationsTimeoutKey, + Help: "(Deprecated) Cumulative number of Docker operation timeout by operation type.", + StabilityLevel: metrics.ALPHA, }, []string{"operation_type"}, ) @@ -132,14 +143,14 @@ var registerMetrics sync.Once // Register all metrics. func Register() { registerMetrics.Do(func() { - prometheus.MustRegister(DockerOperationsLatency) - prometheus.MustRegister(DockerOperations) - prometheus.MustRegister(DockerOperationsErrors) - prometheus.MustRegister(DockerOperationsTimeout) - prometheus.MustRegister(DeprecatedDockerOperationsLatency) - prometheus.MustRegister(DeprecatedDockerOperations) - prometheus.MustRegister(DeprecatedDockerOperationsErrors) - prometheus.MustRegister(DeprecatedDockerOperationsTimeout) + legacyregistry.MustRegister(DockerOperationsLatency) + legacyregistry.MustRegister(DockerOperations) + legacyregistry.MustRegister(DockerOperationsErrors) + legacyregistry.MustRegister(DockerOperationsTimeout) + legacyregistry.MustRegister(DeprecatedDockerOperationsLatency) + legacyregistry.MustRegister(DeprecatedDockerOperations) + legacyregistry.MustRegister(DeprecatedDockerOperationsErrors) + legacyregistry.MustRegister(DeprecatedDockerOperationsTimeout) }) } diff --git a/pkg/kubelet/dockershim/network/metrics/BUILD b/pkg/kubelet/dockershim/network/metrics/BUILD index a473e363aca..dabd4dee307 100644 --- a/pkg/kubelet/dockershim/network/metrics/BUILD +++ b/pkg/kubelet/dockershim/network/metrics/BUILD @@ -5,7 +5,11 @@ go_library( srcs = ["metrics.go"], importpath = "k8s.io/kubernetes/pkg/kubelet/dockershim/network/metrics", visibility = ["//visibility:public"], - deps = ["//vendor/github.com/prometheus/client_golang/prometheus:go_default_library"], + deps = [ + "//staging/src/k8s.io/component-base/metrics:go_default_library", + "//staging/src/k8s.io/component-base/metrics/legacyregistry:go_default_library", + "//vendor/github.com/prometheus/client_golang/prometheus:go_default_library", + ], ) filegroup( diff --git a/pkg/kubelet/dockershim/network/metrics/metrics.go b/pkg/kubelet/dockershim/network/metrics/metrics.go index 3e2247ba144..8ecd02132c3 100644 --- a/pkg/kubelet/dockershim/network/metrics/metrics.go +++ b/pkg/kubelet/dockershim/network/metrics/metrics.go @@ -21,6 +21,9 @@ import ( "time" "github.com/prometheus/client_golang/prometheus" + + "k8s.io/component-base/metrics" + "k8s.io/component-base/metrics/legacyregistry" ) const ( @@ -38,23 +41,25 @@ const ( var ( // NetworkPluginOperationsLatency collects operation latency numbers by operation // type. - NetworkPluginOperationsLatency = prometheus.NewHistogramVec( - prometheus.HistogramOpts{ - Subsystem: kubeletSubsystem, - Name: NetworkPluginOperationsLatencyKey, - Help: "Latency in seconds of network plugin operations. Broken down by operation type.", - Buckets: prometheus.DefBuckets, + NetworkPluginOperationsLatency = metrics.NewHistogramVec( + &metrics.HistogramOpts{ + Subsystem: kubeletSubsystem, + Name: NetworkPluginOperationsLatencyKey, + Help: "Latency in seconds of network plugin operations. Broken down by operation type.", + Buckets: prometheus.DefBuckets, + StabilityLevel: metrics.ALPHA, }, []string{"operation_type"}, ) // DeprecatedNetworkPluginOperationsLatency collects operation latency numbers by operation // type. - DeprecatedNetworkPluginOperationsLatency = prometheus.NewSummaryVec( - prometheus.SummaryOpts{ - Subsystem: kubeletSubsystem, - Name: DeprecatedNetworkPluginOperationsLatencyKey, - Help: "(Deprecated) Latency in microseconds of network plugin operations. Broken down by operation type.", + DeprecatedNetworkPluginOperationsLatency = metrics.NewSummaryVec( + &metrics.SummaryOpts{ + Subsystem: kubeletSubsystem, + Name: DeprecatedNetworkPluginOperationsLatencyKey, + Help: "(Deprecated) Latency in microseconds of network plugin operations. Broken down by operation type.", + StabilityLevel: metrics.ALPHA, }, []string{"operation_type"}, ) @@ -65,8 +70,8 @@ var registerMetrics sync.Once // Register all metrics. func Register() { registerMetrics.Do(func() { - prometheus.MustRegister(NetworkPluginOperationsLatency) - prometheus.MustRegister(DeprecatedNetworkPluginOperationsLatency) + legacyregistry.MustRegister(NetworkPluginOperationsLatency) + legacyregistry.MustRegister(DeprecatedNetworkPluginOperationsLatency) }) } diff --git a/pkg/kubelet/eviction/eviction_manager.go b/pkg/kubelet/eviction/eviction_manager.go index c571fa2045d..2b1d4d34412 100644 --- a/pkg/kubelet/eviction/eviction_manager.go +++ b/pkg/kubelet/eviction/eviction_manager.go @@ -25,7 +25,7 @@ import ( "k8s.io/klog" - "k8s.io/api/core/v1" + v1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/api/resource" "k8s.io/apimachinery/pkg/util/clock" utilfeature "k8s.io/apiserver/pkg/util/feature" @@ -377,6 +377,7 @@ func (m *managerImpl) synchronize(diskInfoProvider DiskInfoProvider, podFunc Act } message, annotations := evictionMessage(resourceToReclaim, pod, statsFunc) if m.evictPod(pod, gracePeriodOverride, message, annotations) { + metrics.Evictions.WithLabelValues(string(thresholdToReclaim.Signal)).Inc() return []*v1.Pod{pod} } } diff --git a/pkg/kubelet/kuberuntime/BUILD b/pkg/kubelet/kuberuntime/BUILD index f6da95bb979..dcc437c3149 100644 --- a/pkg/kubelet/kuberuntime/BUILD +++ b/pkg/kubelet/kuberuntime/BUILD @@ -128,11 +128,11 @@ go_test( "//staging/src/k8s.io/apiserver/pkg/util/feature:go_default_library", "//staging/src/k8s.io/client-go/util/flowcontrol:go_default_library", "//staging/src/k8s.io/component-base/featuregate/testing:go_default_library", + "//staging/src/k8s.io/component-base/metrics/legacyregistry:go_default_library", "//staging/src/k8s.io/cri-api/pkg/apis/runtime/v1alpha2:go_default_library", "//staging/src/k8s.io/cri-api/pkg/apis/testing:go_default_library", "//vendor/github.com/golang/mock/gomock:go_default_library", "//vendor/github.com/google/cadvisor/info/v1:go_default_library", - "//vendor/github.com/prometheus/client_golang/prometheus:go_default_library", "//vendor/github.com/stretchr/testify/assert:go_default_library", "//vendor/github.com/stretchr/testify/require:go_default_library", "//vendor/k8s.io/utils/pointer:go_default_library", diff --git a/pkg/kubelet/kuberuntime/instrumented_services_test.go b/pkg/kubelet/kuberuntime/instrumented_services_test.go index a70c22bc11f..91a1e5be23d 100644 --- a/pkg/kubelet/kuberuntime/instrumented_services_test.go +++ b/pkg/kubelet/kuberuntime/instrumented_services_test.go @@ -22,16 +22,17 @@ import ( "testing" "time" - "github.com/prometheus/client_golang/prometheus" "github.com/stretchr/testify/assert" + + "k8s.io/component-base/metrics/legacyregistry" runtimeapi "k8s.io/cri-api/pkg/apis/runtime/v1alpha2" "k8s.io/kubernetes/pkg/kubelet/metrics" ) func TestRecordOperation(t *testing.T) { - prometheus.MustRegister(metrics.RuntimeOperations) - prometheus.MustRegister(metrics.RuntimeOperationsDuration) - prometheus.MustRegister(metrics.RuntimeOperationsErrors) + legacyregistry.MustRegister(metrics.RuntimeOperations) + legacyregistry.MustRegister(metrics.RuntimeOperationsDuration) + legacyregistry.MustRegister(metrics.RuntimeOperationsErrors) temporalServer := "127.0.0.1:1234" l, err := net.Listen("tcp", temporalServer) @@ -40,7 +41,8 @@ func TestRecordOperation(t *testing.T) { prometheusURL := "http://" + temporalServer + "/metrics" mux := http.NewServeMux() - mux.Handle("/metrics", prometheus.Handler()) + //lint:ignore SA1019 ignore deprecated warning until we move off of global registries + mux.Handle("/metrics", legacyregistry.Handler()) server := &http.Server{ Addr: temporalServer, Handler: mux, diff --git a/pkg/kubelet/metrics/BUILD b/pkg/kubelet/metrics/BUILD index 2c6224cbde5..176015f2e39 100644 --- a/pkg/kubelet/metrics/BUILD +++ b/pkg/kubelet/metrics/BUILD @@ -15,6 +15,8 @@ go_library( "//staging/src/k8s.io/api/core/v1:go_default_library", "//staging/src/k8s.io/apimachinery/pkg/types:go_default_library", "//staging/src/k8s.io/apiserver/pkg/util/feature:go_default_library", + "//staging/src/k8s.io/component-base/metrics:go_default_library", + "//staging/src/k8s.io/component-base/metrics/legacyregistry:go_default_library", "//vendor/github.com/prometheus/client_golang/prometheus:go_default_library", "//vendor/k8s.io/klog:go_default_library", ], diff --git a/pkg/kubelet/metrics/metrics.go b/pkg/kubelet/metrics/metrics.go index 4a6b8617d05..66cb16c3e23 100644 --- a/pkg/kubelet/metrics/metrics.go +++ b/pkg/kubelet/metrics/metrics.go @@ -18,6 +18,8 @@ package metrics import ( "fmt" + "k8s.io/component-base/metrics" + "k8s.io/component-base/metrics/legacyregistry" "sync" "time" @@ -41,6 +43,7 @@ const ( PLEGRelistDurationKey = "pleg_relist_duration_seconds" PLEGDiscardEventsKey = "pleg_discard_events" PLEGRelistIntervalKey = "pleg_relist_interval_seconds" + EvictionsKey = "evictions" EvictionStatsAgeKey = "eviction_stats_age_seconds" DeprecatedPodWorkerLatencyKey = "pod_worker_latency_microseconds" DeprecatedPodStartLatencyKey = "pod_start_latency_microseconds" @@ -85,274 +88,375 @@ const ( ) var ( - NodeName = prometheus.NewGaugeVec( - prometheus.GaugeOpts{ - Subsystem: KubeletSubsystem, - Name: NodeNameKey, - Help: "The node's name. The count is always 1.", + // NodeName is a Gauge that tracks the ode's name. The count is always 1. + NodeName = metrics.NewGaugeVec( + &metrics.GaugeOpts{ + Subsystem: KubeletSubsystem, + Name: NodeNameKey, + Help: "The node's name. The count is always 1.", + StabilityLevel: metrics.ALPHA, }, []string{NodeLabelKey}, ) - ContainersPerPodCount = prometheus.NewHistogram( - prometheus.HistogramOpts{ - Subsystem: KubeletSubsystem, - Name: "containers_per_pod_count", - Help: "The number of containers per pod.", - Buckets: prometheus.DefBuckets, - }, - ) - PodWorkerDuration = prometheus.NewHistogramVec( - prometheus.HistogramOpts{ - Subsystem: KubeletSubsystem, - Name: PodWorkerDurationKey, - Help: "Duration in seconds to sync a single pod. Broken down by operation type: create, update, or sync", - Buckets: prometheus.DefBuckets, + // ContainersPerPodCount is a Counter that tracks the number of containers per pod. + ContainersPerPodCount = metrics.NewHistogram( + &metrics.HistogramOpts{ + Subsystem: KubeletSubsystem, + Name: "containers_per_pod_count", + Help: "The number of containers per pod.", + Buckets: prometheus.DefBuckets, + StabilityLevel: metrics.ALPHA, + }, + ) + // PodWorkerDuration is a Histogram that tracks the duration (in seconds) in takes to sync a single pod. + // Broken down by the operation type. + PodWorkerDuration = metrics.NewHistogramVec( + &metrics.HistogramOpts{ + Subsystem: KubeletSubsystem, + Name: PodWorkerDurationKey, + Help: "Duration in seconds to sync a single pod. Broken down by operation type: create, update, or sync", + Buckets: prometheus.DefBuckets, + StabilityLevel: metrics.ALPHA, }, []string{"operation_type"}, ) - PodStartDuration = prometheus.NewHistogram( - prometheus.HistogramOpts{ - Subsystem: KubeletSubsystem, - Name: PodStartDurationKey, - Help: "Duration in seconds for a single pod to go from pending to running.", - Buckets: prometheus.DefBuckets, - }, - ) - CgroupManagerDuration = prometheus.NewHistogramVec( - prometheus.HistogramOpts{ - Subsystem: KubeletSubsystem, - Name: CgroupManagerOperationsKey, - Help: "Duration in seconds for cgroup manager operations. Broken down by method.", - Buckets: prometheus.DefBuckets, + // PodStartDuration is a Histogram that tracks the duration (in seconds) it takes for a single pod to go from pending to running. + PodStartDuration = metrics.NewHistogram( + &metrics.HistogramOpts{ + Subsystem: KubeletSubsystem, + Name: PodStartDurationKey, + Help: "Duration in seconds for a single pod to go from pending to running.", + Buckets: prometheus.DefBuckets, + StabilityLevel: metrics.ALPHA, + }, + ) + // CgroupManagerDuration is a Histogram that tracks the duration (in seconds) it takes for cgroup manager operations to complete. + // Broken down by method. + CgroupManagerDuration = metrics.NewHistogramVec( + &metrics.HistogramOpts{ + Subsystem: KubeletSubsystem, + Name: CgroupManagerOperationsKey, + Help: "Duration in seconds for cgroup manager operations. Broken down by method.", + Buckets: prometheus.DefBuckets, + StabilityLevel: metrics.ALPHA, }, []string{"operation_type"}, ) - PodWorkerStartDuration = prometheus.NewHistogram( - prometheus.HistogramOpts{ - Subsystem: KubeletSubsystem, - Name: PodWorkerStartDurationKey, - Help: "Duration in seconds from seeing a pod to starting a worker.", - Buckets: prometheus.DefBuckets, - }, - ) - PLEGRelistDuration = prometheus.NewHistogram( - prometheus.HistogramOpts{ - Subsystem: KubeletSubsystem, - Name: PLEGRelistDurationKey, - Help: "Duration in seconds for relisting pods in PLEG.", - Buckets: prometheus.DefBuckets, - }, - ) - PLEGDiscardEvents = prometheus.NewCounterVec( - prometheus.CounterOpts{ - Subsystem: KubeletSubsystem, - Name: PLEGDiscardEventsKey, - Help: "The number of discard events in PLEG.", + // PodWorkerStartDuration is a Histogram that tracks the duration (in seconds) it takes from seeing a pod to starting a worker. + PodWorkerStartDuration = metrics.NewHistogram( + &metrics.HistogramOpts{ + Subsystem: KubeletSubsystem, + Name: PodWorkerStartDurationKey, + Help: "Duration in seconds from seeing a pod to starting a worker.", + Buckets: prometheus.DefBuckets, + StabilityLevel: metrics.ALPHA, + }, + ) + // PLEGRelistDuration is a Histogram that tracks the duration (in seconds) it takes for relisting pods in the Kubelet's + // Pod Lifecycle Event Generator (PLEG). + PLEGRelistDuration = metrics.NewHistogram( + &metrics.HistogramOpts{ + Subsystem: KubeletSubsystem, + Name: PLEGRelistDurationKey, + Help: "Duration in seconds for relisting pods in PLEG.", + Buckets: prometheus.DefBuckets, + StabilityLevel: metrics.ALPHA, + }, + ) + // PLEGDiscardEvents is a Histogram that tracks the duration (in seconds) it takes for discarding events in the Kubelet's + // Pod Lifecycle Event Generator (PLEG). + PLEGDiscardEvents = metrics.NewCounterVec( + &metrics.CounterOpts{ + Subsystem: KubeletSubsystem, + Name: PLEGDiscardEventsKey, + Help: "The number of discard events in PLEG.", + StabilityLevel: metrics.ALPHA, }, []string{}, ) - PLEGRelistInterval = prometheus.NewHistogram( - prometheus.HistogramOpts{ - Subsystem: KubeletSubsystem, - Name: PLEGRelistIntervalKey, - Help: "Interval in seconds between relisting in PLEG.", - Buckets: prometheus.DefBuckets, + // PLEGRelistInterval is a Histogram that tracks the intervals (in seconds) between relisting in the Kubelet's + // Pod Lifecycle Event Generator (PLEG). + PLEGRelistInterval = metrics.NewHistogram( + &metrics.HistogramOpts{ + Subsystem: KubeletSubsystem, + Name: PLEGRelistIntervalKey, + Help: "Interval in seconds between relisting in PLEG.", + Buckets: prometheus.DefBuckets, + StabilityLevel: metrics.ALPHA, + }, + ) + // RuntimeOperations is a Counter that tracks the cumulative number of remote runtime operations. + // Broken down by operation type. + RuntimeOperations = metrics.NewCounterVec( + &metrics.CounterOpts{ + Subsystem: KubeletSubsystem, + Name: RuntimeOperationsKey, + Help: "Cumulative number of runtime operations by operation type.", + StabilityLevel: metrics.ALPHA, }, + []string{"operation_type"}, ) - // Metrics of remote runtime operations. - RuntimeOperations = prometheus.NewCounterVec( - prometheus.CounterOpts{ - Subsystem: KubeletSubsystem, - Name: RuntimeOperationsKey, - Help: "Cumulative number of runtime operations by operation type.", + // RuntimeOperationsDuration is a Histogram that tracks the duration (in seconds) for remote runtime operations to complete. + // Broken down by operation type. + RuntimeOperationsDuration = metrics.NewHistogramVec( + &metrics.HistogramOpts{ + Subsystem: KubeletSubsystem, + Name: RuntimeOperationsDurationKey, + Help: "Duration in seconds of runtime operations. Broken down by operation type.", + Buckets: prometheus.DefBuckets, + StabilityLevel: metrics.ALPHA, }, []string{"operation_type"}, ) - RuntimeOperationsDuration = prometheus.NewHistogramVec( - prometheus.HistogramOpts{ - Subsystem: KubeletSubsystem, - Name: RuntimeOperationsDurationKey, - Help: "Duration in seconds of runtime operations. Broken down by operation type.", - Buckets: prometheus.DefBuckets, + // RuntimeOperationsErrors is a Counter that tracks the cumulative number of remote runtime operations errors. + // Broken down by operation type. + RuntimeOperationsErrors = metrics.NewCounterVec( + &metrics.CounterOpts{ + Subsystem: KubeletSubsystem, + Name: RuntimeOperationsErrorsKey, + Help: "Cumulative number of runtime operation errors by operation type.", + StabilityLevel: metrics.ALPHA, }, []string{"operation_type"}, ) - RuntimeOperationsErrors = prometheus.NewCounterVec( - prometheus.CounterOpts{ - Subsystem: KubeletSubsystem, - Name: RuntimeOperationsErrorsKey, - Help: "Cumulative number of runtime operation errors by operation type.", + // Evictions is a Counter that tracks the cumulative number of pod evictions initiated by the kubelet. + // Broken down by eviction signal. + Evictions = metrics.NewCounterVec( + &metrics.CounterOpts{ + Subsystem: KubeletSubsystem, + Name: EvictionsKey, + Help: "Cumulative number of pod evictions by eviction signal", + StabilityLevel: metrics.ALPHA, }, - []string{"operation_type"}, + []string{"eviction_signal"}, ) - EvictionStatsAge = prometheus.NewHistogramVec( - prometheus.HistogramOpts{ - Subsystem: KubeletSubsystem, - Name: EvictionStatsAgeKey, - Help: "Time between when stats are collected, and when pod is evicted based on those stats by eviction signal", - Buckets: prometheus.DefBuckets, + // EvictionStatsAge is a Histogram that tracks the time (in seconds) between when stats are collected and when a pod is evicted + // based on those stats. Broken down by eviction signal. + EvictionStatsAge = metrics.NewHistogramVec( + &metrics.HistogramOpts{ + Subsystem: KubeletSubsystem, + Name: EvictionStatsAgeKey, + Help: "Time between when stats are collected, and when pod is evicted based on those stats by eviction signal", + Buckets: prometheus.DefBuckets, + StabilityLevel: metrics.ALPHA, }, []string{"eviction_signal"}, ) - DevicePluginRegistrationCount = prometheus.NewCounterVec( - prometheus.CounterOpts{ - Subsystem: KubeletSubsystem, - Name: DevicePluginRegistrationCountKey, - Help: "Cumulative number of device plugin registrations. Broken down by resource name.", + // DevicePluginRegistrationCount is a Counter that tracks the cumulative number of device plugin registrations. + // Broken down by resource name. + DevicePluginRegistrationCount = metrics.NewCounterVec( + &metrics.CounterOpts{ + Subsystem: KubeletSubsystem, + Name: DevicePluginRegistrationCountKey, + Help: "Cumulative number of device plugin registrations. Broken down by resource name.", + StabilityLevel: metrics.ALPHA, }, []string{"resource_name"}, ) - DevicePluginAllocationDuration = prometheus.NewHistogramVec( - prometheus.HistogramOpts{ - Subsystem: KubeletSubsystem, - Name: DevicePluginAllocationDurationKey, - Help: "Duration in seconds to serve a device plugin Allocation request. Broken down by resource name.", - Buckets: prometheus.DefBuckets, + // DevicePluginAllocationDuration is a Histogram that tracks the duration (in seconds) to serve a device plugin allocation request. + // Broken down by resource name. + DevicePluginAllocationDuration = metrics.NewHistogramVec( + &metrics.HistogramOpts{ + Subsystem: KubeletSubsystem, + Name: DevicePluginAllocationDurationKey, + Help: "Duration in seconds to serve a device plugin Allocation request. Broken down by resource name.", + Buckets: prometheus.DefBuckets, + StabilityLevel: metrics.ALPHA, }, []string{"resource_name"}, ) - - DeprecatedPodWorkerLatency = prometheus.NewSummaryVec( - prometheus.SummaryOpts{ - Subsystem: KubeletSubsystem, - Name: DeprecatedPodWorkerLatencyKey, - Help: "(Deprecated) Latency in microseconds to sync a single pod. Broken down by operation type: create, update, or sync", + // DeprecatedPodWorkerLatency is a Summary that tracks the latency (in microseconds) to sync a single pod. + // Broken down by operation type. This metric is deprecated. + DeprecatedPodWorkerLatency = metrics.NewSummaryVec( + &metrics.SummaryOpts{ + Subsystem: KubeletSubsystem, + Name: DeprecatedPodWorkerLatencyKey, + Help: "(Deprecated) Latency in microseconds to sync a single pod. Broken down by operation type: create, update, or sync", + StabilityLevel: metrics.ALPHA, }, []string{"operation_type"}, ) - DeprecatedPodStartLatency = prometheus.NewSummary( - prometheus.SummaryOpts{ - Subsystem: KubeletSubsystem, - Name: DeprecatedPodStartLatencyKey, - Help: "(Deprecated) Latency in microseconds for a single pod to go from pending to running.", - }, - ) - DeprecatedCgroupManagerLatency = prometheus.NewSummaryVec( - prometheus.SummaryOpts{ - Subsystem: KubeletSubsystem, - Name: DeprecatedCgroupManagerOperationsKey, - Help: "(Deprecated) Latency in microseconds for cgroup manager operations. Broken down by method.", + // DeprecatedPodStartLatency is a Summary that tracks the latency (in microseconds) for a single pod to go from pending to running. + // This metric is deprecated. + DeprecatedPodStartLatency = metrics.NewSummary( + &metrics.SummaryOpts{ + Subsystem: KubeletSubsystem, + Name: DeprecatedPodStartLatencyKey, + Help: "(Deprecated) Latency in microseconds for a single pod to go from pending to running.", + StabilityLevel: metrics.ALPHA, + }, + ) + // DeprecatedCgroupManagerLatency is a Summary that tracks the latency (in microseconds) for cgroup manager operations to complete. + // Broken down by operation type. This metric is deprecated. + DeprecatedCgroupManagerLatency = metrics.NewSummaryVec( + &metrics.SummaryOpts{ + Subsystem: KubeletSubsystem, + Name: DeprecatedCgroupManagerOperationsKey, + Help: "(Deprecated) Latency in microseconds for cgroup manager operations. Broken down by method.", + StabilityLevel: metrics.ALPHA, }, []string{"operation_type"}, ) - DeprecatedPodWorkerStartLatency = prometheus.NewSummary( - prometheus.SummaryOpts{ - Subsystem: KubeletSubsystem, - Name: DeprecatedPodWorkerStartLatencyKey, - Help: "(Deprecated) Latency in microseconds from seeing a pod to starting a worker.", - }, - ) - DeprecatedPLEGRelistLatency = prometheus.NewSummary( - prometheus.SummaryOpts{ - Subsystem: KubeletSubsystem, - Name: DeprecatedPLEGRelistLatencyKey, - Help: "(Deprecated) Latency in microseconds for relisting pods in PLEG.", - }, - ) - DeprecatedPLEGRelistInterval = prometheus.NewSummary( - prometheus.SummaryOpts{ - Subsystem: KubeletSubsystem, - Name: DeprecatedPLEGRelistIntervalKey, - Help: "(Deprecated) Interval in microseconds between relisting in PLEG.", - }, - ) - DeprecatedRuntimeOperations = prometheus.NewCounterVec( - prometheus.CounterOpts{ - Subsystem: KubeletSubsystem, - Name: DeprecatedRuntimeOperationsKey, - Help: "(Deprecated) Cumulative number of runtime operations by operation type.", + // DeprecatedPodWorkerStartLatency is a Summary that tracks the latency (in microseconds) from seeing a pod to starting a worker. + // This metric is deprecated. + DeprecatedPodWorkerStartLatency = metrics.NewSummary( + &metrics.SummaryOpts{ + Subsystem: KubeletSubsystem, + Name: DeprecatedPodWorkerStartLatencyKey, + Help: "(Deprecated) Latency in microseconds from seeing a pod to starting a worker.", + StabilityLevel: metrics.ALPHA, + }, + ) + // DeprecatedPLEGRelistLatency is a Summary that tracks the latency (in microseconds) for relisting pods in PLEG. + // This metric is deprecated. + DeprecatedPLEGRelistLatency = metrics.NewSummary( + &metrics.SummaryOpts{ + Subsystem: KubeletSubsystem, + Name: DeprecatedPLEGRelistLatencyKey, + Help: "(Deprecated) Latency in microseconds for relisting pods in PLEG.", + StabilityLevel: metrics.ALPHA, + }, + ) + // DeprecatedPLEGRelistInterval is a Summary that tracks the interval (in microseconds) between relistings in PLEG. + // This metric is deprecated. + DeprecatedPLEGRelistInterval = metrics.NewSummary( + &metrics.SummaryOpts{ + Subsystem: KubeletSubsystem, + Name: DeprecatedPLEGRelistIntervalKey, + Help: "(Deprecated) Interval in microseconds between relisting in PLEG.", + StabilityLevel: metrics.ALPHA, + }, + ) + // DeprecatedRuntimeOperations is a Counter that tracks the cumulative number of remote runtime operations. + // Broken down by operation type. This metric is deprecated. + DeprecatedRuntimeOperations = metrics.NewCounterVec( + &metrics.CounterOpts{ + Subsystem: KubeletSubsystem, + Name: DeprecatedRuntimeOperationsKey, + Help: "(Deprecated) Cumulative number of runtime operations by operation type.", + StabilityLevel: metrics.ALPHA, }, []string{"operation_type"}, ) - DeprecatedRuntimeOperationsLatency = prometheus.NewSummaryVec( - prometheus.SummaryOpts{ - Subsystem: KubeletSubsystem, - Name: DeprecatedRuntimeOperationsLatencyKey, - Help: "(Deprecated) Latency in microseconds of runtime operations. Broken down by operation type.", + // DeprecatedRuntimeOperationsLatency is a Summary that tracks the latency (in microseconds) of remote runtime operations + // to complete. Broken down by operation type. This metric is deprecated. + DeprecatedRuntimeOperationsLatency = metrics.NewSummaryVec( + &metrics.SummaryOpts{ + Subsystem: KubeletSubsystem, + Name: DeprecatedRuntimeOperationsLatencyKey, + Help: "(Deprecated) Latency in microseconds of runtime operations. Broken down by operation type.", + StabilityLevel: metrics.ALPHA, }, []string{"operation_type"}, ) - DeprecatedRuntimeOperationsErrors = prometheus.NewCounterVec( - prometheus.CounterOpts{ - Subsystem: KubeletSubsystem, - Name: DeprecatedRuntimeOperationsErrorsKey, - Help: "(Deprecated) Cumulative number of runtime operation errors by operation type.", + // DeprecatedRuntimeOperationsErrors is a Counter that tracks the cumulative number of remote runtime operation errors. + // Broken down by operation type. This metric is deprecated. + DeprecatedRuntimeOperationsErrors = metrics.NewCounterVec( + &metrics.CounterOpts{ + Subsystem: KubeletSubsystem, + Name: DeprecatedRuntimeOperationsErrorsKey, + Help: "(Deprecated) Cumulative number of runtime operation errors by operation type.", + StabilityLevel: metrics.ALPHA, }, []string{"operation_type"}, ) - DeprecatedEvictionStatsAge = prometheus.NewSummaryVec( - prometheus.SummaryOpts{ - Subsystem: KubeletSubsystem, - Name: DeprecatedEvictionStatsAgeKey, - Help: "(Deprecated) Time between when stats are collected, and when pod is evicted based on those stats by eviction signal", + // DeprecatedEvictionStatsAge is a Summary that tracks the time (in microseconds) between when stats are collected and when a pod + // is evicted based on those stats. Broken down by eviction signal. This metric is deprecated. + DeprecatedEvictionStatsAge = metrics.NewSummaryVec( + &metrics.SummaryOpts{ + Subsystem: KubeletSubsystem, + Name: DeprecatedEvictionStatsAgeKey, + Help: "(Deprecated) Time between when stats are collected, and when pod is evicted based on those stats by eviction signal", + StabilityLevel: metrics.ALPHA, }, []string{"eviction_signal"}, ) - DeprecatedDevicePluginRegistrationCount = prometheus.NewCounterVec( - prometheus.CounterOpts{ - Subsystem: KubeletSubsystem, - Name: DeprecatedDevicePluginRegistrationCountKey, - Help: "(Deprecated) Cumulative number of device plugin registrations. Broken down by resource name.", + // DeprecatedDevicePluginRegistrationCount is a Counter that tracks the cumulative number of device plugin registrations. + // Broken down by resource name. This metric is deprecated. + DeprecatedDevicePluginRegistrationCount = metrics.NewCounterVec( + &metrics.CounterOpts{ + Subsystem: KubeletSubsystem, + Name: DeprecatedDevicePluginRegistrationCountKey, + Help: "(Deprecated) Cumulative number of device plugin registrations. Broken down by resource name.", + StabilityLevel: metrics.ALPHA, }, []string{"resource_name"}, ) - DeprecatedDevicePluginAllocationLatency = prometheus.NewSummaryVec( - prometheus.SummaryOpts{ - Subsystem: KubeletSubsystem, - Name: DeprecatedDevicePluginAllocationLatencyKey, - Help: "(Deprecated) Latency in microseconds to serve a device plugin Allocation request. Broken down by resource name.", + // DeprecatedDevicePluginAllocationLatency is a Summary that tracks the latncy (in microseconds) for serving device plugin allocation requests. + // Broken down by resource name. This metric is deprecated. + DeprecatedDevicePluginAllocationLatency = metrics.NewSummaryVec( + &metrics.SummaryOpts{ + Subsystem: KubeletSubsystem, + Name: DeprecatedDevicePluginAllocationLatencyKey, + Help: "(Deprecated) Latency in microseconds to serve a device plugin Allocation request. Broken down by resource name.", + StabilityLevel: metrics.ALPHA, }, []string{"resource_name"}, ) // Metrics for node config - AssignedConfig = prometheus.NewGaugeVec( - prometheus.GaugeOpts{ - Subsystem: KubeletSubsystem, - Name: AssignedConfigKey, - Help: "The node's understanding of intended config. The count is always 1.", + // AssignedConfig is a Gauge that is set 1 if the Kubelet has a NodeConfig assigned. + AssignedConfig = metrics.NewGaugeVec( + &metrics.GaugeOpts{ + Subsystem: KubeletSubsystem, + Name: AssignedConfigKey, + Help: "The node's understanding of intended config. The count is always 1.", + StabilityLevel: metrics.ALPHA, }, []string{ConfigSourceLabelKey, ConfigUIDLabelKey, ConfigResourceVersionLabelKey, KubeletConfigKeyLabelKey}, ) - ActiveConfig = prometheus.NewGaugeVec( - prometheus.GaugeOpts{ - Subsystem: KubeletSubsystem, - Name: ActiveConfigKey, - Help: "The config source the node is actively using. The count is always 1.", + // ActiveConfig is a Gauge that is set to 1 if the Kubelet has an active NodeConfig. + ActiveConfig = metrics.NewGaugeVec( + &metrics.GaugeOpts{ + Subsystem: KubeletSubsystem, + Name: ActiveConfigKey, + Help: "The config source the node is actively using. The count is always 1.", + StabilityLevel: metrics.ALPHA, }, []string{ConfigSourceLabelKey, ConfigUIDLabelKey, ConfigResourceVersionLabelKey, KubeletConfigKeyLabelKey}, ) - LastKnownGoodConfig = prometheus.NewGaugeVec( - prometheus.GaugeOpts{ - Subsystem: KubeletSubsystem, - Name: LastKnownGoodConfigKey, - Help: "The config source the node will fall back to when it encounters certain errors. The count is always 1.", + // LastKnownGoodConfig is a Gauge that is set to 1 if the Kubelet has a NodeConfig it can fall back to if there + // are certain errors. + LastKnownGoodConfig = metrics.NewGaugeVec( + &metrics.GaugeOpts{ + Subsystem: KubeletSubsystem, + Name: LastKnownGoodConfigKey, + Help: "The config source the node will fall back to when it encounters certain errors. The count is always 1.", + StabilityLevel: metrics.ALPHA, }, []string{ConfigSourceLabelKey, ConfigUIDLabelKey, ConfigResourceVersionLabelKey, KubeletConfigKeyLabelKey}, ) - ConfigError = prometheus.NewGauge( - prometheus.GaugeOpts{ - Subsystem: KubeletSubsystem, - Name: ConfigErrorKey, - Help: "This metric is true (1) if the node is experiencing a configuration-related error, false (0) otherwise.", + // ConfigError is a Gauge that is set to 1 if the node is experiencing a configuration-related error. + ConfigError = metrics.NewGauge( + &metrics.GaugeOpts{ + Subsystem: KubeletSubsystem, + Name: ConfigErrorKey, + Help: "This metric is true (1) if the node is experiencing a configuration-related error, false (0) otherwise.", + StabilityLevel: metrics.ALPHA, }, ) - RunPodSandboxDuration = prometheus.NewHistogramVec( - prometheus.HistogramOpts{ + // RunPodSandboxDuration is a Histogram that tracks the duration (in seconds) it takes to run Pod Sandbox operations. + // Broken down by RuntimeClass. + RunPodSandboxDuration = metrics.NewHistogramVec( + &metrics.HistogramOpts{ Subsystem: KubeletSubsystem, Name: RunPodSandboxDurationKey, Help: "Duration in seconds of the run_podsandbox operations. Broken down by RuntimeClass.", // Use DefBuckets for now, will customize the buckets if necessary. - Buckets: prometheus.DefBuckets, + Buckets: prometheus.DefBuckets, + StabilityLevel: metrics.ALPHA, }, []string{"runtime_handler"}, ) - RunPodSandboxErrors = prometheus.NewCounterVec( - prometheus.CounterOpts{ - Subsystem: KubeletSubsystem, - Name: RunPodSandboxErrorsKey, - Help: "Cumulative number of the run_podsandbox operation errors by RuntimeClass.", + // RunPodSandboxErrors is a Counter that tracks the cumulative number of Pod Sandbox operations errors. + // Broken down by RuntimeClass. + RunPodSandboxErrors = metrics.NewCounterVec( + &metrics.CounterOpts{ + Subsystem: KubeletSubsystem, + Name: RunPodSandboxErrorsKey, + Help: "Cumulative number of the run_podsandbox operation errors by RuntimeClass.", + StabilityLevel: metrics.ALPHA, }, []string{"runtime_handler"}, ) @@ -364,42 +468,43 @@ var registerMetrics sync.Once func Register(containerCache kubecontainer.RuntimeCache, collectors ...prometheus.Collector) { // Register the metrics. registerMetrics.Do(func() { - prometheus.MustRegister(NodeName) - prometheus.MustRegister(PodWorkerDuration) - prometheus.MustRegister(PodStartDuration) - prometheus.MustRegister(CgroupManagerDuration) - prometheus.MustRegister(PodWorkerStartDuration) - prometheus.MustRegister(ContainersPerPodCount) - prometheus.MustRegister(newPodAndContainerCollector(containerCache)) - prometheus.MustRegister(PLEGRelistDuration) - prometheus.MustRegister(PLEGDiscardEvents) - prometheus.MustRegister(PLEGRelistInterval) - prometheus.MustRegister(RuntimeOperations) - prometheus.MustRegister(RuntimeOperationsDuration) - prometheus.MustRegister(RuntimeOperationsErrors) - prometheus.MustRegister(EvictionStatsAge) - prometheus.MustRegister(DevicePluginRegistrationCount) - prometheus.MustRegister(DevicePluginAllocationDuration) - prometheus.MustRegister(DeprecatedPodWorkerLatency) - prometheus.MustRegister(DeprecatedPodStartLatency) - prometheus.MustRegister(DeprecatedCgroupManagerLatency) - prometheus.MustRegister(DeprecatedPodWorkerStartLatency) - prometheus.MustRegister(DeprecatedPLEGRelistLatency) - prometheus.MustRegister(DeprecatedPLEGRelistInterval) - prometheus.MustRegister(DeprecatedRuntimeOperations) - prometheus.MustRegister(DeprecatedRuntimeOperationsLatency) - prometheus.MustRegister(DeprecatedRuntimeOperationsErrors) - prometheus.MustRegister(DeprecatedEvictionStatsAge) - prometheus.MustRegister(DeprecatedDevicePluginRegistrationCount) - prometheus.MustRegister(DeprecatedDevicePluginAllocationLatency) + legacyregistry.MustRegister(NodeName) + legacyregistry.MustRegister(PodWorkerDuration) + legacyregistry.MustRegister(PodStartDuration) + legacyregistry.MustRegister(CgroupManagerDuration) + legacyregistry.MustRegister(PodWorkerStartDuration) + legacyregistry.MustRegister(ContainersPerPodCount) + legacyregistry.RawMustRegister(newPodAndContainerCollector(containerCache)) + legacyregistry.MustRegister(PLEGRelistDuration) + legacyregistry.MustRegister(PLEGDiscardEvents) + legacyregistry.MustRegister(PLEGRelistInterval) + legacyregistry.MustRegister(RuntimeOperations) + legacyregistry.MustRegister(RuntimeOperationsDuration) + legacyregistry.MustRegister(RuntimeOperationsErrors) + legacyregistry.MustRegister(Evictions) + legacyregistry.MustRegister(EvictionStatsAge) + legacyregistry.MustRegister(DevicePluginRegistrationCount) + legacyregistry.MustRegister(DevicePluginAllocationDuration) + legacyregistry.MustRegister(DeprecatedPodWorkerLatency) + legacyregistry.MustRegister(DeprecatedPodStartLatency) + legacyregistry.MustRegister(DeprecatedCgroupManagerLatency) + legacyregistry.MustRegister(DeprecatedPodWorkerStartLatency) + legacyregistry.MustRegister(DeprecatedPLEGRelistLatency) + legacyregistry.MustRegister(DeprecatedPLEGRelistInterval) + legacyregistry.MustRegister(DeprecatedRuntimeOperations) + legacyregistry.MustRegister(DeprecatedRuntimeOperationsLatency) + legacyregistry.MustRegister(DeprecatedRuntimeOperationsErrors) + legacyregistry.MustRegister(DeprecatedEvictionStatsAge) + legacyregistry.MustRegister(DeprecatedDevicePluginRegistrationCount) + legacyregistry.MustRegister(DeprecatedDevicePluginAllocationLatency) if utilfeature.DefaultFeatureGate.Enabled(features.DynamicKubeletConfig) { - prometheus.MustRegister(AssignedConfig) - prometheus.MustRegister(ActiveConfig) - prometheus.MustRegister(LastKnownGoodConfig) - prometheus.MustRegister(ConfigError) + legacyregistry.MustRegister(AssignedConfig) + legacyregistry.MustRegister(ActiveConfig) + legacyregistry.MustRegister(LastKnownGoodConfig) + legacyregistry.MustRegister(ConfigError) } for _, collector := range collectors { - prometheus.MustRegister(collector) + legacyregistry.RawMustRegister(collector) } }) } diff --git a/pkg/kubelet/prober/prober_manager.go b/pkg/kubelet/prober/prober_manager.go index a19d5caad99..5a62fbe838f 100644 --- a/pkg/kubelet/prober/prober_manager.go +++ b/pkg/kubelet/prober/prober_manager.go @@ -38,7 +38,7 @@ var ProberResults = metrics.NewCounterVec( &metrics.CounterOpts{ Subsystem: "prober", Name: "probe_total", - Help: "Cumulative number of a liveness, readiness or startup probe for a container by result.", + Help: "Cumulative number of a liveness or readiness probe for a container by result.", StabilityLevel: metrics.ALPHA, }, []string{"probe_type", diff --git a/pkg/kubelet/server/metrics/BUILD b/pkg/kubelet/server/metrics/BUILD index 6d22a4d7fc6..f8fdebf05e4 100644 --- a/pkg/kubelet/server/metrics/BUILD +++ b/pkg/kubelet/server/metrics/BUILD @@ -10,6 +10,8 @@ go_library( srcs = ["metrics.go"], importpath = "k8s.io/kubernetes/pkg/kubelet/server/metrics", deps = [ + "//staging/src/k8s.io/component-base/metrics:go_default_library", + "//staging/src/k8s.io/component-base/metrics/legacyregistry:go_default_library", "//vendor/github.com/prometheus/client_golang/prometheus:go_default_library", ], ) diff --git a/pkg/kubelet/server/metrics/metrics.go b/pkg/kubelet/server/metrics/metrics.go index 1694ac9bc5c..f5c7ad5f633 100644 --- a/pkg/kubelet/server/metrics/metrics.go +++ b/pkg/kubelet/server/metrics/metrics.go @@ -21,6 +21,9 @@ import ( "time" "github.com/prometheus/client_golang/prometheus" + + "k8s.io/component-base/metrics" + "k8s.io/component-base/metrics/legacyregistry" ) const ( @@ -29,11 +32,12 @@ const ( var ( // HTTPRequests tracks the number of the http requests received since the server started. - HTTPRequests = prometheus.NewCounterVec( - prometheus.CounterOpts{ - Subsystem: kubeletSubsystem, - Name: "http_requests_total", - Help: "Number of the http requests received since the server started", + HTTPRequests = metrics.NewCounterVec( + &metrics.CounterOpts{ + Subsystem: kubeletSubsystem, + Name: "http_requests_total", + Help: "Number of the http requests received since the server started", + StabilityLevel: metrics.ALPHA, }, // server_type aims to differentiate the readonly server and the readwrite server. // long_running marks whether the request is long-running or not. @@ -41,22 +45,24 @@ var ( []string{"method", "path", "server_type", "long_running"}, ) // HTTPRequestsDuration tracks the duration in seconds to serve http requests. - HTTPRequestsDuration = prometheus.NewHistogramVec( - prometheus.HistogramOpts{ + HTTPRequestsDuration = metrics.NewHistogramVec( + &metrics.HistogramOpts{ Subsystem: kubeletSubsystem, Name: "http_requests_duration_seconds", Help: "Duration in seconds to serve http requests", // Use DefBuckets for now, will customize the buckets if necessary. - Buckets: prometheus.DefBuckets, + Buckets: prometheus.DefBuckets, + StabilityLevel: metrics.ALPHA, }, []string{"method", "path", "server_type", "long_running"}, ) // HTTPInflightRequests tracks the number of the inflight http requests. - HTTPInflightRequests = prometheus.NewGaugeVec( - prometheus.GaugeOpts{ - Subsystem: kubeletSubsystem, - Name: "http_inflight_requests", - Help: "Number of the inflight http requests", + HTTPInflightRequests = metrics.NewGaugeVec( + &metrics.GaugeOpts{ + Subsystem: kubeletSubsystem, + Name: "http_inflight_requests", + Help: "Number of the inflight http requests", + StabilityLevel: metrics.ALPHA, }, []string{"method", "path", "server_type", "long_running"}, ) @@ -67,9 +73,9 @@ var registerMetrics sync.Once // Register all metrics. func Register() { registerMetrics.Do(func() { - prometheus.MustRegister(HTTPRequests) - prometheus.MustRegister(HTTPRequestsDuration) - prometheus.MustRegister(HTTPInflightRequests) + legacyregistry.MustRegister(HTTPRequests) + legacyregistry.MustRegister(HTTPRequestsDuration) + legacyregistry.MustRegister(HTTPInflightRequests) }) } diff --git a/pkg/kubelet/volumemanager/metrics/BUILD b/pkg/kubelet/volumemanager/metrics/BUILD index 522eb010844..0ac9ca9fb1b 100644 --- a/pkg/kubelet/volumemanager/metrics/BUILD +++ b/pkg/kubelet/volumemanager/metrics/BUILD @@ -9,6 +9,7 @@ go_library( "//pkg/kubelet/volumemanager/cache:go_default_library", "//pkg/volume:go_default_library", "//pkg/volume/util:go_default_library", + "//staging/src/k8s.io/component-base/metrics/legacyregistry:go_default_library", "//vendor/github.com/prometheus/client_golang/prometheus:go_default_library", "//vendor/k8s.io/klog:go_default_library", ], diff --git a/pkg/kubelet/volumemanager/metrics/metrics.go b/pkg/kubelet/volumemanager/metrics/metrics.go index 2536eb55917..86f800b0bc4 100644 --- a/pkg/kubelet/volumemanager/metrics/metrics.go +++ b/pkg/kubelet/volumemanager/metrics/metrics.go @@ -17,6 +17,7 @@ limitations under the License. package metrics import ( + "k8s.io/component-base/metrics/legacyregistry" "sync" "github.com/prometheus/client_golang/prometheus" @@ -59,7 +60,7 @@ func (v volumeCount) add(state, plugin string) { // Register registers Volume Manager metrics. func Register(asw cache.ActualStateOfWorld, dsw cache.DesiredStateOfWorld, pluginMgr *volume.VolumePluginMgr) { registerMetrics.Do(func() { - prometheus.MustRegister(&totalVolumesCollector{asw, dsw, pluginMgr}) + legacyregistry.RawMustRegister(&totalVolumesCollector{asw, dsw, pluginMgr}) }) } diff --git a/pkg/proxy/metrics/BUILD b/pkg/proxy/metrics/BUILD index f3166915150..32c501a411a 100644 --- a/pkg/proxy/metrics/BUILD +++ b/pkg/proxy/metrics/BUILD @@ -5,7 +5,11 @@ go_library( srcs = ["metrics.go"], importpath = "k8s.io/kubernetes/pkg/proxy/metrics", visibility = ["//visibility:public"], - deps = ["//vendor/github.com/prometheus/client_golang/prometheus:go_default_library"], + deps = [ + "//staging/src/k8s.io/component-base/metrics:go_default_library", + "//staging/src/k8s.io/component-base/metrics/legacyregistry:go_default_library", + "//vendor/github.com/prometheus/client_golang/prometheus:go_default_library", + ], ) filegroup( diff --git a/pkg/proxy/metrics/metrics.go b/pkg/proxy/metrics/metrics.go index 54d7f0a4ca4..11d8aea2294 100644 --- a/pkg/proxy/metrics/metrics.go +++ b/pkg/proxy/metrics/metrics.go @@ -17,6 +17,8 @@ limitations under the License. package metrics import ( + "k8s.io/component-base/metrics" + "k8s.io/component-base/metrics/legacyregistry" "sync" "time" @@ -27,32 +29,35 @@ const kubeProxySubsystem = "kubeproxy" var ( // SyncProxyRulesLatency is the latency of one round of kube-proxy syncing proxy rules. - SyncProxyRulesLatency = prometheus.NewHistogram( - prometheus.HistogramOpts{ - Subsystem: kubeProxySubsystem, - Name: "sync_proxy_rules_duration_seconds", - Help: "SyncProxyRules latency in seconds", - Buckets: prometheus.ExponentialBuckets(0.001, 2, 15), + SyncProxyRulesLatency = metrics.NewHistogram( + &metrics.HistogramOpts{ + Subsystem: kubeProxySubsystem, + Name: "sync_proxy_rules_duration_seconds", + Help: "SyncProxyRules latency in seconds", + Buckets: prometheus.ExponentialBuckets(0.001, 2, 15), + StabilityLevel: metrics.ALPHA, }, ) // DeprecatedSyncProxyRulesLatency is the latency of one round of kube-proxy syncing proxy rules. - DeprecatedSyncProxyRulesLatency = prometheus.NewHistogram( - prometheus.HistogramOpts{ - Subsystem: kubeProxySubsystem, - Name: "sync_proxy_rules_latency_microseconds", - Help: "(Deprecated) SyncProxyRules latency in microseconds", - Buckets: prometheus.ExponentialBuckets(1000, 2, 15), + DeprecatedSyncProxyRulesLatency = metrics.NewHistogram( + &metrics.HistogramOpts{ + Subsystem: kubeProxySubsystem, + Name: "sync_proxy_rules_latency_microseconds", + Help: "(Deprecated) SyncProxyRules latency in microseconds", + Buckets: prometheus.ExponentialBuckets(1000, 2, 15), + StabilityLevel: metrics.ALPHA, }, ) // SyncProxyRulesLastTimestamp is the timestamp proxy rules were last // successfully synced. - SyncProxyRulesLastTimestamp = prometheus.NewGauge( - prometheus.GaugeOpts{ - Subsystem: kubeProxySubsystem, - Name: "sync_proxy_rules_last_timestamp_seconds", - Help: "The last time proxy rules were successfully synced", + SyncProxyRulesLastTimestamp = metrics.NewGauge( + &metrics.GaugeOpts{ + Subsystem: kubeProxySubsystem, + Name: "sync_proxy_rules_last_timestamp_seconds", + Help: "The last time proxy rules were successfully synced", + StabilityLevel: metrics.ALPHA, }, ) @@ -63,54 +68,73 @@ var ( // Note that the metrics is partially based on the time exported by the endpoints controller on // the master machine. The measurement may be inaccurate if there is a clock drift between the // node and master machine. - NetworkProgrammingLatency = prometheus.NewHistogram( - prometheus.HistogramOpts{ + NetworkProgrammingLatency = metrics.NewHistogram( + &metrics.HistogramOpts{ Subsystem: kubeProxySubsystem, Name: "network_programming_duration_seconds", Help: "In Cluster Network Programming Latency in seconds", - // TODO(mm4tt): Reevaluate buckets before 1.14 release. - // The last bucket will be [0.001s*2^20 ~= 17min, +inf) - Buckets: prometheus.ExponentialBuckets(0.001, 2, 20), + Buckets: merge( + prometheus.LinearBuckets(0.25, 0.25, 2), // 0.25s, 0.50s + prometheus.LinearBuckets(1, 1, 59), // 1s, 2s, 3s, ... 59s + prometheus.LinearBuckets(60, 5, 12), // 60s, 65s, 70s, ... 115s + prometheus.LinearBuckets(120, 30, 7), // 2min, 2.5min, 3min, ..., 5min + ), + StabilityLevel: metrics.ALPHA, }, ) // EndpointChangesPending is the number of pending endpoint changes that // have not yet been synced to the proxy. - EndpointChangesPending = prometheus.NewGauge( - prometheus.GaugeOpts{ - Subsystem: kubeProxySubsystem, - Name: "sync_proxy_rules_endpoint_changes_pending", - Help: "Pending proxy rules Endpoint changes", + EndpointChangesPending = metrics.NewGauge( + &metrics.GaugeOpts{ + Subsystem: kubeProxySubsystem, + Name: "sync_proxy_rules_endpoint_changes_pending", + Help: "Pending proxy rules Endpoint changes", + StabilityLevel: metrics.ALPHA, }, ) // EndpointChangesTotal is the number of endpoint changes that the proxy // has seen. - EndpointChangesTotal = prometheus.NewCounter( - prometheus.CounterOpts{ - Subsystem: kubeProxySubsystem, - Name: "sync_proxy_rules_endpoint_changes_total", - Help: "Cumulative proxy rules Endpoint changes", + EndpointChangesTotal = metrics.NewCounter( + &metrics.CounterOpts{ + Subsystem: kubeProxySubsystem, + Name: "sync_proxy_rules_endpoint_changes_total", + Help: "Cumulative proxy rules Endpoint changes", + StabilityLevel: metrics.ALPHA, }, ) // ServiceChangesPending is the number of pending service changes that // have not yet been synced to the proxy. - ServiceChangesPending = prometheus.NewGauge( - prometheus.GaugeOpts{ - Subsystem: kubeProxySubsystem, - Name: "sync_proxy_rules_service_changes_pending", - Help: "Pending proxy rules Service changes", + ServiceChangesPending = metrics.NewGauge( + &metrics.GaugeOpts{ + Subsystem: kubeProxySubsystem, + Name: "sync_proxy_rules_service_changes_pending", + Help: "Pending proxy rules Service changes", + StabilityLevel: metrics.ALPHA, }, ) // ServiceChangesTotal is the number of service changes that the proxy has // seen. - ServiceChangesTotal = prometheus.NewCounter( - prometheus.CounterOpts{ - Subsystem: kubeProxySubsystem, - Name: "sync_proxy_rules_service_changes_total", - Help: "Cumulative proxy rules Service changes", + ServiceChangesTotal = metrics.NewCounter( + &metrics.CounterOpts{ + Subsystem: kubeProxySubsystem, + Name: "sync_proxy_rules_service_changes_total", + Help: "Cumulative proxy rules Service changes", + StabilityLevel: metrics.ALPHA, + }, + ) + + // IptablesRestoreFailuresTotal is the number of iptables restore failures that the proxy has + // seen. + IptablesRestoreFailuresTotal = metrics.NewCounter( + &metrics.CounterOpts{ + Subsystem: kubeProxySubsystem, + Name: "sync_proxy_rules_iptables_restore_failures_total", + Help: "Cumulative proxy iptables restore failures", + StabilityLevel: metrics.ALPHA, }, ) ) @@ -120,14 +144,15 @@ var registerMetricsOnce sync.Once // RegisterMetrics registers kube-proxy metrics. func RegisterMetrics() { registerMetricsOnce.Do(func() { - prometheus.MustRegister(SyncProxyRulesLatency) - prometheus.MustRegister(DeprecatedSyncProxyRulesLatency) - prometheus.MustRegister(SyncProxyRulesLastTimestamp) - prometheus.MustRegister(NetworkProgrammingLatency) - prometheus.MustRegister(EndpointChangesPending) - prometheus.MustRegister(EndpointChangesTotal) - prometheus.MustRegister(ServiceChangesPending) - prometheus.MustRegister(ServiceChangesTotal) + legacyregistry.MustRegister(SyncProxyRulesLatency) + legacyregistry.MustRegister(DeprecatedSyncProxyRulesLatency) + legacyregistry.MustRegister(SyncProxyRulesLastTimestamp) + legacyregistry.MustRegister(NetworkProgrammingLatency) + legacyregistry.MustRegister(EndpointChangesPending) + legacyregistry.MustRegister(EndpointChangesTotal) + legacyregistry.MustRegister(ServiceChangesPending) + legacyregistry.MustRegister(ServiceChangesTotal) + legacyregistry.MustRegister(IptablesRestoreFailuresTotal) }) } @@ -140,3 +165,11 @@ func SinceInMicroseconds(start time.Time) float64 { func SinceInSeconds(start time.Time) float64 { return time.Since(start).Seconds() } + +func merge(slices ...[]float64) []float64 { + result := make([]float64, 1) + for _, s := range slices { + result = append(result, s...) + } + return result +} diff --git a/pkg/proxy/winkernel/BUILD b/pkg/proxy/winkernel/BUILD index c91644282e7..fa2e60e5c15 100644 --- a/pkg/proxy/winkernel/BUILD +++ b/pkg/proxy/winkernel/BUILD @@ -11,6 +11,8 @@ go_library( importpath = "k8s.io/kubernetes/pkg/proxy/winkernel", visibility = ["//visibility:public"], deps = [ + "//staging/src/k8s.io/component-base/metrics:go_default_library", + "//staging/src/k8s.io/component-base/metrics/legacyregistry:go_default_library", "//vendor/github.com/prometheus/client_golang/prometheus:go_default_library", ] + select({ "@io_bazel_rules_go//go/platform:windows": [ diff --git a/pkg/proxy/winkernel/metrics.go b/pkg/proxy/winkernel/metrics.go index 729cc5e626f..811e6e8aa06 100644 --- a/pkg/proxy/winkernel/metrics.go +++ b/pkg/proxy/winkernel/metrics.go @@ -17,6 +17,8 @@ limitations under the License. package winkernel import ( + "k8s.io/component-base/metrics" + "k8s.io/component-base/metrics/legacyregistry" "sync" "time" @@ -26,31 +28,34 @@ import ( const kubeProxySubsystem = "kubeproxy" var ( - SyncProxyRulesLatency = prometheus.NewHistogram( - prometheus.HistogramOpts{ - Subsystem: kubeProxySubsystem, - Name: "sync_proxy_rules_duration_seconds", - Help: "SyncProxyRules latency in seconds", - Buckets: prometheus.ExponentialBuckets(0.001, 2, 15), + SyncProxyRulesLatency = metrics.NewHistogram( + &metrics.HistogramOpts{ + Subsystem: kubeProxySubsystem, + Name: "sync_proxy_rules_duration_seconds", + Help: "SyncProxyRules latency in seconds", + Buckets: prometheus.ExponentialBuckets(0.001, 2, 15), + StabilityLevel: metrics.ALPHA, }, ) - DeprecatedSyncProxyRulesLatency = prometheus.NewHistogram( - prometheus.HistogramOpts{ - Subsystem: kubeProxySubsystem, - Name: "sync_proxy_rules_latency_microseconds", - Help: "(Deprecated) SyncProxyRules latency in microseconds", - Buckets: prometheus.ExponentialBuckets(1000, 2, 15), + DeprecatedSyncProxyRulesLatency = metrics.NewHistogram( + &metrics.HistogramOpts{ + Subsystem: kubeProxySubsystem, + Name: "sync_proxy_rules_latency_microseconds", + Help: "(Deprecated) SyncProxyRules latency in microseconds", + Buckets: prometheus.ExponentialBuckets(1000, 2, 15), + StabilityLevel: metrics.ALPHA, }, ) // SyncProxyRulesLastTimestamp is the timestamp proxy rules were last // successfully synced. - SyncProxyRulesLastTimestamp = prometheus.NewGauge( - prometheus.GaugeOpts{ - Subsystem: kubeProxySubsystem, - Name: "sync_proxy_rules_last_timestamp_seconds", - Help: "The last time proxy rules were successfully synced", + SyncProxyRulesLastTimestamp = metrics.NewGauge( + &metrics.GaugeOpts{ + Subsystem: kubeProxySubsystem, + Name: "sync_proxy_rules_last_timestamp_seconds", + Help: "The last time proxy rules were successfully synced", + StabilityLevel: metrics.ALPHA, }, ) ) @@ -59,9 +64,9 @@ var registerMetricsOnce sync.Once func RegisterMetrics() { registerMetricsOnce.Do(func() { - prometheus.MustRegister(SyncProxyRulesLatency) - prometheus.MustRegister(DeprecatedSyncProxyRulesLatency) - prometheus.MustRegister(SyncProxyRulesLastTimestamp) + legacyregistry.MustRegister(SyncProxyRulesLatency) + legacyregistry.MustRegister(DeprecatedSyncProxyRulesLatency) + legacyregistry.MustRegister(SyncProxyRulesLastTimestamp) }) } diff --git a/pkg/scheduler/internal/queue/multi_tenancy_scheduling_queue_test.go b/pkg/scheduler/internal/queue/multi_tenancy_scheduling_queue_test.go index 3e93d439a3f..478730750e9 100644 --- a/pkg/scheduler/internal/queue/multi_tenancy_scheduling_queue_test.go +++ b/pkg/scheduler/internal/queue/multi_tenancy_scheduling_queue_test.go @@ -1114,6 +1114,7 @@ func TestPendingPodsMetricWithMultiTenancy(t *testing.T) { total := 50 timestamp := time.Now() var pInfos = make([]*framework.PodInfo, 0, total) + metrics.Register() for i := 1; i <= total; i++ { p := &framework.PodInfo{ Pod: &v1.Pod{ @@ -1209,9 +1210,9 @@ func TestPendingPodsMetricWithMultiTenancy(t *testing.T) { } resetMetrics := func() { - metrics.ActivePods.Set(0) - metrics.BackoffPods.Set(0) - metrics.UnschedulablePods.Set(0) + metrics.ActivePods().Set(0) + metrics.BackoffPods().Set(0) + metrics.UnschedulablePods().Set(0) } for _, test := range tests { @@ -1226,7 +1227,7 @@ func TestPendingPodsMetricWithMultiTenancy(t *testing.T) { var activeNum, backoffNum, unschedulableNum float64 metricProto := &dto.Metric{} - if err := metrics.ActivePods.Write(metricProto); err != nil { + if err := metrics.ActivePods().Write(metricProto); err != nil { t.Errorf("error writing ActivePods metric: %v", err) } activeNum = metricProto.Gauge.GetValue() @@ -1234,7 +1235,7 @@ func TestPendingPodsMetricWithMultiTenancy(t *testing.T) { t.Errorf("ActivePods: Expected %v, got %v", test.expected[0], activeNum) } - if err := metrics.BackoffPods.Write(metricProto); err != nil { + if err := metrics.BackoffPods().Write(metricProto); err != nil { t.Errorf("error writing BackoffPods metric: %v", err) } backoffNum = metricProto.Gauge.GetValue() @@ -1242,7 +1243,7 @@ func TestPendingPodsMetricWithMultiTenancy(t *testing.T) { t.Errorf("BackoffPods: Expected %v, got %v", test.expected[1], backoffNum) } - if err := metrics.UnschedulablePods.Write(metricProto); err != nil { + if err := metrics.UnschedulablePods().Write(metricProto); err != nil { t.Errorf("error writing UnschedulablePods metric: %v", err) } unschedulableNum = metricProto.Gauge.GetValue() diff --git a/pkg/scheduler/internal/queue/scheduling_queue_test.go b/pkg/scheduler/internal/queue/scheduling_queue_test.go index 4a7fdecab0f..4244101715a 100644 --- a/pkg/scheduler/internal/queue/scheduling_queue_test.go +++ b/pkg/scheduler/internal/queue/scheduling_queue_test.go @@ -1,5 +1,6 @@ /* Copyright 2017 The Kubernetes Authors. +Copyright 2020 Authors of Arktos - file modified. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -1195,6 +1196,7 @@ func TestPodTimestamp(t *testing.T) { func TestPendingPodsMetric(t *testing.T) { total := 50 timestamp := time.Now() + metrics.Register() var pInfos = make([]*framework.PodInfo, 0, total) for i := 1; i <= total; i++ { p := &framework.PodInfo{ @@ -1290,9 +1292,9 @@ func TestPendingPodsMetric(t *testing.T) { } resetMetrics := func() { - metrics.ActivePods.Set(0) - metrics.BackoffPods.Set(0) - metrics.UnschedulablePods.Set(0) + metrics.ActivePods().Set(0) + metrics.BackoffPods().Set(0) + metrics.UnschedulablePods().Set(0) } for _, test := range tests { @@ -1307,7 +1309,7 @@ func TestPendingPodsMetric(t *testing.T) { var activeNum, backoffNum, unschedulableNum float64 metricProto := &dto.Metric{} - if err := metrics.ActivePods.Write(metricProto); err != nil { + if err := metrics.ActivePods().Write(metricProto); err != nil { t.Errorf("error writing ActivePods metric: %v", err) } activeNum = metricProto.Gauge.GetValue() @@ -1315,7 +1317,7 @@ func TestPendingPodsMetric(t *testing.T) { t.Errorf("ActivePods: Expected %v, got %v", test.expected[0], activeNum) } - if err := metrics.BackoffPods.Write(metricProto); err != nil { + if err := metrics.BackoffPods().Write(metricProto); err != nil { t.Errorf("error writing BackoffPods metric: %v", err) } backoffNum = metricProto.Gauge.GetValue() @@ -1323,7 +1325,7 @@ func TestPendingPodsMetric(t *testing.T) { t.Errorf("BackoffPods: Expected %v, got %v", test.expected[1], backoffNum) } - if err := metrics.UnschedulablePods.Write(metricProto); err != nil { + if err := metrics.UnschedulablePods().Write(metricProto); err != nil { t.Errorf("error writing UnschedulablePods metric: %v", err) } unschedulableNum = metricProto.Gauge.GetValue() diff --git a/pkg/scheduler/metrics/BUILD b/pkg/scheduler/metrics/BUILD index 41351c5042d..f698d44ad16 100644 --- a/pkg/scheduler/metrics/BUILD +++ b/pkg/scheduler/metrics/BUILD @@ -11,6 +11,8 @@ go_library( importpath = "k8s.io/kubernetes/pkg/scheduler/metrics", deps = [ "//pkg/controller/volume/scheduling:go_default_library", + "//staging/src/k8s.io/component-base/metrics:go_default_library", + "//staging/src/k8s.io/component-base/metrics/legacyregistry:go_default_library", "//vendor/github.com/prometheus/client_golang/prometheus:go_default_library", ], ) diff --git a/pkg/scheduler/metrics/metric_recorder.go b/pkg/scheduler/metrics/metric_recorder.go index 6c280365523..5534923fa15 100644 --- a/pkg/scheduler/metrics/metric_recorder.go +++ b/pkg/scheduler/metrics/metric_recorder.go @@ -17,7 +17,7 @@ limitations under the License. package metrics import ( - "github.com/prometheus/client_golang/prometheus" + "k8s.io/component-base/metrics" ) // MetricRecorder represents a metric recorder which takes action when the @@ -32,27 +32,27 @@ var _ MetricRecorder = &PendingPodsRecorder{} // PendingPodsRecorder is an implementation of MetricRecorder type PendingPodsRecorder struct { - recorder prometheus.Gauge + recorder metrics.GaugeMetric } // NewActivePodsRecorder returns ActivePods in a Prometheus metric fashion func NewActivePodsRecorder() *PendingPodsRecorder { return &PendingPodsRecorder{ - recorder: ActivePods, + recorder: ActivePods(), } } // NewUnschedulablePodsRecorder returns UnschedulablePods in a Prometheus metric fashion func NewUnschedulablePodsRecorder() *PendingPodsRecorder { return &PendingPodsRecorder{ - recorder: UnschedulablePods, + recorder: UnschedulablePods(), } } // NewBackoffPodsRecorder returns BackoffPods in a Prometheus metric fashion func NewBackoffPodsRecorder() *PendingPodsRecorder { return &PendingPodsRecorder{ - recorder: BackoffPods, + recorder: BackoffPods(), } } diff --git a/pkg/scheduler/metrics/metrics.go b/pkg/scheduler/metrics/metrics.go index 863f4dbab13..95687dbf35d 100644 --- a/pkg/scheduler/metrics/metrics.go +++ b/pkg/scheduler/metrics/metrics.go @@ -21,6 +21,9 @@ import ( "time" "github.com/prometheus/client_golang/prometheus" + + "k8s.io/component-base/metrics" + "k8s.io/component-base/metrics/legacyregistry" volumescheduling "k8s.io/kubernetes/pkg/controller/volume/scheduling" ) @@ -49,11 +52,12 @@ const ( // All the histogram based metrics have 1ms as size for the smallest bucket. var ( - scheduleAttempts = prometheus.NewCounterVec( - prometheus.CounterOpts{ - Subsystem: SchedulerSubsystem, - Name: "schedule_attempts_total", - Help: "Number of attempts to schedule pods, by the result. 'unschedulable' means a pod could not be scheduled, while 'error' means an internal scheduler problem.", + scheduleAttempts = metrics.NewCounterVec( + &metrics.CounterOpts{ + Subsystem: SchedulerSubsystem, + Name: "schedule_attempts_total", + Help: "Number of attempts to schedule pods, by the result. 'unschedulable' means a pod could not be scheduled, while 'error' means an internal scheduler problem.", + StabilityLevel: metrics.ALPHA, }, []string{"result"}) // PodScheduleSuccesses counts how many pods were scheduled. PodScheduleSuccesses = scheduleAttempts.With(prometheus.Labels{"result": "scheduled"}) @@ -61,148 +65,162 @@ var ( PodScheduleFailures = scheduleAttempts.With(prometheus.Labels{"result": "unschedulable"}) // PodScheduleErrors counts how many pods could not be scheduled due to a scheduler error. PodScheduleErrors = scheduleAttempts.With(prometheus.Labels{"result": "error"}) - SchedulingLatency = prometheus.NewSummaryVec( - prometheus.SummaryOpts{ + SchedulingLatency = metrics.NewSummaryVec( + &metrics.SummaryOpts{ Subsystem: SchedulerSubsystem, Name: SchedulingLatencyName, Help: "Scheduling latency in seconds split by sub-parts of the scheduling operation", // Make the sliding window of 5h. // TODO: The value for this should be based on some SLI definition (long term). - MaxAge: 5 * time.Hour, + MaxAge: 5 * time.Hour, + StabilityLevel: metrics.ALPHA, }, []string{OperationLabel}, ) - DeprecatedSchedulingLatency = prometheus.NewSummaryVec( - prometheus.SummaryOpts{ + DeprecatedSchedulingLatency = metrics.NewSummaryVec( + &metrics.SummaryOpts{ Subsystem: SchedulerSubsystem, Name: DeprecatedSchedulingLatencyName, Help: "(Deprecated) Scheduling latency in seconds split by sub-parts of the scheduling operation", // Make the sliding window of 5h. // TODO: The value for this should be based on some SLI definition (long term). - MaxAge: 5 * time.Hour, + MaxAge: 5 * time.Hour, + StabilityLevel: metrics.ALPHA, }, []string{OperationLabel}, ) - E2eSchedulingLatency = prometheus.NewHistogram( - prometheus.HistogramOpts{ - Subsystem: SchedulerSubsystem, - Name: "e2e_scheduling_duration_seconds", - Help: "E2e scheduling latency in seconds (scheduling algorithm + binding)", - Buckets: prometheus.ExponentialBuckets(0.001, 2, 15), + E2eSchedulingLatency = metrics.NewHistogram( + &metrics.HistogramOpts{ + Subsystem: SchedulerSubsystem, + Name: "e2e_scheduling_duration_seconds", + Help: "E2e scheduling latency in seconds (scheduling algorithm + binding)", + Buckets: prometheus.ExponentialBuckets(0.001, 2, 15), + StabilityLevel: metrics.ALPHA, }, ) - DeprecatedE2eSchedulingLatency = prometheus.NewHistogram( - prometheus.HistogramOpts{ - Subsystem: SchedulerSubsystem, - Name: "e2e_scheduling_latency_microseconds", - Help: "(Deprecated) E2e scheduling latency in microseconds (scheduling algorithm + binding)", - Buckets: prometheus.ExponentialBuckets(1000, 2, 15), + DeprecatedE2eSchedulingLatency = metrics.NewHistogram( + &metrics.HistogramOpts{ + Subsystem: SchedulerSubsystem, + Name: "e2e_scheduling_latency_microseconds", + Help: "(Deprecated) E2e scheduling latency in microseconds (scheduling algorithm + binding)", + Buckets: prometheus.ExponentialBuckets(1000, 2, 15), + StabilityLevel: metrics.ALPHA, }, ) - SchedulingAlgorithmLatency = prometheus.NewHistogram( - prometheus.HistogramOpts{ - Subsystem: SchedulerSubsystem, - Name: "scheduling_algorithm_duration_seconds", - Help: "Scheduling algorithm latency in seconds", - Buckets: prometheus.ExponentialBuckets(0.001, 2, 15), + SchedulingAlgorithmLatency = metrics.NewHistogram( + &metrics.HistogramOpts{ + Subsystem: SchedulerSubsystem, + Name: "scheduling_algorithm_duration_seconds", + Help: "Scheduling algorithm latency in seconds", + Buckets: prometheus.ExponentialBuckets(0.001, 2, 15), + StabilityLevel: metrics.ALPHA, }, ) - DeprecatedSchedulingAlgorithmLatency = prometheus.NewHistogram( - prometheus.HistogramOpts{ - Subsystem: SchedulerSubsystem, - Name: "scheduling_algorithm_latency_microseconds", - Help: "(Deprecated) Scheduling algorithm latency in microseconds", - Buckets: prometheus.ExponentialBuckets(1000, 2, 15), + DeprecatedSchedulingAlgorithmLatency = metrics.NewHistogram( + &metrics.HistogramOpts{ + Subsystem: SchedulerSubsystem, + Name: "scheduling_algorithm_latency_microseconds", + Help: "(Deprecated) Scheduling algorithm latency in microseconds", + Buckets: prometheus.ExponentialBuckets(1000, 2, 15), + StabilityLevel: metrics.ALPHA, }, ) - SchedulingAlgorithmPredicateEvaluationDuration = prometheus.NewHistogram( - prometheus.HistogramOpts{ - Subsystem: SchedulerSubsystem, - Name: "scheduling_algorithm_predicate_evaluation_seconds", - Help: "Scheduling algorithm predicate evaluation duration in seconds", - Buckets: prometheus.ExponentialBuckets(0.001, 2, 15), + SchedulingAlgorithmPredicateEvaluationDuration = metrics.NewHistogram( + &metrics.HistogramOpts{ + Subsystem: SchedulerSubsystem, + Name: "scheduling_algorithm_predicate_evaluation_seconds", + Help: "Scheduling algorithm predicate evaluation duration in seconds", + Buckets: prometheus.ExponentialBuckets(0.001, 2, 15), + StabilityLevel: metrics.ALPHA, }, ) - DeprecatedSchedulingAlgorithmPredicateEvaluationDuration = prometheus.NewHistogram( - prometheus.HistogramOpts{ - Subsystem: SchedulerSubsystem, - Name: "scheduling_algorithm_predicate_evaluation", - Help: "(Deprecated) Scheduling algorithm predicate evaluation duration in microseconds", - Buckets: prometheus.ExponentialBuckets(1000, 2, 15), + DeprecatedSchedulingAlgorithmPredicateEvaluationDuration = metrics.NewHistogram( + &metrics.HistogramOpts{ + Subsystem: SchedulerSubsystem, + Name: "scheduling_algorithm_predicate_evaluation", + Help: "(Deprecated) Scheduling algorithm predicate evaluation duration in microseconds", + Buckets: prometheus.ExponentialBuckets(1000, 2, 15), + StabilityLevel: metrics.ALPHA, }, ) - SchedulingAlgorithmPriorityEvaluationDuration = prometheus.NewHistogram( - prometheus.HistogramOpts{ - Subsystem: SchedulerSubsystem, - Name: "scheduling_algorithm_priority_evaluation_seconds", - Help: "Scheduling algorithm priority evaluation duration in seconds", - Buckets: prometheus.ExponentialBuckets(0.001, 2, 15), + SchedulingAlgorithmPriorityEvaluationDuration = metrics.NewHistogram( + &metrics.HistogramOpts{ + Subsystem: SchedulerSubsystem, + Name: "scheduling_algorithm_priority_evaluation_seconds", + Help: "Scheduling algorithm priority evaluation duration in seconds", + Buckets: prometheus.ExponentialBuckets(0.001, 2, 15), + StabilityLevel: metrics.ALPHA, }, ) - DeprecatedSchedulingAlgorithmPriorityEvaluationDuration = prometheus.NewHistogram( - prometheus.HistogramOpts{ - Subsystem: SchedulerSubsystem, - Name: "scheduling_algorithm_priority_evaluation", - Help: "(Deprecated) Scheduling algorithm priority evaluation duration in microseconds", - Buckets: prometheus.ExponentialBuckets(1000, 2, 15), + DeprecatedSchedulingAlgorithmPriorityEvaluationDuration = metrics.NewHistogram( + &metrics.HistogramOpts{ + Subsystem: SchedulerSubsystem, + Name: "scheduling_algorithm_priority_evaluation", + Help: "(Deprecated) Scheduling algorithm priority evaluation duration in microseconds", + Buckets: prometheus.ExponentialBuckets(1000, 2, 15), + StabilityLevel: metrics.ALPHA, }, ) - SchedulingAlgorithmPremptionEvaluationDuration = prometheus.NewHistogram( - prometheus.HistogramOpts{ - Subsystem: SchedulerSubsystem, - Name: "scheduling_algorithm_preemption_evaluation_seconds", - Help: "Scheduling algorithm preemption evaluation duration in seconds", - Buckets: prometheus.ExponentialBuckets(0.001, 2, 15), + SchedulingAlgorithmPremptionEvaluationDuration = metrics.NewHistogram( + &metrics.HistogramOpts{ + Subsystem: SchedulerSubsystem, + Name: "scheduling_algorithm_preemption_evaluation_seconds", + Help: "Scheduling algorithm preemption evaluation duration in seconds", + Buckets: prometheus.ExponentialBuckets(0.001, 2, 15), + StabilityLevel: metrics.ALPHA, }, ) - DeprecatedSchedulingAlgorithmPremptionEvaluationDuration = prometheus.NewHistogram( - prometheus.HistogramOpts{ - Subsystem: SchedulerSubsystem, - Name: "scheduling_algorithm_preemption_evaluation", - Help: "(Deprecated) Scheduling algorithm preemption evaluation duration in microseconds", - Buckets: prometheus.ExponentialBuckets(1000, 2, 15), + DeprecatedSchedulingAlgorithmPremptionEvaluationDuration = metrics.NewHistogram( + &metrics.HistogramOpts{ + Subsystem: SchedulerSubsystem, + Name: "scheduling_algorithm_preemption_evaluation", + Help: "(Deprecated) Scheduling algorithm preemption evaluation duration in microseconds", + Buckets: prometheus.ExponentialBuckets(1000, 2, 15), + StabilityLevel: metrics.ALPHA, }, ) - BindingLatency = prometheus.NewHistogram( - prometheus.HistogramOpts{ - Subsystem: SchedulerSubsystem, - Name: "binding_duration_seconds", - Help: "Binding latency in seconds", - Buckets: prometheus.ExponentialBuckets(0.001, 2, 15), + BindingLatency = metrics.NewHistogram( + &metrics.HistogramOpts{ + Subsystem: SchedulerSubsystem, + Name: "binding_duration_seconds", + Help: "Binding latency in seconds", + Buckets: prometheus.ExponentialBuckets(0.001, 2, 15), + StabilityLevel: metrics.ALPHA, }, ) - DeprecatedBindingLatency = prometheus.NewHistogram( - prometheus.HistogramOpts{ - Subsystem: SchedulerSubsystem, - Name: "binding_latency_microseconds", - Help: "(Deprecated) Binding latency in microseconds", - Buckets: prometheus.ExponentialBuckets(1000, 2, 15), + DeprecatedBindingLatency = metrics.NewHistogram( + &metrics.HistogramOpts{ + Subsystem: SchedulerSubsystem, + Name: "binding_latency_microseconds", + Help: "(Deprecated) Binding latency in microseconds", + Buckets: prometheus.ExponentialBuckets(1000, 2, 15), + StabilityLevel: metrics.ALPHA, }, ) - PreemptionVictims = prometheus.NewGauge( - prometheus.GaugeOpts{ - Subsystem: SchedulerSubsystem, - Name: "pod_preemption_victims", - Help: "Number of selected preemption victims", + PreemptionVictims = metrics.NewGauge( + &metrics.GaugeOpts{ + Subsystem: SchedulerSubsystem, + Name: "pod_preemption_victims", + Help: "Number of selected preemption victims", + StabilityLevel: metrics.ALPHA, }) - PreemptionAttempts = prometheus.NewCounter( - prometheus.CounterOpts{ - Subsystem: SchedulerSubsystem, - Name: "total_preemption_attempts", - Help: "Total preemption attempts in the cluster till now", + PreemptionAttempts = metrics.NewCounter( + &metrics.CounterOpts{ + Subsystem: SchedulerSubsystem, + Name: "total_preemption_attempts", + Help: "Total preemption attempts in the cluster till now", + StabilityLevel: metrics.ALPHA, }) - pendingPods = prometheus.NewGaugeVec( - prometheus.GaugeOpts{ - Subsystem: SchedulerSubsystem, - Name: "pending_pods", - Help: "Number of pending pods, by the queue type. 'active' means number of pods in activeQ; 'backoff' means number of pods in backoffQ; 'unschedulable' means number of pods in unschedulableQ.", + pendingPods = metrics.NewGaugeVec( + &metrics.GaugeOpts{ + Subsystem: SchedulerSubsystem, + Name: "pending_pods", + Help: "Number of pending pods, by the queue type. 'active' means number of pods in activeQ; 'backoff' means number of pods in backoffQ; 'unschedulable' means number of pods in unschedulableQ.", + StabilityLevel: metrics.ALPHA, }, []string{"queue"}) - ActivePods = pendingPods.With(prometheus.Labels{"queue": "active"}) - BackoffPods = pendingPods.With(prometheus.Labels{"queue": "backoff"}) - UnschedulablePods = pendingPods.With(prometheus.Labels{"queue": "unschedulable"}) - metricsList = []prometheus.Collector{ + metricsList = []metrics.Registerable{ scheduleAttempts, SchedulingLatency, DeprecatedSchedulingLatency, @@ -231,13 +249,27 @@ func Register() { // Register the metrics. registerMetrics.Do(func() { for _, metric := range metricsList { - prometheus.MustRegister(metric) + legacyregistry.MustRegister(metric) } - volumescheduling.RegisterVolumeSchedulingMetrics() }) } +// ActivePods returns the pending pods metrics with the label active +func ActivePods() metrics.GaugeMetric { + return pendingPods.With(prometheus.Labels{"queue": "active"}) +} + +// BackoffPods returns the pending pods metrics with the label backoff +func BackoffPods() metrics.GaugeMetric { + return pendingPods.With(prometheus.Labels{"queue": "backoff"}) +} + +// UnschedulablePods returns the pending pods metrics with the label unschedulable +func UnschedulablePods() metrics.GaugeMetric { + return pendingPods.With(prometheus.Labels{"queue": "unschedulable"}) +} + // Reset resets metrics func Reset() { SchedulingLatency.Reset() diff --git a/pkg/ssh/BUILD b/pkg/ssh/BUILD index 2cc03ea717c..ac08e456edf 100644 --- a/pkg/ssh/BUILD +++ b/pkg/ssh/BUILD @@ -25,7 +25,8 @@ go_library( "//staging/src/k8s.io/apimachinery/pkg/util/net:go_default_library", "//staging/src/k8s.io/apimachinery/pkg/util/runtime:go_default_library", "//staging/src/k8s.io/apimachinery/pkg/util/wait:go_default_library", - "//vendor/github.com/prometheus/client_golang/prometheus:go_default_library", + "//staging/src/k8s.io/component-base/metrics:go_default_library", + "//staging/src/k8s.io/component-base/metrics/legacyregistry:go_default_library", "//vendor/golang.org/x/crypto/ssh:go_default_library", "//vendor/k8s.io/klog:go_default_library", ], diff --git a/pkg/ssh/ssh.go b/pkg/ssh/ssh.go index 5b6cb4e1509..bcb26e65ea8 100644 --- a/pkg/ssh/ssh.go +++ b/pkg/ssh/ssh.go @@ -36,33 +36,44 @@ import ( "sync" "time" - "github.com/prometheus/client_golang/prometheus" "golang.org/x/crypto/ssh" utilnet "k8s.io/apimachinery/pkg/util/net" "k8s.io/apimachinery/pkg/util/runtime" "k8s.io/apimachinery/pkg/util/wait" + "k8s.io/component-base/metrics" + "k8s.io/component-base/metrics/legacyregistry" "k8s.io/klog" ) +/* + * By default, all the following metrics are defined as falling under + * ALPHA stability level https://github.com/kubernetes/enhancements/blob/master/keps/sig-instrumentation/20190404-kubernetes-control-plane-metrics-stability.md#stability-classes) + * + * Promoting the stability level of the metric is a responsibility of the component owner, since it + * involves explicitly acknowledging support for the metric across multiple releases, in accordance with + * the metric stability policy. + */ var ( - tunnelOpenCounter = prometheus.NewCounter( - prometheus.CounterOpts{ - Name: "ssh_tunnel_open_count", - Help: "Counter of ssh tunnel total open attempts", + tunnelOpenCounter = metrics.NewCounter( + &metrics.CounterOpts{ + Name: "ssh_tunnel_open_count", + Help: "Counter of ssh tunnel total open attempts", + StabilityLevel: metrics.ALPHA, }, ) - tunnelOpenFailCounter = prometheus.NewCounter( - prometheus.CounterOpts{ - Name: "ssh_tunnel_open_fail_count", - Help: "Counter of ssh tunnel failed open attempts", + tunnelOpenFailCounter = metrics.NewCounter( + &metrics.CounterOpts{ + Name: "ssh_tunnel_open_fail_count", + Help: "Counter of ssh tunnel failed open attempts", + StabilityLevel: metrics.ALPHA, }, ) ) func init() { - prometheus.MustRegister(tunnelOpenCounter) - prometheus.MustRegister(tunnelOpenFailCounter) + legacyregistry.MustRegister(tunnelOpenCounter) + legacyregistry.MustRegister(tunnelOpenFailCounter) } // TODO: Unit tests for this code, we can spin up a test SSH server with instructions here: diff --git a/pkg/util/metrics/BUILD b/pkg/util/metrics/BUILD index a15d30ec247..5416001e924 100644 --- a/pkg/util/metrics/BUILD +++ b/pkg/util/metrics/BUILD @@ -12,7 +12,8 @@ go_library( importpath = "k8s.io/kubernetes/pkg/util/metrics", deps = [ "//staging/src/k8s.io/client-go/util/flowcontrol:go_default_library", - "//vendor/github.com/prometheus/client_golang/prometheus:go_default_library", + "//staging/src/k8s.io/component-base/metrics:go_default_library", + "//staging/src/k8s.io/component-base/metrics/legacyregistry:go_default_library", ], ) diff --git a/pkg/util/metrics/util.go b/pkg/util/metrics/util.go index f1bb7773efb..74d762fafff 100644 --- a/pkg/util/metrics/util.go +++ b/pkg/util/metrics/util.go @@ -21,8 +21,8 @@ import ( "sync" "k8s.io/client-go/util/flowcontrol" - - "github.com/prometheus/client_golang/prometheus" + "k8s.io/component-base/metrics" + "k8s.io/component-base/metrics/legacyregistry" ) var ( @@ -31,7 +31,7 @@ var ( ) type rateLimiterMetric struct { - metric prometheus.Gauge + metric metrics.GaugeMetric stopCh chan struct{} } @@ -43,12 +43,13 @@ func registerRateLimiterMetric(ownerName string) error { // only register once in Prometheus. We happen to see an ownerName reused in parallel integration tests. return nil } - metric := prometheus.NewGauge(prometheus.GaugeOpts{ - Name: "rate_limiter_use", - Subsystem: ownerName, - Help: fmt.Sprintf("A metric measuring the saturation of the rate limiter for %v", ownerName), + metric := metrics.NewGauge(&metrics.GaugeOpts{ + Name: "rate_limiter_use", + Subsystem: ownerName, + Help: fmt.Sprintf("A metric measuring the saturation of the rate limiter for %v", ownerName), + StabilityLevel: metrics.ALPHA, }) - if err := prometheus.Register(metric); err != nil { + if err := legacyregistry.Register(metric); err != nil { return fmt.Errorf("error registering rate limiter usage metric: %v", err) } stopCh := make(chan struct{}) diff --git a/pkg/volume/csi/BUILD b/pkg/volume/csi/BUILD index a6c59dac5e6..80beee758e6 100644 --- a/pkg/volume/csi/BUILD +++ b/pkg/volume/csi/BUILD @@ -99,6 +99,7 @@ filegroup( "//pkg/volume/csi/csiv0:all-srcs", "//pkg/volume/csi/fake:all-srcs", "//pkg/volume/csi/nodeinfomanager:all-srcs", + "//pkg/volume/csi/testing:all-srcs", ], tags = ["automanaged"], visibility = ["//visibility:public"], diff --git a/pkg/volume/csi/csi_attacher_test.go b/pkg/volume/csi/csi_attacher_test.go index bfbf0779057..c280fec73b3 100644 --- a/pkg/volume/csi/csi_attacher_test.go +++ b/pkg/volume/csi/csi_attacher_test.go @@ -1447,7 +1447,7 @@ func newTestWatchPlugin(t *testing.T, fakeClient *fakeclient.Clientset) (*csiPlu fakeClient.Fake.PrependWatchReactor("volumeattachments", core.DefaultWatchReactor(fakeWatcher, nil)) // Start informer for CSIDrivers. - factory := informers.NewSharedInformerFactory(fakeClient, csiResyncPeriod) + factory := informers.NewSharedInformerFactory(fakeClient, CsiResyncPeriod) csiDriverInformer := factory.Storage().V1beta1().CSIDrivers() csiDriverLister := csiDriverInformer.Lister() factory.Start(wait.NeverStop) @@ -1474,7 +1474,7 @@ func newTestWatchPlugin(t *testing.T, fakeClient *fakeclient.Clientset) (*csiPlu if utilfeature.DefaultFeatureGate.Enabled(features.CSIDriverRegistry) { // Wait until the informer in CSI volume plugin has all CSIDrivers. - wait.PollImmediate(testInformerSyncPeriod, testInformerSyncTimeout, func() (bool, error) { + wait.PollImmediate(TestInformerSyncPeriod, TestInformerSyncTimeout, func() (bool, error) { return csiDriverInformer.Informer().HasSynced(), nil }) } diff --git a/pkg/volume/csi/csi_plugin.go b/pkg/volume/csi/csi_plugin.go index e80efe385ca..ba69dcf7678 100644 --- a/pkg/volume/csi/csi_plugin.go +++ b/pkg/volume/csi/csi_plugin.go @@ -59,8 +59,9 @@ const ( volDataFileName = "vol_data.json" fsTypeBlockName = "block" + // CsiResyncPeriod is default resync period duration // TODO: increase to something useful - csiResyncPeriod = time.Minute + CsiResyncPeriod = time.Minute ) var deprecatedSocketDirVersions = []string{"0.1.0", "0.2.0", "0.3.0", "0.4.0"} diff --git a/pkg/volume/csi/csi_plugin_test.go b/pkg/volume/csi/csi_plugin_test.go index 97fecb5ef93..e4ec6ae674a 100644 --- a/pkg/volume/csi/csi_plugin_test.go +++ b/pkg/volume/csi/csi_plugin_test.go @@ -50,7 +50,7 @@ func newTestPlugin(t *testing.T, client *fakeclient.Clientset) (*csiPlugin, stri } // Start informer for CSIDrivers. - factory := informers.NewSharedInformerFactory(client, csiResyncPeriod) + factory := informers.NewSharedInformerFactory(client, CsiResyncPeriod) csiDriverInformer := factory.Storage().V1beta1().CSIDrivers() csiDriverLister := csiDriverInformer.Lister() go factory.Start(wait.NeverStop) @@ -77,7 +77,7 @@ func newTestPlugin(t *testing.T, client *fakeclient.Clientset) (*csiPlugin, stri if utilfeature.DefaultFeatureGate.Enabled(features.CSIDriverRegistry) { // Wait until the informer in CSI volume plugin has all CSIDrivers. - wait.PollImmediate(testInformerSyncPeriod, testInformerSyncTimeout, func() (bool, error) { + wait.PollImmediate(TestInformerSyncPeriod, TestInformerSyncTimeout, func() (bool, error) { return csiDriverInformer.Informer().HasSynced(), nil }) } @@ -935,7 +935,7 @@ func TestPluginFindAttachablePlugin(t *testing.T) { defer os.RemoveAll(tmpDir) client := fakeclient.NewSimpleClientset(getTestCSIDriver(test.driverName, nil, &test.canAttach)) - factory := informers.NewSharedInformerFactory(client, csiResyncPeriod) + factory := informers.NewSharedInformerFactory(client, CsiResyncPeriod) host := volumetest.NewFakeVolumeHostWithCSINodeName( tmpDir, client, diff --git a/pkg/volume/csi/csi_test.go b/pkg/volume/csi/csi_test.go index 8dd147fa846..b2865453e93 100644 --- a/pkg/volume/csi/csi_test.go +++ b/pkg/volume/csi/csi_test.go @@ -121,7 +121,7 @@ func TestCSI_VolumeAll(t *testing.T) { client := fakeclient.NewSimpleClientset() fakeWatcher := watch.NewRaceFreeFake() - factory := informers.NewSharedInformerFactory(client, csiResyncPeriod) + factory := informers.NewSharedInformerFactory(client, CsiResyncPeriod) factory.Start(wait.NeverStop) host := volumetest.NewFakeVolumeHostWithCSINodeName( diff --git a/pkg/volume/csi/csi_util.go b/pkg/volume/csi/csi_util.go index 0b8233be809..eb643de4b72 100644 --- a/pkg/volume/csi/csi_util.go +++ b/pkg/volume/csi/csi_util.go @@ -34,8 +34,10 @@ import ( ) const ( - testInformerSyncPeriod = 100 * time.Millisecond - testInformerSyncTimeout = 30 * time.Second + // TestInformerSyncPeriod is informer sync period duration for testing + TestInformerSyncPeriod = 100 * time.Millisecond + // TestInformerSyncTimeout is informer timeout duration for testing + TestInformerSyncTimeout = 30 * time.Second ) func getCredentialsFromSecret(k8s kubernetes.Interface, secretRef *api.SecretReference) (map[string]string, error) { diff --git a/pkg/volume/csi/testing/BUILD b/pkg/volume/csi/testing/BUILD new file mode 100644 index 00000000000..78cddd23181 --- /dev/null +++ b/pkg/volume/csi/testing/BUILD @@ -0,0 +1,33 @@ +load("@io_bazel_rules_go//go:def.bzl", "go_library") + +go_library( + name = "go_default_library", + srcs = ["testing.go"], + importpath = "k8s.io/kubernetes/pkg/volume/csi/testing", + visibility = ["//visibility:public"], + deps = [ + "//pkg/features:go_default_library", + "//pkg/volume:go_default_library", + "//pkg/volume/csi:go_default_library", + "//pkg/volume/testing:go_default_library", + "//staging/src/k8s.io/apimachinery/pkg/util/wait:go_default_library", + "//staging/src/k8s.io/apiserver/pkg/util/feature:go_default_library", + "//staging/src/k8s.io/client-go/informers:go_default_library", + "//staging/src/k8s.io/client-go/kubernetes/fake:go_default_library", + "//staging/src/k8s.io/client-go/util/testing:go_default_library", + ], +) + +filegroup( + name = "package-srcs", + srcs = glob(["**"]), + tags = ["automanaged"], + visibility = ["//visibility:private"], +) + +filegroup( + name = "all-srcs", + srcs = [":package-srcs"], + tags = ["automanaged"], + visibility = ["//visibility:public"], +) diff --git a/pkg/volume/csi/testing/testing.go b/pkg/volume/csi/testing/testing.go new file mode 100644 index 00000000000..f4d4d9a4cba --- /dev/null +++ b/pkg/volume/csi/testing/testing.go @@ -0,0 +1,72 @@ +/* +Copyright 2019 The Kubernetes Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package testing + +import ( + "k8s.io/apimachinery/pkg/util/wait" + utilfeature "k8s.io/apiserver/pkg/util/feature" + "k8s.io/client-go/informers" + fakeclient "k8s.io/client-go/kubernetes/fake" + utiltesting "k8s.io/client-go/util/testing" + "k8s.io/kubernetes/pkg/features" + "k8s.io/kubernetes/pkg/volume" + "k8s.io/kubernetes/pkg/volume/csi" + volumetest "k8s.io/kubernetes/pkg/volume/testing" + "testing" +) + +// NewTestPlugin creates a plugin mgr to load plugins and setup a fake client +func NewTestPlugin(t *testing.T, client *fakeclient.Clientset) (*volume.VolumePluginMgr, *volume.VolumePlugin, string) { + tmpDir, err := utiltesting.MkTmpdir("csi-test") + if err != nil { + t.Fatalf("can't create temp dir: %v", err) + } + + if client == nil { + client = fakeclient.NewSimpleClientset() + } + + // Start informer for CSIDrivers. + factory := informers.NewSharedInformerFactory(client, csi.CsiResyncPeriod) + csiDriverInformer := factory.Storage().V1beta1().CSIDrivers() + csiDriverLister := csiDriverInformer.Lister() + go factory.Start(wait.NeverStop) + + host := volumetest.NewFakeVolumeHostWithCSINodeName( + tmpDir, + client, + nil, + "fakeNode", + csiDriverLister, + ) + plugMgr := &volume.VolumePluginMgr{} + plugMgr.InitPlugins(csi.ProbeVolumePlugins(), nil /* prober */, host) + + plug, err := plugMgr.FindPluginByName(csi.CSIPluginName) + if err != nil { + t.Fatalf("can't find plugin %v", csi.CSIPluginName) + } + + if utilfeature.DefaultFeatureGate.Enabled(features.CSIDriverRegistry) { + // Wait until the informer in CSI volume plugin has all CSIDrivers. + wait.PollImmediate(csi.TestInformerSyncPeriod, csi.TestInformerSyncTimeout, func() (bool, error) { + return csiDriverInformer.Informer().HasSynced(), nil + }) + } + + return plugMgr, &plug, tmpDir +} diff --git a/pkg/volume/util/BUILD b/pkg/volume/util/BUILD index 0b8973cc8ab..43174f771c5 100644 --- a/pkg/volume/util/BUILD +++ b/pkg/volume/util/BUILD @@ -40,7 +40,8 @@ go_library( "//staging/src/k8s.io/apimachinery/pkg/util/strategicpatch:go_default_library", "//staging/src/k8s.io/apiserver/pkg/util/feature:go_default_library", "//staging/src/k8s.io/client-go/kubernetes:go_default_library", - "//vendor/github.com/prometheus/client_golang/prometheus:go_default_library", + "//staging/src/k8s.io/component-base/metrics:go_default_library", + "//staging/src/k8s.io/component-base/metrics/legacyregistry:go_default_library", "//vendor/k8s.io/klog:go_default_library", "//vendor/k8s.io/utils/strings:go_default_library", ], diff --git a/pkg/volume/util/metrics.go b/pkg/volume/util/metrics.go index 10c66794dc2..5542f8e534b 100644 --- a/pkg/volume/util/metrics.go +++ b/pkg/volume/util/metrics.go @@ -20,7 +20,8 @@ import ( "fmt" "time" - "github.com/prometheus/client_golang/prometheus" + "k8s.io/component-base/metrics" + "k8s.io/component-base/metrics/legacyregistry" "k8s.io/kubernetes/pkg/volume" ) @@ -29,36 +30,48 @@ const ( statusFailUnknown = "fail-unknown" ) -var storageOperationMetric = prometheus.NewHistogramVec( - prometheus.HistogramOpts{ - Name: "storage_operation_duration_seconds", - Help: "Storage operation duration", - Buckets: []float64{.1, .25, .5, 1, 2.5, 5, 10, 15, 25, 50, 120, 300, 600}, +/* + * By default, all the following metrics are defined as falling under + * ALPHA stability level https://github.com/kubernetes/enhancements/blob/master/keps/sig-instrumentation/20190404-kubernetes-control-plane-metrics-stability.md#stability-classes) + * + * Promoting the stability level of the metric is a responsibility of the component owner, since it + * involves explicitly acknowledging support for the metric across multiple releases, in accordance with + * the metric stability policy. + */ +var storageOperationMetric = metrics.NewHistogramVec( + &metrics.HistogramOpts{ + Name: "storage_operation_duration_seconds", + Help: "Storage operation duration", + Buckets: []float64{.1, .25, .5, 1, 2.5, 5, 10, 15, 25, 50, 120, 300, 600}, + StabilityLevel: metrics.ALPHA, }, []string{"volume_plugin", "operation_name"}, ) -var storageOperationErrorMetric = prometheus.NewCounterVec( - prometheus.CounterOpts{ - Name: "storage_operation_errors_total", - Help: "Storage operation errors", +var storageOperationErrorMetric = metrics.NewCounterVec( + &metrics.CounterOpts{ + Name: "storage_operation_errors_total", + Help: "Storage operation errors", + StabilityLevel: metrics.ALPHA, }, []string{"volume_plugin", "operation_name"}, ) -var storageOperationStatusMetric = prometheus.NewCounterVec( - prometheus.CounterOpts{ - Name: "storage_operation_status_count", - Help: "Storage operation return statuses count", +var storageOperationStatusMetric = metrics.NewCounterVec( + &metrics.CounterOpts{ + Name: "storage_operation_status_count", + Help: "Storage operation return statuses count", + StabilityLevel: metrics.ALPHA, }, []string{"volume_plugin", "operation_name", "status"}, ) -var storageOperationEndToEndLatencyMetric = prometheus.NewHistogramVec( - prometheus.HistogramOpts{ - Name: "volume_operation_total_seconds", - Help: "Storage operation end to end duration in seconds", - Buckets: []float64{.1, .25, .5, 1, 2.5, 5, 10, 15, 25, 50, 120, 300, 600}, +var storageOperationEndToEndLatencyMetric = metrics.NewHistogramVec( + &metrics.HistogramOpts{ + Name: "volume_operation_total_seconds", + Help: "Storage operation end to end duration in seconds", + Buckets: []float64{.1, .25, .5, 1, 2.5, 5, 10, 15, 25, 50, 120, 300, 600}, + StabilityLevel: metrics.ALPHA, }, []string{"plugin_name", "operation_name"}, ) @@ -68,10 +81,12 @@ func init() { } func registerMetrics() { - prometheus.MustRegister(storageOperationMetric) - prometheus.MustRegister(storageOperationErrorMetric) - prometheus.MustRegister(storageOperationStatusMetric) - prometheus.MustRegister(storageOperationEndToEndLatencyMetric) + // legacyregistry is the internal k8s wrapper around the prometheus + // global registry, used specifically for metric stability enforcement + legacyregistry.MustRegister(storageOperationMetric) + legacyregistry.MustRegister(storageOperationErrorMetric) + legacyregistry.MustRegister(storageOperationStatusMetric) + legacyregistry.MustRegister(storageOperationEndToEndLatencyMetric) } // OperationCompleteHook returns a hook to call when an operation is completed diff --git a/pkg/volume/util/operationexecutor/BUILD b/pkg/volume/util/operationexecutor/BUILD index 633be6d6008..aa0684276fa 100644 --- a/pkg/volume/util/operationexecutor/BUILD +++ b/pkg/volume/util/operationexecutor/BUILD @@ -42,16 +42,34 @@ go_library( go_test( name = "go_default_test", - srcs = ["operation_executor_test.go"], + srcs = [ + "operation_executor_test.go", + "operation_generator_test.go", + ], embed = [":go_default_library"], deps = [ + "//pkg/features:go_default_library", "//pkg/util/mount:go_default_library", "//pkg/volume:go_default_library", + "//pkg/volume/awsebs:go_default_library", + "//pkg/volume/csi:go_default_library", + "//pkg/volume/csi/testing:go_default_library", + "//pkg/volume/gcepd:go_default_library", + "//pkg/volume/testing:go_default_library", "//pkg/volume/util/types:go_default_library", "//staging/src/k8s.io/api/core/v1:go_default_library", "//staging/src/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library", "//staging/src/k8s.io/apimachinery/pkg/types:go_default_library", "//staging/src/k8s.io/apimachinery/pkg/util/uuid:go_default_library", + "//staging/src/k8s.io/apiserver/pkg/util/feature:go_default_library", + "//staging/src/k8s.io/client-go/kubernetes/fake:go_default_library", + "//staging/src/k8s.io/client-go/tools/record:go_default_library", + "//staging/src/k8s.io/component-base/featuregate:go_default_library", + "//staging/src/k8s.io/component-base/featuregate/testing:go_default_library", + "//staging/src/k8s.io/component-base/metrics/legacyregistry:go_default_library", + "//staging/src/k8s.io/csi-translation-lib/plugins:go_default_library", + "//vendor/github.com/prometheus/client_model/go:go_default_library", + "//vendor/github.com/stretchr/testify/assert:go_default_library", ], ) diff --git a/pkg/volume/util/operationexecutor/operation_generator_test.go b/pkg/volume/util/operationexecutor/operation_generator_test.go new file mode 100644 index 00000000000..a2c7bbb8cd2 --- /dev/null +++ b/pkg/volume/util/operationexecutor/operation_generator_test.go @@ -0,0 +1,256 @@ +/* +Copyright 2019 The Kubernetes Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package operationexecutor + +import ( + "fmt" + "github.com/prometheus/client_model/go" + "github.com/stretchr/testify/assert" + "k8s.io/api/core/v1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/types" + "k8s.io/apimachinery/pkg/util/uuid" + utilfeature "k8s.io/apiserver/pkg/util/feature" + fakeclient "k8s.io/client-go/kubernetes/fake" + "k8s.io/client-go/tools/record" + "k8s.io/component-base/featuregate" + featuregatetesting "k8s.io/component-base/featuregate/testing" + "k8s.io/component-base/metrics/legacyregistry" + "k8s.io/csi-translation-lib/plugins" + "k8s.io/kubernetes/pkg/features" + "k8s.io/kubernetes/pkg/volume" + "k8s.io/kubernetes/pkg/volume/awsebs" + "k8s.io/kubernetes/pkg/volume/csi" + csitesting "k8s.io/kubernetes/pkg/volume/csi/testing" + "k8s.io/kubernetes/pkg/volume/gcepd" + volumetesting "k8s.io/kubernetes/pkg/volume/testing" + "os" + "testing" +) + +// this method just tests the volume plugin name that's used in CompleteFunc, the same plugin is also used inside the +// generated func so there is no need to test the plugin name that's used inside generated function +func TestOperationGenerator_GenerateUnmapVolumeFunc_PluginName(t *testing.T) { + type testcase struct { + name string + isCsiMigrationEnabled bool + pluginName string + csiDriverName string + csiMigrationFeature featuregate.Feature + pvSpec v1.PersistentVolumeSpec + probVolumePlugins []volume.VolumePlugin + } + + testcases := []testcase{ + { + name: "gce pd plugin: csi migration disabled", + isCsiMigrationEnabled: false, + pluginName: plugins.GCEPDInTreePluginName, + csiMigrationFeature: features.CSIMigrationGCE, + pvSpec: v1.PersistentVolumeSpec{ + PersistentVolumeSource: v1.PersistentVolumeSource{ + GCEPersistentDisk: &v1.GCEPersistentDiskVolumeSource{}, + }}, + probVolumePlugins: gcepd.ProbeVolumePlugins(), + }, + { + name: "gce pd plugin: csi migration enabled", + isCsiMigrationEnabled: true, + pluginName: plugins.GCEPDInTreePluginName, + csiDriverName: plugins.GCEPDDriverName, + csiMigrationFeature: features.CSIMigrationGCE, + pvSpec: v1.PersistentVolumeSpec{ + PersistentVolumeSource: v1.PersistentVolumeSource{ + GCEPersistentDisk: &v1.GCEPersistentDiskVolumeSource{}, + }}, + probVolumePlugins: gcepd.ProbeVolumePlugins(), + }, + { + name: "aws ebs plugin: csi migration disabled", + isCsiMigrationEnabled: false, + pluginName: plugins.AWSEBSInTreePluginName, + csiMigrationFeature: features.CSIMigrationAWS, + pvSpec: v1.PersistentVolumeSpec{ + PersistentVolumeSource: v1.PersistentVolumeSource{ + AWSElasticBlockStore: &v1.AWSElasticBlockStoreVolumeSource{}, + }}, + probVolumePlugins: awsebs.ProbeVolumePlugins(), + }, + { + name: "aws ebs plugin: csi migration enabled", + isCsiMigrationEnabled: true, + pluginName: plugins.AWSEBSInTreePluginName, + csiDriverName: plugins.AWSEBSDriverName, + csiMigrationFeature: features.CSIMigrationAWS, + pvSpec: v1.PersistentVolumeSpec{ + PersistentVolumeSource: v1.PersistentVolumeSource{ + AWSElasticBlockStore: &v1.AWSElasticBlockStoreVolumeSource{}, + }}, + probVolumePlugins: awsebs.ProbeVolumePlugins(), + }, + } + + for _, tc := range testcases { + expectedPluginName := tc.pluginName + if tc.isCsiMigrationEnabled { + expectedPluginName = fmt.Sprintf("%s:%s", csi.CSIPluginName, tc.csiDriverName) + } + defer featuregatetesting.SetFeatureGateDuringTest(t, utilfeature.DefaultFeatureGate, features.CSIMigration, tc.isCsiMigrationEnabled)() + defer featuregatetesting.SetFeatureGateDuringTest(t, utilfeature.DefaultFeatureGate, tc.csiMigrationFeature, tc.isCsiMigrationEnabled)() + + volumePluginMgr, plugin, tmpDir := initTestPlugins(t, tc.probVolumePlugins, tc.pluginName) + defer os.RemoveAll(tmpDir) + + operationGenerator := getTestOperationGenerator(volumePluginMgr) + + pod := &v1.Pod{ObjectMeta: metav1.ObjectMeta{UID: types.UID(string(uuid.NewUUID()))}} + volumeToUnmount := getTestVolumeToUnmount(pod, tc.pvSpec, tc.pluginName) + + if tc.isCsiMigrationEnabled { + // GenerateUnmapVolumeFunc call blockVolumePlugin.NewBlockVolumeUnmapper and when the plugin is csi, + // csi plugin looks a file that contains some information about the volume, + // and GenerateUnmapVolumeFuncfails if csi plugin can't find that file. + // So the reason for calling plugin.NewBlockVolumeMapper for csi enabled case is creating that file. + csiSpec, err := translateSpec(volumeToUnmount.VolumeSpec) + if err != nil { + t.Fatalf("Can't translate volume to CSI") + } + _, mapperError := (*plugin).(volume.BlockVolumePlugin).NewBlockVolumeMapper(csiSpec, pod, volume.VolumeOptions{}) + if mapperError != nil { + t.Fatalf("mapper error: %v\n", mapperError) + } + } + + unmapVolumeFunc, e := operationGenerator.GenerateUnmapVolumeFunc(volumeToUnmount, nil) + if e != nil { + t.Fatalf("Error occurred while generating unmapVolumeFunc: %v", e) + } + + metricFamilyName := "storage_operation_status_count" + labelFilter := map[string]string{ + "status": "success", + "operation_name": "unmap_volume", + "volume_plugin": expectedPluginName, + } + // compare the relative change of the metric because of the global state of the prometheus.DefaultGatherer.Gather() + storageOperationStatusCountMetricBefore := findMetricWithNameAndLabels(metricFamilyName, labelFilter) + + var ee error + unmapVolumeFunc.CompleteFunc(&ee) + + storageOperationStatusCountMetricAfter := findMetricWithNameAndLabels(metricFamilyName, labelFilter) + if storageOperationStatusCountMetricAfter == nil { + t.Fatalf("Couldn't find the metric with name(%s) and labels(%v)", metricFamilyName, labelFilter) + } + + if storageOperationStatusCountMetricBefore == nil { + assert.Equal(t, float64(1), *storageOperationStatusCountMetricAfter.Counter.Value, tc.name) + } else { + metricValueDiff := *storageOperationStatusCountMetricAfter.Counter.Value - *storageOperationStatusCountMetricBefore.Counter.Value + assert.Equal(t, float64(1), metricValueDiff, tc.name) + } + } +} + +func findMetricWithNameAndLabels(metricFamilyName string, labelFilter map[string]string) *io_prometheus_client.Metric { + metricFamily := getMetricFamily(metricFamilyName) + if metricFamily == nil { + return nil + } + + for _, metric := range metricFamily.GetMetric() { + if isLabelsMatchWithMetric(labelFilter, metric) { + return metric + } + } + + return nil +} + +func isLabelsMatchWithMetric(labelFilter map[string]string, metric *io_prometheus_client.Metric) bool { + if len(labelFilter) != len(metric.Label) { + return false + } + for labelName, labelValue := range labelFilter { + labelFound := false + for _, labelPair := range metric.Label { + if labelName == *labelPair.Name && labelValue == *labelPair.Value { + labelFound = true + break + } + } + if !labelFound { + return false + } + } + return true +} + +func getTestOperationGenerator(volumePluginMgr *volume.VolumePluginMgr) OperationGenerator { + fakeKubeClient := fakeclient.NewSimpleClientset() + fakeRecorder := &record.FakeRecorder{} + fakeHandler := volumetesting.NewBlockVolumePathHandler() + operationGenerator := NewOperationGenerator( + fakeKubeClient, + volumePluginMgr, + fakeRecorder, + false, + fakeHandler) + return operationGenerator +} + +func getTestVolumeToUnmount(pod *v1.Pod, pvSpec v1.PersistentVolumeSpec, pluginName string) MountedVolume { + volumeSpec := &volume.Spec{ + PersistentVolume: &v1.PersistentVolume{ + Spec: pvSpec, + }, + } + volumeToUnmount := MountedVolume{ + VolumeName: v1.UniqueVolumeName("pd-volume"), + PodUID: pod.UID, + PluginName: pluginName, + VolumeSpec: volumeSpec, + } + return volumeToUnmount +} + +func getMetricFamily(metricFamilyName string) *io_prometheus_client.MetricFamily { + metricFamilies, _ := legacyregistry.DefaultGatherer.Gather() + for _, mf := range metricFamilies { + if *mf.Name == metricFamilyName { + return mf + } + } + return nil +} + +func initTestPlugins(t *testing.T, plugs []volume.VolumePlugin, pluginName string) (*volume.VolumePluginMgr, *volume.VolumePlugin, string) { + client := fakeclient.NewSimpleClientset() + pluginMgr, csiPlugin, tmpDir := csitesting.NewTestPlugin(t, client) + + err := pluginMgr.InitPlugins(plugs, nil, pluginMgr.Host) + if err != nil { + t.Fatalf("Can't init volume plugins: %v", err) + } + + _, e := pluginMgr.FindPluginByName(pluginName) + if e != nil { + t.Fatalf("Can't find the plugin by name: %s", pluginName) + } + + return pluginMgr, csiPlugin, tmpDir +} diff --git a/staging/publishing/import-restrictions.yaml b/staging/publishing/import-restrictions.yaml index b87453cc655..22f18a33806 100644 --- a/staging/publishing/import-restrictions.yaml +++ b/staging/publishing/import-restrictions.yaml @@ -55,6 +55,8 @@ allowedImports: - k8s.io/apimachinery - k8s.io/component-base + - k8s.io/client-go + - k8s.io/client-go/tools/ - k8s.io/klog - k8s.io/utils @@ -213,6 +215,8 @@ - k8s.io/klog - k8s.io/legacy-cloud-providers - k8s.io/utils + - k8s.io/component-base/metrics + - k8s.io/component-base/metrics/legacyregistry - baseImportPath: "./vendor/k8s.io/node-api/" allowedImports: diff --git a/staging/publishing/rules.yaml b/staging/publishing/rules.yaml index b6bc94f22fd..c54605a0fde 100644 --- a/staging/publishing/rules.yaml +++ b/staging/publishing/rules.yaml @@ -82,6 +82,10 @@ rules: dependencies: - repository: apimachinery branch: master + - repository: api + branch: master + - repository: client-go + branch: master - source: branch: release-1.15 dir: staging/src/k8s.io/component-base @@ -460,6 +464,10 @@ rules: branch: master - repository: component-base branch: master + - repository: api + branch: master + - repository: client-go + branch: master - source: branch: release-1.15 dir: staging/src/k8s.io/kube-controller-manager diff --git a/staging/src/k8s.io/api/go.sum b/staging/src/k8s.io/api/go.sum index e6e1020a88f..ee67f80705c 100644 --- a/staging/src/k8s.io/api/go.sum +++ b/staging/src/k8s.io/api/go.sum @@ -70,6 +70,7 @@ gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.8 h1:obN1ZagJSUGI0Ek/LBmuj4SNLPfIny3KsKFopxRdj10= gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +k8s.io/klog v1.0.0 h1:Pt+yjF5aB1xDSVbau4VsWe+dQNzA0qv1LlXdC2dF6Q8= k8s.io/klog v1.0.0/go.mod h1:4Bi6QPql/J/LkTDqv7R/cd3hPo4k2DG6Ptcz060Ez5I= k8s.io/kube-openapi v0.0.0-20190228160746-b3a7cee44a30/go.mod h1:BXM9ceUBTj2QnfH2MK1odQs778ajze1RxcmP6S8RVVc= sigs.k8s.io/yaml v1.1.0 h1:4A07+ZFc2wgJwo8YNlQpr1rVlgUDlxXHhPJciaPY5gs= diff --git a/staging/src/k8s.io/apiextensions-apiserver/go.mod b/staging/src/k8s.io/apiextensions-apiserver/go.mod index f6c2244fd9e..ed08c647fac 100644 --- a/staging/src/k8s.io/apiextensions-apiserver/go.mod +++ b/staging/src/k8s.io/apiextensions-apiserver/go.mod @@ -19,6 +19,7 @@ require ( github.com/spf13/pflag v1.0.5 github.com/stretchr/testify v1.4.0 go.etcd.io/etcd v0.5.0-alpha.5.0.20200224211402-c65a9e2dd1fd + google.golang.org/grpc v1.26.0 gopkg.in/yaml.v2 v2.2.8 k8s.io/api v0.0.0 k8s.io/apimachinery v0.0.0 @@ -42,7 +43,6 @@ replace ( github.com/google/gofuzz => github.com/google/gofuzz v0.0.0-20170612174753-24818f796faf github.com/googleapis/gnostic => github.com/googleapis/gnostic v0.0.0-20170729233727-0c5108395e2d github.com/grpc-ecosystem/go-grpc-middleware => github.com/grpc-ecosystem/go-grpc-middleware v0.0.0-20190222133341-cfaf5686ec79 - github.com/grpc-ecosystem/go-grpc-prometheus => github.com/grpc-ecosystem/go-grpc-prometheus v0.0.0-20170330212424-2500245aa611 github.com/grpc-ecosystem/grpc-gateway => github.com/grpc-ecosystem/grpc-gateway v1.3.0 github.com/hashicorp/golang-lru => github.com/hashicorp/golang-lru v0.5.0 github.com/jonboulle/clockwork => github.com/jonboulle/clockwork v0.0.0-20141017032234-72f9bd7c4e0c diff --git a/staging/src/k8s.io/apiextensions-apiserver/go.sum b/staging/src/k8s.io/apiextensions-apiserver/go.sum index 79a7968f7f6..15423d97ab6 100644 --- a/staging/src/k8s.io/apiextensions-apiserver/go.sum +++ b/staging/src/k8s.io/apiextensions-apiserver/go.sum @@ -44,6 +44,7 @@ github.com/coreos/go-etcd v2.0.0+incompatible/go.mod h1:Jez6KQU2B/sWsbdaef3ED8Nz github.com/coreos/go-oidc v0.0.0-20180117170138-065b426bd416 h1:X+JQSgXg3CcxgcBoMAqU8NoS0fch8zHxjiKWcXclxaI= github.com/coreos/go-oidc v0.0.0-20180117170138-065b426bd416/go.mod h1:CgnwVTmzoESiwO9qyAFEMiHoZ1nMCKZlZ9V6mm3/LKc= github.com/coreos/go-semver v0.2.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk= +github.com/coreos/go-semver v0.3.0 h1:wkHLiw0WNATZnSG7epLsujiMCgPAc9xhjJ4tgnAxmfM= github.com/coreos/go-semver v0.3.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk= github.com/coreos/go-systemd v0.0.0-20180511133405-39ca1b05acc7 h1:u9SHYsPQNyt5tgDm3YN7+9dYrpK96E5wFilTFWIDZOM= github.com/coreos/go-systemd v0.0.0-20180511133405-39ca1b05acc7/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4= @@ -173,8 +174,8 @@ github.com/grafov/bcast v0.0.0-20190217190352-1447f067e08d/go.mod h1:RInr+B3/Tx7 github.com/gregjones/httpcache v0.0.0-20180305231024-9cad4c3443a7/go.mod h1:FecbI9+v66THATjSRHfNgh1IVFe/9kFxbXtjV0ctIMA= github.com/grpc-ecosystem/go-grpc-middleware v0.0.0-20190222133341-cfaf5686ec79 h1:lR9ssWAqp9qL0bALxqEEkuudiP1eweOdv9jsRK3e7lE= github.com/grpc-ecosystem/go-grpc-middleware v0.0.0-20190222133341-cfaf5686ec79/go.mod h1:FiyG127CGDf3tlThmgyCl78X/SZQqEOJBCDaAfeWzPs= -github.com/grpc-ecosystem/go-grpc-prometheus v0.0.0-20170330212424-2500245aa611 h1:f5vL2EW5pL274ztMNnizZAEa457nKyKPEaN/sm/kdBk= -github.com/grpc-ecosystem/go-grpc-prometheus v0.0.0-20170330212424-2500245aa611/go.mod h1:8NvIoxWQoOIhqOTXgfV/d3M/q6VIi02HzZEHgUlZvzk= +github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0 h1:Ovs26xHkKqVztRpIrF/92BcuyuQ/YW4NSIpoGtfXNho= +github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0/go.mod h1:8NvIoxWQoOIhqOTXgfV/d3M/q6VIi02HzZEHgUlZvzk= github.com/grpc-ecosystem/grpc-gateway v1.3.0 h1:HJtP6RRwj2EpPCD/mhAWzSvLL/dFTdPm1UrWwanoFos= github.com/grpc-ecosystem/grpc-gateway v1.3.0/go.mod h1:RSKVYQBd5MCa4OVpNdGskqpgL2+G+NZTnrVHpWWfpdw= github.com/hashicorp/golang-lru v0.5.0 h1:CL2msUPvZTLb5O648aiLNJw3hnBxN2+1Jq8rCOH9wdo= @@ -405,6 +406,7 @@ honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWh honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= k8s.io/gengo v0.0.0-20200205140755-e0e292d8aa12 h1:pZzawYyz6VRNPVYpqGv61LWCimQv1BihyeqFrp50/G4= k8s.io/gengo v0.0.0-20200205140755-e0e292d8aa12/go.mod h1:ezvh/TsK7cY6rbqRK0oQQ8IAqLxYwwyPxAX1Pzy0ii0= +k8s.io/klog v1.0.0 h1:Pt+yjF5aB1xDSVbau4VsWe+dQNzA0qv1LlXdC2dF6Q8= k8s.io/klog v1.0.0/go.mod h1:4Bi6QPql/J/LkTDqv7R/cd3hPo4k2DG6Ptcz060Ez5I= k8s.io/kube-openapi v0.0.0-20190228160746-b3a7cee44a30 h1:TRb4wNWoBVrH9plmkp2q86FIDppkbrEXdXlxU3a3BMI= k8s.io/kube-openapi v0.0.0-20190228160746-b3a7cee44a30/go.mod h1:BXM9ceUBTj2QnfH2MK1odQs778ajze1RxcmP6S8RVVc= @@ -415,7 +417,7 @@ modernc.org/golex v1.0.0/go.mod h1:b/QX9oBD/LhixY6NDh+IdGv17hgB+51fET1i2kPSmvk= modernc.org/mathutil v1.0.0/go.mod h1:wU0vUrJsVWBZ4P6e7xtFJEhFSNsfRLJ8H458uRjg03k= modernc.org/strutil v1.0.0/go.mod h1:lstksw84oURvj9y3tn8lGvRxyRC1S2+g5uuIzNfIOBs= modernc.org/xc v1.0.0/go.mod h1:mRNCo0bvLjGhHO9WsyuKVU4q0ceiDDDoEeWDJHrNx8I= -sigs.k8s.io/structured-merge-diff v0.0.0-20190302045857-e85c7b244fd2 h1:9r5DY45ef9LtcA6BnkhW8MPV7OKAfbf2AUwUhq3LeRk= -sigs.k8s.io/structured-merge-diff v0.0.0-20190302045857-e85c7b244fd2/go.mod h1:wWxsB5ozmmv/SG7nM11ayaAW51xMvak/t1r0CSlcokI= +sigs.k8s.io/structured-merge-diff v0.0.0-20190719182312-e94e05bfbbe3 h1:yCY9zAYErawYwXdOYmwEBzcGCr/6eIUujYZE2DIQve8= +sigs.k8s.io/structured-merge-diff v0.0.0-20190719182312-e94e05bfbbe3/go.mod h1:wWxsB5ozmmv/SG7nM11ayaAW51xMvak/t1r0CSlcokI= sigs.k8s.io/yaml v1.1.0 h1:4A07+ZFc2wgJwo8YNlQpr1rVlgUDlxXHhPJciaPY5gs= sigs.k8s.io/yaml v1.1.0/go.mod h1:UJmg0vDUVViEyp3mgSv9WPwZCDxu4rQW1olrI1uml+o= diff --git a/staging/src/k8s.io/apiextensions-apiserver/pkg/apiserver/conversion/BUILD b/staging/src/k8s.io/apiextensions-apiserver/pkg/apiserver/conversion/BUILD index 56ccbcc7e17..073e51b5c56 100644 --- a/staging/src/k8s.io/apiextensions-apiserver/pkg/apiserver/conversion/BUILD +++ b/staging/src/k8s.io/apiextensions-apiserver/pkg/apiserver/conversion/BUILD @@ -28,6 +28,8 @@ go_library( "//staging/src/k8s.io/apiserver/pkg/util/webhook:go_default_library", "//staging/src/k8s.io/client-go/kubernetes/scheme:go_default_library", "//staging/src/k8s.io/client-go/rest:go_default_library", + "//staging/src/k8s.io/component-base/metrics:go_default_library", + "//staging/src/k8s.io/component-base/metrics/legacyregistry:go_default_library", "//vendor/github.com/prometheus/client_golang/prometheus:go_default_library", ], ) diff --git a/staging/src/k8s.io/apiextensions-apiserver/pkg/apiserver/conversion/metrics.go b/staging/src/k8s.io/apiextensions-apiserver/pkg/apiserver/conversion/metrics.go index 89090d7f999..dcd96232a5c 100644 --- a/staging/src/k8s.io/apiextensions-apiserver/pkg/apiserver/conversion/metrics.go +++ b/staging/src/k8s.io/apiextensions-apiserver/pkg/apiserver/conversion/metrics.go @@ -26,6 +26,8 @@ import ( "k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/runtime/schema" + "k8s.io/component-base/metrics" + "k8s.io/component-base/metrics/legacyregistry" ) var ( @@ -36,19 +38,19 @@ var ( type converterMetricFactory struct { // A map from a converter name to it's metric. Allows the converterMetric to be created // again with the same metric for a specific converter (e.g. 'webhook'). - durations map[string]*prometheus.HistogramVec + durations map[string]*metrics.HistogramVec factoryLock sync.Mutex } func newConverterMertricFactory() *converterMetricFactory { - return &converterMetricFactory{durations: map[string]*prometheus.HistogramVec{}, factoryLock: sync.Mutex{}} + return &converterMetricFactory{durations: map[string]*metrics.HistogramVec{}, factoryLock: sync.Mutex{}} } var _ crConverterInterface = &converterMetric{} type converterMetric struct { delegate crConverterInterface - latencies *prometheus.HistogramVec + latencies *metrics.HistogramVec crdName string } @@ -57,14 +59,15 @@ func (c *converterMetricFactory) addMetrics(converterName string, crdName string defer c.factoryLock.Unlock() metric, exists := c.durations[converterName] if !exists { - metric = prometheus.NewHistogramVec( - prometheus.HistogramOpts{ - Name: fmt.Sprintf("apiserver_crd_%s_conversion_duration_seconds", converterName), - Help: fmt.Sprintf("CRD %s conversion duration in seconds", converterName), - Buckets: latencyBuckets, + metric = metrics.NewHistogramVec( + &metrics.HistogramOpts{ + Name: fmt.Sprintf("apiserver_crd_%s_conversion_duration_seconds", converterName), + Help: fmt.Sprintf("CRD %s conversion duration in seconds", converterName), + Buckets: latencyBuckets, + StabilityLevel: metrics.ALPHA, }, []string{"crd_name", "from_version", "to_version", "succeeded"}) - err := prometheus.Register(metric) + err := legacyregistry.Register(metric) if err != nil { return nil, err } diff --git a/staging/src/k8s.io/apimachinery/go.sum b/staging/src/k8s.io/apimachinery/go.sum index ac66b1a4059..20431d4677c 100644 --- a/staging/src/k8s.io/apimachinery/go.sum +++ b/staging/src/k8s.io/apimachinery/go.sum @@ -87,6 +87,7 @@ gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.8 h1:obN1ZagJSUGI0Ek/LBmuj4SNLPfIny3KsKFopxRdj10= gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +k8s.io/klog v1.0.0 h1:Pt+yjF5aB1xDSVbau4VsWe+dQNzA0qv1LlXdC2dF6Q8= k8s.io/klog v1.0.0/go.mod h1:4Bi6QPql/J/LkTDqv7R/cd3hPo4k2DG6Ptcz060Ez5I= k8s.io/kube-openapi v0.0.0-20190228160746-b3a7cee44a30 h1:TRb4wNWoBVrH9plmkp2q86FIDppkbrEXdXlxU3a3BMI= k8s.io/kube-openapi v0.0.0-20190228160746-b3a7cee44a30/go.mod h1:BXM9ceUBTj2QnfH2MK1odQs778ajze1RxcmP6S8RVVc= diff --git a/staging/src/k8s.io/apiserver/go.mod b/staging/src/k8s.io/apiserver/go.mod index a8bf86b6133..1b7a9f58c75 100644 --- a/staging/src/k8s.io/apiserver/go.mod +++ b/staging/src/k8s.io/apiserver/go.mod @@ -52,7 +52,7 @@ require ( k8s.io/klog v1.0.0 k8s.io/kube-openapi v0.0.0-20200121204235-bf4fb3bd569c k8s.io/utils v0.0.0-20200324210504-a9aa75ae1b89 - sigs.k8s.io/structured-merge-diff v0.0.0-20190302045857-e85c7b244fd2 + sigs.k8s.io/structured-merge-diff v0.0.0-20190719182312-e94e05bfbbe3 sigs.k8s.io/yaml v1.2.0 ) @@ -65,7 +65,6 @@ replace ( github.com/google/gofuzz => github.com/google/gofuzz v0.0.0-20170612174753-24818f796faf github.com/googleapis/gnostic => github.com/googleapis/gnostic v0.0.0-20170729233727-0c5108395e2d github.com/grpc-ecosystem/go-grpc-middleware => github.com/grpc-ecosystem/go-grpc-middleware v0.0.0-20190222133341-cfaf5686ec79 - github.com/grpc-ecosystem/go-grpc-prometheus => github.com/grpc-ecosystem/go-grpc-prometheus v0.0.0-20170330212424-2500245aa611 github.com/grpc-ecosystem/grpc-gateway => github.com/grpc-ecosystem/grpc-gateway v1.3.0 github.com/hashicorp/golang-lru => github.com/hashicorp/golang-lru v0.5.0 github.com/jonboulle/clockwork => github.com/jonboulle/clockwork v0.0.0-20141017032234-72f9bd7c4e0c diff --git a/staging/src/k8s.io/apiserver/go.sum b/staging/src/k8s.io/apiserver/go.sum index 7ab3d72a95d..39a431745d2 100644 --- a/staging/src/k8s.io/apiserver/go.sum +++ b/staging/src/k8s.io/apiserver/go.sum @@ -22,10 +22,12 @@ github.com/bgentry/speakeasy v0.1.0/go.mod h1:+zsyZBPWlz7T6j88CTgSN5bM796AkVf0kB github.com/blang/semver v3.5.0+incompatible/go.mod h1:kRBLl5iJ+tD4TcOOxsy/0fnwebNt5EWlYSAyrTnjyyk= github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= +github.com/cockroachdb/datadriven v0.0.0-20190809214429-80d97fb3cbaa h1:OaNxuTZr7kxeODyLWsRMC+OD03aFUH+mW6r2d+MWa5Y= github.com/cockroachdb/datadriven v0.0.0-20190809214429-80d97fb3cbaa/go.mod h1:zn76sxSg3SzpJ0PPJaLDCu+Bu0Lg3sKTORVIj19EIF8= github.com/coreos/go-oidc v0.0.0-20180117170138-065b426bd416 h1:X+JQSgXg3CcxgcBoMAqU8NoS0fch8zHxjiKWcXclxaI= github.com/coreos/go-oidc v0.0.0-20180117170138-065b426bd416/go.mod h1:CgnwVTmzoESiwO9qyAFEMiHoZ1nMCKZlZ9V6mm3/LKc= github.com/coreos/go-semver v0.2.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk= +github.com/coreos/go-semver v0.3.0 h1:wkHLiw0WNATZnSG7epLsujiMCgPAc9xhjJ4tgnAxmfM= github.com/coreos/go-semver v0.3.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk= github.com/coreos/go-systemd v0.0.0-20180511133405-39ca1b05acc7 h1:u9SHYsPQNyt5tgDm3YN7+9dYrpK96E5wFilTFWIDZOM= github.com/coreos/go-systemd v0.0.0-20180511133405-39ca1b05acc7/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4= @@ -44,6 +46,7 @@ github.com/docker/docker v0.7.3-0.20190327010347-be7ac8be2ae0 h1:w3NnFcKR5241cfm github.com/docker/docker v0.7.3-0.20190327010347-be7ac8be2ae0/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk= github.com/docker/spdystream v0.0.0-20160310174837-449fdfce4d96/go.mod h1:Qh8CwZgvJUkLughtfhJv5dyTYa91l1fOUCrgjqmcifM= github.com/dustin/go-humanize v0.0.0-20171111073723-bb3d318650d4/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk= +github.com/dustin/go-humanize v1.0.0 h1:VSnTsYCnlFHaM2/igO1h6X3HA71jcobQuxemgkq4zYo= github.com/dustin/go-humanize v1.0.0/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk= github.com/elazarl/goproxy v0.0.0-20180725130230-947c36da3153/go.mod h1:/Zj4wYkgs4iZTTu3o/KG3Itv/qCCa8VVMlb3i9OVuzc= github.com/emicklei/go-restful v2.9.5+incompatible h1:spTtZBk5DYEvbxMVutUuTyh1Ao2r4iyvLdACqsl/Ljk= @@ -80,6 +83,7 @@ github.com/golang/protobuf v1.2.0 h1:P3YflyNX/ehuJFLhxviNdFxQPkGK5cDcApsge1SqnvM github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/golang/protobuf v1.3.2 h1:6nsPYzhq5kReh6QImI3k5qWzO4PEbvbIW2cwSfR/6xs= github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= +github.com/google/btree v1.0.0 h1:0udJVsspx3VBr5FwtLhQQtuAsVc79tTq0ocGIPAU6qo= github.com/google/btree v1.0.0/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M= github.com/google/go-cmp v0.3.0 h1:crn/baboCvb5fXaQ0IJ1SGTsTVrWpDsCWC8EGETZijY= @@ -97,12 +101,13 @@ github.com/gorilla/websocket v0.0.0-20170926233335-4201258b820c h1:Lh2aW+HnU2Nbe github.com/gorilla/websocket v0.0.0-20170926233335-4201258b820c/go.mod h1:E7qHFY5m1UJ88s3WnNqhKjPHQ0heANvMoAMk2YaljkQ= github.com/gorilla/websocket v1.4.0 h1:WDFjx/TMzVgy9VdMMQi2K2Emtwi2QcUQsztZ/zLaH/Q= github.com/gorilla/websocket v1.4.0/go.mod h1:E7qHFY5m1UJ88s3WnNqhKjPHQ0heANvMoAMk2YaljkQ= +github.com/grafov/bcast v0.0.0-20190217190352-1447f067e08d h1:Q2+KsA/1GLC9xyLsDun3/EOJ+83rY/IHRsO1DToPrdo= github.com/grafov/bcast v0.0.0-20190217190352-1447f067e08d/go.mod h1:RInr+B3/Tx70hYm0rpNPMTD7vH0pBG5ny/JsHAs2KcQ= github.com/gregjones/httpcache v0.0.0-20180305231024-9cad4c3443a7/go.mod h1:FecbI9+v66THATjSRHfNgh1IVFe/9kFxbXtjV0ctIMA= github.com/grpc-ecosystem/go-grpc-middleware v0.0.0-20190222133341-cfaf5686ec79 h1:lR9ssWAqp9qL0bALxqEEkuudiP1eweOdv9jsRK3e7lE= github.com/grpc-ecosystem/go-grpc-middleware v0.0.0-20190222133341-cfaf5686ec79/go.mod h1:FiyG127CGDf3tlThmgyCl78X/SZQqEOJBCDaAfeWzPs= -github.com/grpc-ecosystem/go-grpc-prometheus v0.0.0-20170330212424-2500245aa611 h1:f5vL2EW5pL274ztMNnizZAEa457nKyKPEaN/sm/kdBk= -github.com/grpc-ecosystem/go-grpc-prometheus v0.0.0-20170330212424-2500245aa611/go.mod h1:8NvIoxWQoOIhqOTXgfV/d3M/q6VIi02HzZEHgUlZvzk= +github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0 h1:Ovs26xHkKqVztRpIrF/92BcuyuQ/YW4NSIpoGtfXNho= +github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0/go.mod h1:8NvIoxWQoOIhqOTXgfV/d3M/q6VIi02HzZEHgUlZvzk= github.com/grpc-ecosystem/grpc-gateway v1.3.0 h1:HJtP6RRwj2EpPCD/mhAWzSvLL/dFTdPm1UrWwanoFos= github.com/grpc-ecosystem/grpc-gateway v1.3.0/go.mod h1:RSKVYQBd5MCa4OVpNdGskqpgL2+G+NZTnrVHpWWfpdw= github.com/hashicorp/golang-lru v0.5.0 h1:CL2msUPvZTLb5O648aiLNJw3hnBxN2+1Jq8rCOH9wdo= @@ -192,7 +197,9 @@ github.com/tmc/grpc-websocket-proxy v0.0.0-20170815181823-89b8d40f7ca8/go.mod h1 github.com/urfave/cli v1.20.0/go.mod h1:70zkFmudgCuE/ngEzBv17Jvp/497gISqfk5gWijbERA= github.com/xiang90/probing v0.0.0-20160813154853-07dd2e8dfe18 h1:MPPkRncZLN9Kh4MEFmbnK4h3BD7AUmskWv2+EeZJCCs= github.com/xiang90/probing v0.0.0-20160813154853-07dd2e8dfe18/go.mod h1:UETIi67q53MR2AWcXfiuqkDkRtnGDLqkBTpCHuJHxtU= +go.etcd.io/bbolt v1.3.3 h1:MUGmc65QhB3pIlaQ5bB4LwqSj6GIonVJXpZiaKNyaKk= go.etcd.io/bbolt v1.3.3/go.mod h1:IbVyRI1SCnLcuJnV2u8VeU0CEYM7e686BmAb1XKL+uU= +go.etcd.io/etcd v0.5.0-alpha.5.0.20200224211402-c65a9e2dd1fd h1:JwlSZ9TSTcRHDGbIr5QG3MEmKyMK99BbNLMJtwnJ0rY= go.etcd.io/etcd v0.5.0-alpha.5.0.20200224211402-c65a9e2dd1fd/go.mod h1:dnLIgRNXwCJa5e+c6mIZCrds/GIG4ncV9HhK5PX7jPg= go.uber.org/atomic v0.0.0-20181018215023-8dc6146f7569 h1:nSQar3Y0E3VQF/VdZ8PTAilaXpER+d7ypdABCrpwMdg= go.uber.org/atomic v0.0.0-20181018215023-8dc6146f7569/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE= @@ -256,6 +263,7 @@ google.golang.org/grpc v1.26.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8 gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 h1:qIbj1fsPNlZgppZ+VLlY7N33q108Sa+fhmuc+sWQYwY= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/cheggaaa/pb.v1 v1.0.25/go.mod h1:V/YB90LKu/1FcN3WVnfiiE5oMCibMjukxqG/qStrOgw= +gopkg.in/fatih/set.v0 v0.2.1 h1:Xvyyp7LXu34P0ROhCyfXkmQCAoOUKb1E2JS9I7SE5CY= gopkg.in/fatih/set.v0 v0.2.1/go.mod h1:5eLWEndGL4zGGemXWrKuts+wTJR0y+w+auqUJZbmyBg= gopkg.in/fsnotify.v1 v1.4.7 h1:xOHLXZwVvI9hhs+cLKq5+I5onOuwQLhQwiu63xxlHs4= gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys= @@ -277,12 +285,13 @@ gotest.tools v2.2.0+incompatible h1:VsBPFP1AI068pPrMxtb/S8Zkgf9xEmTLJjfM+P5UIEo= gotest.tools v2.2.0+incompatible/go.mod h1:DsYFclhRJ6vuDpmuTbkuFWG+y2sxOXAzmJt81HFBacw= honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= +k8s.io/klog v1.0.0 h1:Pt+yjF5aB1xDSVbau4VsWe+dQNzA0qv1LlXdC2dF6Q8= k8s.io/klog v1.0.0/go.mod h1:4Bi6QPql/J/LkTDqv7R/cd3hPo4k2DG6Ptcz060Ez5I= k8s.io/kube-openapi v0.0.0-20190228160746-b3a7cee44a30 h1:TRb4wNWoBVrH9plmkp2q86FIDppkbrEXdXlxU3a3BMI= k8s.io/kube-openapi v0.0.0-20190228160746-b3a7cee44a30/go.mod h1:BXM9ceUBTj2QnfH2MK1odQs778ajze1RxcmP6S8RVVc= k8s.io/utils v0.0.0-20190221042446-c2654d5206da h1:ElyM7RPonbKnQqOcw7dG2IK5uvQQn3b/WPHqD5mBvP4= k8s.io/utils v0.0.0-20190221042446-c2654d5206da/go.mod h1:8k8uAuAQ0rXslZKaEWd0c3oVhZz7sSzSiPnVZayjIX0= -sigs.k8s.io/structured-merge-diff v0.0.0-20190302045857-e85c7b244fd2 h1:9r5DY45ef9LtcA6BnkhW8MPV7OKAfbf2AUwUhq3LeRk= -sigs.k8s.io/structured-merge-diff v0.0.0-20190302045857-e85c7b244fd2/go.mod h1:wWxsB5ozmmv/SG7nM11ayaAW51xMvak/t1r0CSlcokI= +sigs.k8s.io/structured-merge-diff v0.0.0-20190719182312-e94e05bfbbe3 h1:yCY9zAYErawYwXdOYmwEBzcGCr/6eIUujYZE2DIQve8= +sigs.k8s.io/structured-merge-diff v0.0.0-20190719182312-e94e05bfbbe3/go.mod h1:wWxsB5ozmmv/SG7nM11ayaAW51xMvak/t1r0CSlcokI= sigs.k8s.io/yaml v1.1.0 h1:4A07+ZFc2wgJwo8YNlQpr1rVlgUDlxXHhPJciaPY5gs= sigs.k8s.io/yaml v1.1.0/go.mod h1:UJmg0vDUVViEyp3mgSv9WPwZCDxu4rQW1olrI1uml+o= diff --git a/staging/src/k8s.io/apiserver/pkg/admission/metrics/BUILD b/staging/src/k8s.io/apiserver/pkg/admission/metrics/BUILD index e0f92b550d1..98e129cb9d5 100644 --- a/staging/src/k8s.io/apiserver/pkg/admission/metrics/BUILD +++ b/staging/src/k8s.io/apiserver/pkg/admission/metrics/BUILD @@ -8,7 +8,8 @@ go_library( visibility = ["//visibility:public"], deps = [ "//staging/src/k8s.io/apiserver/pkg/admission:go_default_library", - "//vendor/github.com/prometheus/client_golang/prometheus:go_default_library", + "//staging/src/k8s.io/component-base/metrics:go_default_library", + "//staging/src/k8s.io/component-base/metrics/legacyregistry:go_default_library", ], ) @@ -24,7 +25,7 @@ go_test( "//staging/src/k8s.io/apimachinery/pkg/runtime:go_default_library", "//staging/src/k8s.io/apimachinery/pkg/runtime/schema:go_default_library", "//staging/src/k8s.io/apiserver/pkg/admission:go_default_library", - "//vendor/github.com/prometheus/client_golang/prometheus:go_default_library", + "//staging/src/k8s.io/component-base/metrics/legacyregistry:go_default_library", "//vendor/github.com/prometheus/client_model/go:go_default_library", ], ) diff --git a/staging/src/k8s.io/apiserver/pkg/admission/metrics/metrics.go b/staging/src/k8s.io/apiserver/pkg/admission/metrics/metrics.go index 56cc07edd39..13946201653 100644 --- a/staging/src/k8s.io/apiserver/pkg/admission/metrics/metrics.go +++ b/staging/src/k8s.io/apiserver/pkg/admission/metrics/metrics.go @@ -21,9 +21,9 @@ import ( "strconv" "time" - "github.com/prometheus/client_golang/prometheus" - "k8s.io/apiserver/pkg/admission" + "k8s.io/component-base/metrics" + "k8s.io/component-base/metrics/legacyregistry" ) const ( @@ -153,33 +153,35 @@ func (m *AdmissionMetrics) ObserveWebhook(elapsed time.Duration, rejected bool, } type metricSet struct { - latencies *prometheus.HistogramVec - latenciesSummary *prometheus.SummaryVec + latencies *metrics.HistogramVec + latenciesSummary *metrics.SummaryVec } func newMetricSet(name string, labels []string, helpTemplate string, hasSummary bool) *metricSet { - var summary *prometheus.SummaryVec + var summary *metrics.SummaryVec if hasSummary { - summary = prometheus.NewSummaryVec( - prometheus.SummaryOpts{ - Namespace: namespace, - Subsystem: subsystem, - Name: fmt.Sprintf("%s_admission_duration_seconds_summary", name), - Help: fmt.Sprintf(helpTemplate, "latency summary in seconds"), - MaxAge: latencySummaryMaxAge, + summary = metrics.NewSummaryVec( + &metrics.SummaryOpts{ + Namespace: namespace, + Subsystem: subsystem, + Name: fmt.Sprintf("%s_admission_duration_seconds_summary", name), + Help: fmt.Sprintf(helpTemplate, "latency summary in seconds"), + MaxAge: latencySummaryMaxAge, + StabilityLevel: metrics.ALPHA, }, labels, ) } return &metricSet{ - latencies: prometheus.NewHistogramVec( - prometheus.HistogramOpts{ - Namespace: namespace, - Subsystem: subsystem, - Name: fmt.Sprintf("%s_admission_duration_seconds", name), - Help: fmt.Sprintf(helpTemplate, "latency histogram in seconds"), - Buckets: latencyBuckets, + latencies: metrics.NewHistogramVec( + &metrics.HistogramOpts{ + Namespace: namespace, + Subsystem: subsystem, + Name: fmt.Sprintf("%s_admission_duration_seconds", name), + Help: fmt.Sprintf(helpTemplate, "latency histogram in seconds"), + Buckets: latencyBuckets, + StabilityLevel: metrics.ALPHA, }, labels, ), @@ -190,9 +192,9 @@ func newMetricSet(name string, labels []string, helpTemplate string, hasSummary // MustRegister registers all the prometheus metrics in the metricSet. func (m *metricSet) mustRegister() { - prometheus.MustRegister(m.latencies) + legacyregistry.MustRegister(m.latencies) if m.latenciesSummary != nil { - prometheus.MustRegister(m.latenciesSummary) + legacyregistry.MustRegister(m.latenciesSummary) } } diff --git a/staging/src/k8s.io/apiserver/pkg/admission/metrics/testutil_test.go b/staging/src/k8s.io/apiserver/pkg/admission/metrics/testutil_test.go index af5ee79a8b6..97813605d4f 100644 --- a/staging/src/k8s.io/apiserver/pkg/admission/metrics/testutil_test.go +++ b/staging/src/k8s.io/apiserver/pkg/admission/metrics/testutil_test.go @@ -1,5 +1,6 @@ /* Copyright 2017 The Kubernetes Authors. +Copyright 2020 Authors of Arktos - file modified. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -17,9 +18,9 @@ limitations under the License. package metrics import ( + "k8s.io/component-base/metrics/legacyregistry" "testing" - "github.com/prometheus/client_golang/prometheus" ptype "github.com/prometheus/client_model/go" ) @@ -34,7 +35,7 @@ func labelsMatch(metric *ptype.Metric, labelFilter map[string]string) bool { // expectFindMetric find a metric with the given name nad labels or reports a fatal test error. func expectFindMetric(t *testing.T, name string, expectedLabels map[string]string) *ptype.Metric { - metrics, err := prometheus.DefaultGatherer.Gather() + metrics, err := legacyregistry.DefaultGatherer.Gather() if err != nil { t.Fatalf("Failed to gather metrics: %s", err) } @@ -61,7 +62,7 @@ func expectFindMetric(t *testing.T, name string, expectedLabels map[string]strin // expectHistogramCountTotal ensures that the sum of counts of metrics matching the labelFilter is as // expected. func expectHistogramCountTotal(t *testing.T, name string, labelFilter map[string]string, wantCount int) { - metrics, err := prometheus.DefaultGatherer.Gather() + metrics, err := legacyregistry.DefaultGatherer.Gather() if err != nil { t.Fatalf("Failed to gather metrics: %s", err) } diff --git a/staging/src/k8s.io/apiserver/pkg/audit/BUILD b/staging/src/k8s.io/apiserver/pkg/audit/BUILD index f6923a2828a..92726d869cf 100644 --- a/staging/src/k8s.io/apiserver/pkg/audit/BUILD +++ b/staging/src/k8s.io/apiserver/pkg/audit/BUILD @@ -34,8 +34,9 @@ go_library( "//staging/src/k8s.io/apiserver/pkg/apis/audit/v1beta1:go_default_library", "//staging/src/k8s.io/apiserver/pkg/authentication/user:go_default_library", "//staging/src/k8s.io/apiserver/pkg/authorization/authorizer:go_default_library", + "//staging/src/k8s.io/component-base/metrics:go_default_library", + "//staging/src/k8s.io/component-base/metrics/legacyregistry:go_default_library", "//vendor/github.com/pborman/uuid:go_default_library", - "//vendor/github.com/prometheus/client_golang/prometheus:go_default_library", "//vendor/k8s.io/klog:go_default_library", ], ) diff --git a/staging/src/k8s.io/apiserver/pkg/audit/metrics.go b/staging/src/k8s.io/apiserver/pkg/audit/metrics.go index 9b81b30cc26..88d4154e8ae 100644 --- a/staging/src/k8s.io/apiserver/pkg/audit/metrics.go +++ b/staging/src/k8s.io/apiserver/pkg/audit/metrics.go @@ -19,8 +19,9 @@ package audit import ( "fmt" - "github.com/prometheus/client_golang/prometheus" auditinternal "k8s.io/apiserver/pkg/apis/audit" + "k8s.io/component-base/metrics" + "k8s.io/component-base/metrics/legacyregistry" "k8s.io/klog" ) @@ -28,46 +29,58 @@ const ( subsystem = "apiserver_audit" ) +/* + * By default, all the following metrics are defined as falling under + * ALPHA stability level https://github.com/kubernetes/enhancements/blob/master/keps/sig-instrumentation/20190404-kubernetes-control-plane-metrics-stability.md#stability-classes) + * + * Promoting the stability level of the metric is a responsibility of the component owner, since it + * involves explicitly acknowledging support for the metric across multiple releases, in accordance with + * the metric stability policy. + */ var ( - eventCounter = prometheus.NewCounter( - prometheus.CounterOpts{ - Subsystem: subsystem, - Name: "event_total", - Help: "Counter of audit events generated and sent to the audit backend.", + eventCounter = metrics.NewCounter( + &metrics.CounterOpts{ + Subsystem: subsystem, + Name: "event_total", + Help: "Counter of audit events generated and sent to the audit backend.", + StabilityLevel: metrics.ALPHA, }) - errorCounter = prometheus.NewCounterVec( - prometheus.CounterOpts{ + errorCounter = metrics.NewCounterVec( + &metrics.CounterOpts{ Subsystem: subsystem, Name: "error_total", Help: "Counter of audit events that failed to be audited properly. " + "Plugin identifies the plugin affected by the error.", + StabilityLevel: metrics.ALPHA, }, []string{"plugin"}, ) - levelCounter = prometheus.NewCounterVec( - prometheus.CounterOpts{ - Subsystem: subsystem, - Name: "level_total", - Help: "Counter of policy levels for audit events (1 per request).", + levelCounter = metrics.NewCounterVec( + &metrics.CounterOpts{ + Subsystem: subsystem, + Name: "level_total", + Help: "Counter of policy levels for audit events (1 per request).", + StabilityLevel: metrics.ALPHA, }, []string{"level"}, ) - ApiserverAuditDroppedCounter = prometheus.NewCounter( - prometheus.CounterOpts{ + ApiserverAuditDroppedCounter = metrics.NewCounter( + &metrics.CounterOpts{ Subsystem: subsystem, Name: "requests_rejected_total", Help: "Counter of apiserver requests rejected due to an error " + "in audit logging backend.", + StabilityLevel: metrics.ALPHA, }, ) ) func init() { - prometheus.MustRegister(eventCounter) - prometheus.MustRegister(errorCounter) - prometheus.MustRegister(levelCounter) - prometheus.MustRegister(ApiserverAuditDroppedCounter) + legacyregistry.MustRegister(eventCounter) + legacyregistry.MustRegister(errorCounter) + legacyregistry.MustRegister(levelCounter) + legacyregistry.MustRegister(ApiserverAuditDroppedCounter) } // ObserveEvent updates the relevant prometheus metrics for the generated audit event. diff --git a/staging/src/k8s.io/apiserver/pkg/authentication/request/x509/BUILD b/staging/src/k8s.io/apiserver/pkg/authentication/request/x509/BUILD index 399197ea136..f75340b599d 100644 --- a/staging/src/k8s.io/apiserver/pkg/authentication/request/x509/BUILD +++ b/staging/src/k8s.io/apiserver/pkg/authentication/request/x509/BUILD @@ -36,7 +36,8 @@ go_library( "//staging/src/k8s.io/apimachinery/pkg/util/sets:go_default_library", "//staging/src/k8s.io/apiserver/pkg/authentication/authenticator:go_default_library", "//staging/src/k8s.io/apiserver/pkg/authentication/user:go_default_library", - "//vendor/github.com/prometheus/client_golang/prometheus:go_default_library", + "//staging/src/k8s.io/component-base/metrics:go_default_library", + "//staging/src/k8s.io/component-base/metrics/legacyregistry:go_default_library", ], ) diff --git a/staging/src/k8s.io/apiserver/pkg/authentication/request/x509/x509.go b/staging/src/k8s.io/apiserver/pkg/authentication/request/x509/x509.go index 007312b5bae..56fbbf6ba7f 100644 --- a/staging/src/k8s.io/apiserver/pkg/authentication/request/x509/x509.go +++ b/staging/src/k8s.io/apiserver/pkg/authentication/request/x509/x509.go @@ -26,20 +26,28 @@ import ( "strings" "time" - "github.com/prometheus/client_golang/prometheus" - utilerrors "k8s.io/apimachinery/pkg/util/errors" "k8s.io/apimachinery/pkg/util/sets" "k8s.io/apiserver/pkg/authentication/authenticator" "k8s.io/apiserver/pkg/authentication/user" + "k8s.io/component-base/metrics" + "k8s.io/component-base/metrics/legacyregistry" ) const ErrTenantEmptyCN = "CN name cannot be empty" const ErrMultipleOrganizationsWithTenant = "more than one organization with tenants specified" const ErrMultipleTenants = "more than one tenants specified in an organization " -var clientCertificateExpirationHistogram = prometheus.NewHistogram( - prometheus.HistogramOpts{ +/* + * By default, the following metric is defined as falling under + * ALPHA stability level https://github.com/kubernetes/enhancements/blob/master/keps/sig-instrumentation/20190404-kubernetes-control-plane-metrics-stability.md#stability-classes) + * + * Promoting the stability level of the metric is a responsibility of the component owner, since it + * involves explicitly acknowledging support for the metric across multiple releases, in accordance with + * the metric stability policy. + */ +var clientCertificateExpirationHistogram = metrics.NewHistogram( + &metrics.HistogramOpts{ Namespace: "apiserver", Subsystem: "client", Name: "certificate_expiration_seconds", @@ -60,11 +68,12 @@ var clientCertificateExpirationHistogram = prometheus.NewHistogram( (6 * 30 * 24 * time.Hour).Seconds(), (12 * 30 * 24 * time.Hour).Seconds(), }, + StabilityLevel: metrics.ALPHA, }, ) func init() { - prometheus.MustRegister(clientCertificateExpirationHistogram) + legacyregistry.MustRegister(clientCertificateExpirationHistogram) } // UserConversion defines an interface for extracting user info from a client certificate chain diff --git a/staging/src/k8s.io/apiserver/pkg/endpoints/filters/BUILD b/staging/src/k8s.io/apiserver/pkg/endpoints/filters/BUILD index bbedebe4c14..52dd7632b12 100644 --- a/staging/src/k8s.io/apiserver/pkg/endpoints/filters/BUILD +++ b/staging/src/k8s.io/apiserver/pkg/endpoints/filters/BUILD @@ -70,7 +70,8 @@ go_library( "//staging/src/k8s.io/apiserver/pkg/endpoints/handlers/responsewriters:go_default_library", "//staging/src/k8s.io/apiserver/pkg/endpoints/request:go_default_library", "//staging/src/k8s.io/apiserver/pkg/server/httplog:go_default_library", - "//vendor/github.com/prometheus/client_golang/prometheus:go_default_library", + "//staging/src/k8s.io/component-base/metrics:go_default_library", + "//staging/src/k8s.io/component-base/metrics/legacyregistry:go_default_library", "//vendor/k8s.io/klog:go_default_library", ], ) diff --git a/staging/src/k8s.io/apiserver/pkg/endpoints/filters/authentication.go b/staging/src/k8s.io/apiserver/pkg/endpoints/filters/authentication.go index aeeb6fdb5df..1d868a7ff0a 100644 --- a/staging/src/k8s.io/apiserver/pkg/endpoints/filters/authentication.go +++ b/staging/src/k8s.io/apiserver/pkg/endpoints/filters/authentication.go @@ -22,29 +22,38 @@ import ( "net/http" "strings" - "github.com/prometheus/client_golang/prometheus" - "k8s.io/klog" - apierrors "k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/runtime/schema" "k8s.io/apiserver/pkg/authentication/authenticator" "k8s.io/apiserver/pkg/endpoints/handlers/responsewriters" genericapirequest "k8s.io/apiserver/pkg/endpoints/request" + "k8s.io/component-base/metrics" + "k8s.io/component-base/metrics/legacyregistry" + "k8s.io/klog" ) +/* + * By default, all the following metrics are defined as falling under + * ALPHA stability level https://github.com/kubernetes/enhancements/blob/master/keps/sig-instrumentation/20190404-kubernetes-control-plane-metrics-stability.md#stability-classes) + * + * Promoting the stability level of the metric is a responsibility of the component owner, since it + * involves explicitly acknowledging support for the metric across multiple releases, in accordance with + * the metric stability policy. + */ var ( - authenticatedUserCounter = prometheus.NewCounterVec( - prometheus.CounterOpts{ - Name: "authenticated_user_requests", - Help: "Counter of authenticated requests broken out by username.", + authenticatedUserCounter = metrics.NewCounterVec( + &metrics.CounterOpts{ + Name: "authenticated_user_requests", + Help: "Counter of authenticated requests broken out by username.", + StabilityLevel: metrics.ALPHA, }, []string{"username"}, ) ) func init() { - prometheus.MustRegister(authenticatedUserCounter) + legacyregistry.MustRegister(authenticatedUserCounter) } // WithAuthentication creates an http handler that tries to authenticate the given request as a user, and then diff --git a/staging/src/k8s.io/apiserver/pkg/endpoints/handlers/fieldmanager/internal/pathelement.go b/staging/src/k8s.io/apiserver/pkg/endpoints/handlers/fieldmanager/internal/pathelement.go index e2b63362f37..62f41507dcf 100644 --- a/staging/src/k8s.io/apiserver/pkg/endpoints/handlers/fieldmanager/internal/pathelement.go +++ b/staging/src/k8s.io/apiserver/pkg/endpoints/handlers/fieldmanager/internal/pathelement.go @@ -94,7 +94,7 @@ func NewPathElement(s string) (fieldpath.PathElement, error) { }) } return fieldpath.PathElement{ - Key: fields, + Key: &value.Map{Items: fields}, }, nil default: // Ignore unknown key types @@ -107,9 +107,9 @@ func PathElementString(pe fieldpath.PathElement) (string, error) { switch { case pe.FieldName != nil: return Field + Separator + *pe.FieldName, nil - case len(pe.Key) > 0: + case pe.Key != nil: kv := map[string]json.RawMessage{} - for _, k := range pe.Key { + for _, k := range pe.Key.Items { b, err := k.Value.ToJSON() if err != nil { return "", err diff --git a/staging/src/k8s.io/apiserver/pkg/endpoints/metrics/BUILD b/staging/src/k8s.io/apiserver/pkg/endpoints/metrics/BUILD index 4df68923804..95e8093e922 100644 --- a/staging/src/k8s.io/apiserver/pkg/endpoints/metrics/BUILD +++ b/staging/src/k8s.io/apiserver/pkg/endpoints/metrics/BUILD @@ -25,6 +25,8 @@ go_library( "//staging/src/k8s.io/apiserver/pkg/endpoints/request:go_default_library", "//staging/src/k8s.io/apiserver/pkg/features:go_default_library", "//staging/src/k8s.io/apiserver/pkg/util/feature:go_default_library", + "//staging/src/k8s.io/component-base/metrics:go_default_library", + "//staging/src/k8s.io/component-base/metrics/legacyregistry:go_default_library", "//vendor/github.com/emicklei/go-restful:go_default_library", "//vendor/github.com/prometheus/client_golang/prometheus:go_default_library", ], diff --git a/staging/src/k8s.io/apiserver/pkg/endpoints/metrics/metrics.go b/staging/src/k8s.io/apiserver/pkg/endpoints/metrics/metrics.go index 7c5154295ee..33c61ca2829 100644 --- a/staging/src/k8s.io/apiserver/pkg/endpoints/metrics/metrics.go +++ b/staging/src/k8s.io/apiserver/pkg/endpoints/metrics/metrics.go @@ -27,6 +27,9 @@ import ( "sync" "time" + restful "github.com/emicklei/go-restful" + "github.com/prometheus/client_golang/prometheus" + "k8s.io/apimachinery/pkg/apis/meta/v1/validation" "k8s.io/apimachinery/pkg/types" utilnet "k8s.io/apimachinery/pkg/util/net" @@ -34,15 +37,14 @@ import ( "k8s.io/apiserver/pkg/endpoints/request" "k8s.io/apiserver/pkg/features" utilfeature "k8s.io/apiserver/pkg/util/feature" - - restful "github.com/emicklei/go-restful" - "github.com/prometheus/client_golang/prometheus" + compbasemetrics "k8s.io/component-base/metrics" + "k8s.io/component-base/metrics/legacyregistry" ) // resettableCollector is the interface implemented by prometheus.MetricVec // that can be used by Prometheus to collect metrics and reset their values. type resettableCollector interface { - prometheus.Collector + compbasemetrics.Registerable Reset() } @@ -50,13 +52,22 @@ const ( APIServerComponent string = "apiserver" ) +/* + * By default, all the following metrics are defined as falling under + * ALPHA stability level https://github.com/kubernetes/enhancements/blob/master/keps/sig-instrumentation/20190404-kubernetes-control-plane-metrics-stability.md#stability-classes) + * + * Promoting the stability level of the metric is a responsibility of the component owner, since it + * involves explicitly acknowledging support for the metric across multiple releases, in accordance with + * the metric stability policy. + */ var ( // TODO(a-robinson): Add unit tests for the handling of these metrics once // the upstream library supports it. - requestCounter = prometheus.NewCounterVec( - prometheus.CounterOpts{ - Name: "apiserver_request_total", - Help: "Counter of apiserver requests broken out for each verb, dry run value, group, version, resource, scope, component, client, and HTTP response contentType and code.", + requestCounter = compbasemetrics.NewCounterVec( + &compbasemetrics.CounterOpts{ + Name: "apiserver_request_total", + Help: "Counter of apiserver requests broken out for each verb, dry run value, group, version, resource, scope, component, client, and HTTP response contentType and code.", + StabilityLevel: compbasemetrics.ALPHA, }, // The label_name contentType doesn't follow the label_name convention defined here: // https://github.com/kubernetes/community/blob/master/contributors/devel/sig-instrumentation/instrumentation.md @@ -64,22 +75,24 @@ var ( // should be all lowercase and separated by underscores. []string{"verb", "dry_run", "group", "version", "resource", "subresource", "scope", "component", "client", "contentType", "code"}, ) - deprecatedRequestCounter = prometheus.NewCounterVec( - prometheus.CounterOpts{ - Name: "apiserver_request_count", - Help: "(Deprecated) Counter of apiserver requests broken out for each verb, group, version, resource, scope, component, client, and HTTP response contentType and code.", + deprecatedRequestCounter = compbasemetrics.NewCounterVec( + &compbasemetrics.CounterOpts{ + Name: "apiserver_request_count", + Help: "(Deprecated) Counter of apiserver requests broken out for each verb, group, version, resource, scope, component, client, and HTTP response contentType and code.", + StabilityLevel: compbasemetrics.ALPHA, }, []string{"verb", "group", "version", "resource", "subresource", "scope", "component", "client", "contentType", "code"}, ) - longRunningRequestGauge = prometheus.NewGaugeVec( - prometheus.GaugeOpts{ - Name: "apiserver_longrunning_gauge", - Help: "Gauge of all active long-running apiserver requests broken out by verb, group, version, resource, scope and component. Not all requests are tracked this way.", + longRunningRequestGauge = compbasemetrics.NewGaugeVec( + &compbasemetrics.GaugeOpts{ + Name: "apiserver_longrunning_gauge", + Help: "Gauge of all active long-running apiserver requests broken out by verb, group, version, resource, scope and component. Not all requests are tracked this way.", + StabilityLevel: compbasemetrics.ALPHA, }, []string{"verb", "group", "version", "resource", "subresource", "scope", "component"}, ) - requestLatencies = prometheus.NewHistogramVec( - prometheus.HistogramOpts{ + requestLatencies = compbasemetrics.NewHistogramVec( + &compbasemetrics.HistogramOpts{ Name: "apiserver_request_duration_seconds", Help: "Response latency distribution in seconds for each verb, dry run value, group, version, resource, subresource, scope and component.", // This metric is used for verifying api call latencies SLO, @@ -87,66 +100,94 @@ var ( // Thus we customize buckets significantly, to empower both usecases. Buckets: []float64{0.05, 0.1, 0.15, 0.2, 0.25, 0.3, 0.35, 0.4, 0.45, 0.5, 0.6, 0.7, 0.8, 0.9, 1.0, 1.25, 1.5, 1.75, 2.0, 2.5, 3.0, 3.5, 4.0, 4.5, 5, 6, 7, 8, 9, 10, 15, 20, 25, 30, 40, 50, 60}, + StabilityLevel: compbasemetrics.ALPHA, }, []string{"verb", "dry_run", "group", "version", "resource", "subresource", "scope", "component"}, ) - deprecatedRequestLatencies = prometheus.NewHistogramVec( - prometheus.HistogramOpts{ + deprecatedRequestLatencies = compbasemetrics.NewHistogramVec( + &compbasemetrics.HistogramOpts{ Name: "apiserver_request_latencies", Help: "(Deprecated) Response latency distribution in microseconds for each verb, group, version, resource, subresource, scope and component.", // Use buckets ranging from 125 ms to 8 seconds. - Buckets: prometheus.ExponentialBuckets(125000, 2.0, 7), + Buckets: prometheus.ExponentialBuckets(125000, 2.0, 7), + StabilityLevel: compbasemetrics.ALPHA, }, []string{"verb", "group", "version", "resource", "subresource", "scope", "component"}, ) - deprecatedRequestLatenciesSummary = prometheus.NewSummaryVec( - prometheus.SummaryOpts{ + deprecatedRequestLatenciesSummary = compbasemetrics.NewSummaryVec( + &compbasemetrics.SummaryOpts{ Name: "apiserver_request_latencies_summary", Help: "(Deprecated) Response latency summary in microseconds for each verb, group, version, resource, subresource, scope and component.", // Make the sliding window of 5h. // TODO: The value for this should be based on our SLI definition (medium term). - MaxAge: 5 * time.Hour, + MaxAge: 5 * time.Hour, + StabilityLevel: compbasemetrics.ALPHA, }, []string{"verb", "group", "version", "resource", "subresource", "scope", "component"}, ) - responseSizes = prometheus.NewHistogramVec( - prometheus.HistogramOpts{ + responseSizes = compbasemetrics.NewHistogramVec( + &compbasemetrics.HistogramOpts{ Name: "apiserver_response_sizes", Help: "Response size distribution in bytes for each group, version, verb, resource, subresource, scope and component.", // Use buckets ranging from 1000 bytes (1KB) to 10^9 bytes (1GB). - Buckets: prometheus.ExponentialBuckets(1000, 10.0, 7), + Buckets: prometheus.ExponentialBuckets(1000, 10.0, 7), + StabilityLevel: compbasemetrics.ALPHA, }, []string{"verb", "group", "version", "resource", "subresource", "scope", "component"}, ) // DroppedRequests is a number of requests dropped with 'Try again later' response" - DroppedRequests = prometheus.NewCounterVec( - prometheus.CounterOpts{ - Name: "apiserver_dropped_requests_total", - Help: "Number of requests dropped with 'Try again later' response", + DroppedRequests = compbasemetrics.NewCounterVec( + &compbasemetrics.CounterOpts{ + Name: "apiserver_dropped_requests_total", + Help: "Number of requests dropped with 'Try again later' response", + StabilityLevel: compbasemetrics.ALPHA, }, []string{"requestKind"}, ) - DeprecatedDroppedRequests = prometheus.NewCounterVec( - prometheus.CounterOpts{ - Name: "apiserver_dropped_requests", - Help: "(Deprecated) Number of requests dropped with 'Try again later' response", + DeprecatedDroppedRequests = compbasemetrics.NewCounterVec( + &compbasemetrics.CounterOpts{ + Name: "apiserver_dropped_requests", + Help: "(Deprecated) Number of requests dropped with 'Try again later' response", + StabilityLevel: compbasemetrics.ALPHA, }, []string{"requestKind"}, ) // RegisteredWatchers is a number of currently registered watchers splitted by resource. - RegisteredWatchers = prometheus.NewGaugeVec( - prometheus.GaugeOpts{ - Name: "apiserver_registered_watchers", - Help: "Number of currently registered watchers for a given resources", + RegisteredWatchers = compbasemetrics.NewGaugeVec( + &compbasemetrics.GaugeOpts{ + Name: "apiserver_registered_watchers", + Help: "Number of currently registered watchers for a given resources", + StabilityLevel: compbasemetrics.ALPHA, + }, + []string{"group", "version", "kind"}, + ) + //<<<<<<< HEAD + //======= + WatchEvents = compbasemetrics.NewCounterVec( + &compbasemetrics.CounterOpts{ + Name: "apiserver_watch_events_total", + Help: "Number of events sent in watch clients", + StabilityLevel: compbasemetrics.ALPHA, + }, + []string{"group", "version", "kind"}, + ) + WatchEventsSizes = compbasemetrics.NewHistogramVec( + &compbasemetrics.HistogramOpts{ + Name: "apiserver_watch_events_sizes", + Help: "Watch event size distribution in bytes", + Buckets: prometheus.ExponentialBuckets(1024, 2.0, 8), // 1K, 2K, 4K, 8K, ..., 128K. + StabilityLevel: compbasemetrics.ALPHA, }, []string{"group", "version", "kind"}, ) + //>>>>>>> 466980d... migrate kube-apiserver metrics to stability framework // Because of volatality of the base metric this is pre-aggregated one. Instead of reporing current usage all the time // it reports maximal usage during the last second. - currentInflightRequests = prometheus.NewGaugeVec( - prometheus.GaugeOpts{ - Name: "apiserver_current_inflight_requests", - Help: "Maximal number of currently used inflight request limit of this apiserver per request kind in last second.", + currentInflightRequests = compbasemetrics.NewGaugeVec( + &compbasemetrics.GaugeOpts{ + Name: "apiserver_current_inflight_requests", + Help: "Maximal number of currently used inflight request limit of this apiserver per request kind in last second.", + StabilityLevel: compbasemetrics.ALPHA, }, []string{"requestKind"}, ) @@ -180,7 +221,7 @@ var registerMetrics sync.Once func Register() { registerMetrics.Do(func() { for _, metric := range metrics { - prometheus.MustRegister(metric) + legacyregistry.MustRegister(metric) } }) } @@ -218,7 +259,7 @@ func RecordLongRunning(req *http.Request, requestInfo *request.RequestInfo, comp if requestInfo == nil { requestInfo = &request.RequestInfo{Verb: req.Method, Path: req.URL.Path} } - var g prometheus.Gauge + var g compbasemetrics.GaugeMetric scope := CleanScope(requestInfo) reportedVerb := cleanVerb(strings.ToUpper(requestInfo.Verb), req) if requestInfo.IsResourceRequest { diff --git a/staging/src/k8s.io/apiserver/pkg/server/routes/BUILD b/staging/src/k8s.io/apiserver/pkg/server/routes/BUILD index e502cff4714..706b2afe15b 100644 --- a/staging/src/k8s.io/apiserver/pkg/server/routes/BUILD +++ b/staging/src/k8s.io/apiserver/pkg/server/routes/BUILD @@ -24,9 +24,9 @@ go_library( "//staging/src/k8s.io/apiserver/pkg/endpoints/metrics:go_default_library", "//staging/src/k8s.io/apiserver/pkg/server/mux:go_default_library", "//staging/src/k8s.io/apiserver/pkg/storage/etcd3/metrics:go_default_library", + "//staging/src/k8s.io/component-base/metrics/legacyregistry:go_default_library", "//vendor/github.com/emicklei/go-restful:go_default_library", "//vendor/github.com/go-openapi/spec:go_default_library", - "//vendor/github.com/prometheus/client_golang/prometheus:go_default_library", "//vendor/k8s.io/klog:go_default_library", "//vendor/k8s.io/kube-openapi/pkg/builder:go_default_library", "//vendor/k8s.io/kube-openapi/pkg/common:go_default_library", diff --git a/staging/src/k8s.io/apiserver/pkg/server/routes/metrics.go b/staging/src/k8s.io/apiserver/pkg/server/routes/metrics.go index 31b532509d5..94ab6a8af90 100644 --- a/staging/src/k8s.io/apiserver/pkg/server/routes/metrics.go +++ b/staging/src/k8s.io/apiserver/pkg/server/routes/metrics.go @@ -24,8 +24,7 @@ import ( apimetrics "k8s.io/apiserver/pkg/endpoints/metrics" "k8s.io/apiserver/pkg/server/mux" etcd3metrics "k8s.io/apiserver/pkg/storage/etcd3/metrics" - - "github.com/prometheus/client_golang/prometheus" + "k8s.io/component-base/metrics/legacyregistry" ) // DefaultMetrics installs the default prometheus metrics handler @@ -34,7 +33,7 @@ type DefaultMetrics struct{} // Install adds the DefaultMetrics handler func (m DefaultMetrics) Install(c *mux.PathRecorderMux) { register() - c.Handle("/metrics", prometheus.Handler()) + c.Handle("/metrics", legacyregistry.Handler()) } // MetricsWithReset install the prometheus metrics handler extended with support for the DELETE method @@ -44,7 +43,7 @@ type MetricsWithReset struct{} // Install adds the MetricsWithReset handler func (m MetricsWithReset) Install(c *mux.PathRecorderMux) { register() - defaultMetricsHandler := prometheus.Handler().ServeHTTP + defaultMetricsHandler := legacyregistry.Handler().ServeHTTP c.HandleFunc("/metrics", func(w http.ResponseWriter, req *http.Request) { if req.Method == "DELETE" { apimetrics.Reset() diff --git a/staging/src/k8s.io/apiserver/pkg/storage/cacher/BUILD b/staging/src/k8s.io/apiserver/pkg/storage/cacher/BUILD index 73c0b344e8f..d44fcbd0aa9 100644 --- a/staging/src/k8s.io/apiserver/pkg/storage/cacher/BUILD +++ b/staging/src/k8s.io/apiserver/pkg/storage/cacher/BUILD @@ -31,7 +31,8 @@ go_library( "//staging/src/k8s.io/apiserver/pkg/storage:go_default_library", "//staging/src/k8s.io/apiserver/pkg/util/feature:go_default_library", "//staging/src/k8s.io/client-go/tools/cache:go_default_library", - "//vendor/github.com/prometheus/client_golang/prometheus:go_default_library", + "//staging/src/k8s.io/component-base/metrics:go_default_library", + "//staging/src/k8s.io/component-base/metrics/legacyregistry:go_default_library", "//vendor/k8s.io/klog:go_default_library", "//vendor/k8s.io/utils/trace:go_default_library", ], diff --git a/staging/src/k8s.io/apiserver/pkg/storage/cacher/cacher.go b/staging/src/k8s.io/apiserver/pkg/storage/cacher/cacher.go index 68a0b57751f..d2ccacbc41e 100644 --- a/staging/src/k8s.io/apiserver/pkg/storage/cacher/cacher.go +++ b/staging/src/k8s.io/apiserver/pkg/storage/cacher/cacher.go @@ -26,8 +26,6 @@ import ( "sync" "time" - "k8s.io/klog" - "k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/api/meta" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" @@ -43,16 +41,26 @@ import ( "k8s.io/apiserver/pkg/storage" utilfeature "k8s.io/apiserver/pkg/util/feature" "k8s.io/client-go/tools/cache" + "k8s.io/component-base/metrics" + "k8s.io/component-base/metrics/legacyregistry" + "k8s.io/klog" utiltrace "k8s.io/utils/trace" - - "github.com/prometheus/client_golang/prometheus" ) +/* + * By default, all the following metrics are defined as falling under + * ALPHA stability level https://github.com/kubernetes/enhancements/blob/master/keps/sig-instrumentation/20190404-kubernetes-control-plane-metrics-stability.md#stability-classes) + * + * Promoting the stability level of the metric is a responsibility of the component owner, since it + * involves explicitly acknowledging support for the metric across multiple releases, in accordance with + * the metric stability policy. + */ var ( - initCounter = prometheus.NewCounterVec( - prometheus.CounterOpts{ - Name: "apiserver_init_events_total", - Help: "Counter of init events processed in watchcache broken by resource type", + initCounter = metrics.NewCounterVec( + &metrics.CounterOpts{ + Name: "apiserver_init_events_total", + Help: "Counter of init events processed in watchcache broken by resource type", + StabilityLevel: metrics.ALPHA, }, []string{"resource"}, ) @@ -66,7 +74,7 @@ const ( ) func init() { - prometheus.MustRegister(initCounter) + legacyregistry.MustRegister(initCounter) } // Config contains the configuration for a given Cache. diff --git a/staging/src/k8s.io/apiserver/pkg/storage/etcd3/metrics/BUILD b/staging/src/k8s.io/apiserver/pkg/storage/etcd3/metrics/BUILD index 0a42ce60971..13324471c83 100644 --- a/staging/src/k8s.io/apiserver/pkg/storage/etcd3/metrics/BUILD +++ b/staging/src/k8s.io/apiserver/pkg/storage/etcd3/metrics/BUILD @@ -10,7 +10,10 @@ go_library( srcs = ["metrics.go"], importmap = "k8s.io/kubernetes/vendor/k8s.io/apiserver/pkg/storage/etcd3/metrics", importpath = "k8s.io/apiserver/pkg/storage/etcd3/metrics", - deps = ["//vendor/github.com/prometheus/client_golang/prometheus:go_default_library"], + deps = [ + "//staging/src/k8s.io/component-base/metrics:go_default_library", + "//staging/src/k8s.io/component-base/metrics/legacyregistry:go_default_library", + ], ) filegroup( diff --git a/staging/src/k8s.io/apiserver/pkg/storage/etcd3/metrics/metrics.go b/staging/src/k8s.io/apiserver/pkg/storage/etcd3/metrics/metrics.go index 911a343138b..a2c354ec5ca 100644 --- a/staging/src/k8s.io/apiserver/pkg/storage/etcd3/metrics/metrics.go +++ b/staging/src/k8s.io/apiserver/pkg/storage/etcd3/metrics/metrics.go @@ -20,10 +20,20 @@ import ( "sync" "time" - "github.com/prometheus/client_golang/prometheus" + compbasemetrics "k8s.io/component-base/metrics" + "k8s.io/component-base/metrics/legacyregistry" ) +/* + * By default, all the following metrics are defined as falling under + * ALPHA stability level https://github.com/kubernetes/enhancements/blob/master/keps/sig-instrumentation/20190404-kubernetes-control-plane-metrics-stability.md#stability-classes) + * + * Promoting the stability level of the metric is a responsibility of the component owner, since it + * involves explicitly acknowledging support for the metric across multiple releases, in accordance with + * the metric stability policy. + */ var ( + /* Disable those metrics as not in community (neither 2021-02-05 master or 1.18) cacheHitCounterOpts = prometheus.CounterOpts{ Name: "etcd_helper_cache_hit_total", Help: "Counter of etcd helper cache hits.", @@ -52,21 +62,26 @@ var ( Help: "Latency in seconds of adding an object to etcd cache", }, ) - etcdRequestLatency = prometheus.NewHistogramVec( - prometheus.HistogramOpts{ - Name: "etcd_request_duration_seconds", - Help: "Etcd request latency in seconds for each operation and object type.", + */ + + etcdRequestLatency = compbasemetrics.NewHistogramVec( + &compbasemetrics.HistogramOpts{ + Name: "etcd_request_duration_seconds", + Help: "Etcd request latency in seconds for each operation and object type.", + StabilityLevel: compbasemetrics.ALPHA, }, []string{"operation", "type"}, ) - objectCounts = prometheus.NewGaugeVec( - prometheus.GaugeOpts{ - Name: "etcd_object_counts", - Help: "Number of stored objects at the time of last check split by kind.", + objectCounts = compbasemetrics.NewGaugeVec( + &compbasemetrics.GaugeOpts{ + Name: "etcd_object_counts", + Help: "Number of stored objects at the time of last check split by kind.", + StabilityLevel: compbasemetrics.ALPHA, }, []string{"resource"}, ) + /* Disable those metrics as not in community (neither 2021-02-05 master or 1.18) deprecatedCacheHitCounterOpts = prometheus.CounterOpts{ Name: "etcd_helper_cache_hit_count", Help: "(Deprecated) Counter of etcd helper cache hits.", @@ -95,10 +110,13 @@ var ( Help: "(Deprecated) Latency in microseconds of adding an object to etcd cache", }, ) - deprecatedEtcdRequestLatenciesSummary = prometheus.NewSummaryVec( - prometheus.SummaryOpts{ - Name: "etcd_request_latencies_summary", - Help: "(Deprecated) Etcd request latency summary in microseconds for each operation and object type.", + */ + + deprecatedEtcdRequestLatenciesSummary = compbasemetrics.NewSummaryVec( + &compbasemetrics.SummaryOpts{ + Name: "etcd_request_latencies_summary", + Help: "(Deprecated) Etcd request latency summary in microseconds for each operation and object type.", + StabilityLevel: compbasemetrics.ALPHA, }, []string{"operation", "type"}, ) @@ -110,21 +128,11 @@ var registerMetrics sync.Once func Register() { // Register the metrics. registerMetrics.Do(func() { - prometheus.MustRegister(cacheHitCounter) - prometheus.MustRegister(cacheMissCounter) - prometheus.MustRegister(cacheEntryCounter) - prometheus.MustRegister(cacheAddLatency) - prometheus.MustRegister(cacheGetLatency) - prometheus.MustRegister(etcdRequestLatency) - prometheus.MustRegister(objectCounts) + legacyregistry.MustRegister(etcdRequestLatency) + legacyregistry.MustRegister(objectCounts) // TODO(danielqsj): Remove the following metrics, they are deprecated - prometheus.MustRegister(deprecatedCacheHitCounter) - prometheus.MustRegister(deprecatedCacheMissCounter) - prometheus.MustRegister(deprecatedCacheEntryCounter) - prometheus.MustRegister(deprecatedCacheAddLatency) - prometheus.MustRegister(deprecatedCacheGetLatency) - prometheus.MustRegister(deprecatedEtcdRequestLatenciesSummary) + legacyregistry.MustRegister(deprecatedEtcdRequestLatenciesSummary) }) } @@ -137,6 +145,7 @@ func RecordEtcdRequestLatency(verb, resource string, startTime time.Time) { deprecatedEtcdRequestLatenciesSummary.WithLabelValues(verb, resource).Observe(sinceInMicroseconds(startTime)) } +/* func ObserveGetCache(startTime time.Time) { cacheGetLatency.Observe(sinceInSeconds(startTime)) deprecatedCacheGetLatency.Observe(sinceInMicroseconds(startTime)) @@ -161,19 +170,23 @@ func ObserveNewEntry() { cacheEntryCounter.Inc() deprecatedCacheEntryCounter.Inc() } +*/ func Reset() { - cacheHitCounter = prometheus.NewCounter(cacheHitCounterOpts) + /*cacheHitCounter = prometheus.NewCounter(cacheHitCounterOpts) cacheMissCounter = prometheus.NewCounter(cacheMissCounterOpts) cacheEntryCounter = prometheus.NewCounter(cacheEntryCounterOpts) // TODO: Reset cacheAddLatency. // TODO: Reset cacheGetLatency. + */ etcdRequestLatency.Reset() - deprecatedCacheHitCounter = prometheus.NewCounter(deprecatedCacheHitCounterOpts) - deprecatedCacheMissCounter = prometheus.NewCounter(deprecatedCacheMissCounterOpts) - deprecatedCacheEntryCounter = prometheus.NewCounter(deprecatedCacheEntryCounterOpts) - deprecatedEtcdRequestLatenciesSummary.Reset() + /* + deprecatedCacheHitCounter = prometheus.NewCounter(deprecatedCacheHitCounterOpts) + deprecatedCacheMissCounter = prometheus.NewCounter(deprecatedCacheMissCounterOpts) + deprecatedCacheEntryCounter = prometheus.NewCounter(deprecatedCacheEntryCounterOpts) + deprecatedEtcdRequestLatenciesSummary.Reset() + */ } // sinceInMicroseconds gets the time since the specified start in microseconds. diff --git a/staging/src/k8s.io/apiserver/pkg/storage/storagebackend/factory/BUILD b/staging/src/k8s.io/apiserver/pkg/storage/storagebackend/factory/BUILD index 06fe3aca6a1..7ae0fec0087 100644 --- a/staging/src/k8s.io/apiserver/pkg/storage/storagebackend/factory/BUILD +++ b/staging/src/k8s.io/apiserver/pkg/storage/storagebackend/factory/BUILD @@ -44,6 +44,7 @@ go_library( "//staging/src/k8s.io/apiserver/pkg/storage/storagebackend:go_default_library", "//staging/src/k8s.io/apiserver/pkg/storage/storagecluster:go_default_library", "//staging/src/k8s.io/apiserver/pkg/storage/value:go_default_library", + "//staging/src/k8s.io/component-base/metrics/legacyregistry:go_default_library", "//vendor/github.com/grafov/bcast:go_default_library", "//vendor/github.com/grpc-ecosystem/go-grpc-prometheus:go_default_library", "//vendor/go.etcd.io/etcd/clientv3:go_default_library", diff --git a/staging/src/k8s.io/apiserver/pkg/storage/storagebackend/factory/etcd3.go b/staging/src/k8s.io/apiserver/pkg/storage/storagebackend/factory/etcd3.go index 2b78ec2fca9..22a9f3c122e 100644 --- a/staging/src/k8s.io/apiserver/pkg/storage/storagebackend/factory/etcd3.go +++ b/staging/src/k8s.io/apiserver/pkg/storage/storagebackend/factory/etcd3.go @@ -40,6 +40,7 @@ import ( "k8s.io/apiserver/pkg/storage/etcd3" "k8s.io/apiserver/pkg/storage/storagebackend" "k8s.io/apiserver/pkg/storage/value" + "k8s.io/component-base/metrics/legacyregistry" ) // The short keepalive timeout and interval have been chosen to aggressively @@ -52,6 +53,14 @@ const keepaliveTimeout = 10 * time.Second // on heavily loaded arm64 CPUs (issue #64649) const dialTimeout = 20 * time.Second +func init() { + // grpcprom auto-registers (via an init function) their client metrics, since we are opting out of + // using the global prometheus registry and using our own wrapped global registry, + // we need to explicitly register these metrics to our global registry here. + // For reference: https://github.com/kubernetes/kubernetes/pull/81387 + legacyregistry.RawMustRegister(grpcprom.DefaultClientMetrics) +} + // TODO - health check for data clusters func newETCD3HealthCheck(c storagebackend.Config) (func() error, error) { // constructing the etcd v3 client blocks and times out if etcd is not available. diff --git a/staging/src/k8s.io/apiserver/pkg/storage/value/BUILD b/staging/src/k8s.io/apiserver/pkg/storage/value/BUILD index 9c4716b41ff..93af5283b48 100644 --- a/staging/src/k8s.io/apiserver/pkg/storage/value/BUILD +++ b/staging/src/k8s.io/apiserver/pkg/storage/value/BUILD @@ -14,7 +14,7 @@ go_test( ], embed = [":go_default_library"], deps = [ - "//vendor/github.com/prometheus/client_golang/prometheus:go_default_library", + "//staging/src/k8s.io/component-base/metrics/legacyregistry:go_default_library", "//vendor/github.com/prometheus/client_golang/prometheus/testutil:go_default_library", "//vendor/google.golang.org/grpc/codes:go_default_library", "//vendor/google.golang.org/grpc/status:go_default_library", @@ -30,6 +30,8 @@ go_library( importmap = "k8s.io/kubernetes/vendor/k8s.io/apiserver/pkg/storage/value", importpath = "k8s.io/apiserver/pkg/storage/value", deps = [ + "//staging/src/k8s.io/component-base/metrics:go_default_library", + "//staging/src/k8s.io/component-base/metrics/legacyregistry:go_default_library", "//vendor/github.com/prometheus/client_golang/prometheus:go_default_library", "//vendor/google.golang.org/grpc/status:go_default_library", ], diff --git a/staging/src/k8s.io/apiserver/pkg/storage/value/metrics.go b/staging/src/k8s.io/apiserver/pkg/storage/value/metrics.go index f827bffaf92..f35994688bc 100644 --- a/staging/src/k8s.io/apiserver/pkg/storage/value/metrics.go +++ b/staging/src/k8s.io/apiserver/pkg/storage/value/metrics.go @@ -20,9 +20,11 @@ import ( "sync" "time" + "github.com/prometheus/client_golang/prometheus" "google.golang.org/grpc/status" - "github.com/prometheus/client_golang/prometheus" + "k8s.io/component-base/metrics" + "k8s.io/component-base/metrics/legacyregistry" ) const ( @@ -30,85 +32,101 @@ const ( subsystem = "storage" ) +/* + * By default, all the following metrics are defined as falling under + * ALPHA stability level https://github.com/kubernetes/enhancements/blob/master/keps/sig-instrumentation/20190404-kubernetes-control-plane-metrics-stability.md#stability-classes) + * + * Promoting the stability level of the metric is a responsibility of the component owner, since it + * involves explicitly acknowledging support for the metric across multiple releases, in accordance with + * the metric stability policy. + */ var ( - transformerLatencies = prometheus.NewHistogramVec( - prometheus.HistogramOpts{ + transformerLatencies = metrics.NewHistogramVec( + &metrics.HistogramOpts{ Namespace: namespace, Subsystem: subsystem, Name: "transformation_duration_seconds", Help: "Latencies in seconds of value transformation operations.", // In-process transformations (ex. AES CBC) complete on the order of 20 microseconds. However, when // external KMS is involved latencies may climb into milliseconds. - Buckets: prometheus.ExponentialBuckets(5e-6, 2, 14), + Buckets: prometheus.ExponentialBuckets(5e-6, 2, 14), + StabilityLevel: metrics.ALPHA, }, []string{"transformation_type"}, ) - deprecatedTransformerLatencies = prometheus.NewHistogramVec( - prometheus.HistogramOpts{ + deprecatedTransformerLatencies = metrics.NewHistogramVec( + &metrics.HistogramOpts{ Namespace: namespace, Subsystem: subsystem, Name: "transformation_latencies_microseconds", Help: "(Deprecated) Latencies in microseconds of value transformation operations.", // In-process transformations (ex. AES CBC) complete on the order of 20 microseconds. However, when // external KMS is involved latencies may climb into milliseconds. - Buckets: prometheus.ExponentialBuckets(5, 2, 14), + Buckets: prometheus.ExponentialBuckets(5, 2, 14), + StabilityLevel: metrics.ALPHA, }, []string{"transformation_type"}, ) - transformerOperationsTotal = prometheus.NewCounterVec( - prometheus.CounterOpts{ - Namespace: namespace, - Subsystem: subsystem, - Name: "transformation_operations_total", - Help: "Total number of transformations.", + transformerOperationsTotal = metrics.NewCounterVec( + &metrics.CounterOpts{ + Namespace: namespace, + Subsystem: subsystem, + Name: "transformation_operations_total", + Help: "Total number of transformations.", + StabilityLevel: metrics.ALPHA, }, - []string{"transformation_type", "status"}, + []string{"transformation_type", "transformer_prefix", "status"}, ) - deprecatedTransformerFailuresTotal = prometheus.NewCounterVec( - prometheus.CounterOpts{ - Namespace: namespace, - Subsystem: subsystem, - Name: "transformation_failures_total", - Help: "(Deprecated) Total number of failed transformation operations.", + deprecatedTransformerFailuresTotal = metrics.NewCounterVec( + &metrics.CounterOpts{ + Namespace: namespace, + Subsystem: subsystem, + Name: "transformation_failures_total", + Help: "(Deprecated) Total number of failed transformation operations.", + StabilityLevel: metrics.ALPHA, }, []string{"transformation_type"}, ) - envelopeTransformationCacheMissTotal = prometheus.NewCounter( - prometheus.CounterOpts{ - Namespace: namespace, - Subsystem: subsystem, - Name: "envelope_transformation_cache_misses_total", - Help: "Total number of cache misses while accessing key decryption key(KEK).", + envelopeTransformationCacheMissTotal = metrics.NewCounter( + &metrics.CounterOpts{ + Namespace: namespace, + Subsystem: subsystem, + Name: "envelope_transformation_cache_misses_total", + Help: "Total number of cache misses while accessing key decryption key(KEK).", + StabilityLevel: metrics.ALPHA, }, ) - dataKeyGenerationLatencies = prometheus.NewHistogram( - prometheus.HistogramOpts{ - Namespace: namespace, - Subsystem: subsystem, - Name: "data_key_generation_duration_seconds", - Help: "Latencies in seconds of data encryption key(DEK) generation operations.", - Buckets: prometheus.ExponentialBuckets(5e-6, 2, 14), + dataKeyGenerationLatencies = metrics.NewHistogram( + &metrics.HistogramOpts{ + Namespace: namespace, + Subsystem: subsystem, + Name: "data_key_generation_duration_seconds", + Help: "Latencies in seconds of data encryption key(DEK) generation operations.", + Buckets: prometheus.ExponentialBuckets(5e-6, 2, 14), + StabilityLevel: metrics.ALPHA, }, ) - deprecatedDataKeyGenerationLatencies = prometheus.NewHistogram( - prometheus.HistogramOpts{ - Namespace: namespace, - Subsystem: subsystem, - Name: "data_key_generation_latencies_microseconds", - Help: "(Deprecated) Latencies in microseconds of data encryption key(DEK) generation operations.", - Buckets: prometheus.ExponentialBuckets(5, 2, 14), + deprecatedDataKeyGenerationLatencies = metrics.NewHistogram( + &metrics.HistogramOpts{ + Namespace: namespace, + Subsystem: subsystem, + Name: "data_key_generation_latencies_microseconds", + Help: "(Deprecated) Latencies in microseconds of data encryption key(DEK) generation operations.", + Buckets: prometheus.ExponentialBuckets(5, 2, 14), + StabilityLevel: metrics.ALPHA, }, ) - dataKeyGenerationFailuresTotal = prometheus.NewCounter( - prometheus.CounterOpts{ - Namespace: namespace, - Subsystem: subsystem, - Name: "data_key_generation_failures_total", - Help: "Total number of failed data encryption key(DEK) generation operations.", + dataKeyGenerationFailuresTotal = metrics.NewCounter( + &metrics.CounterOpts{ + Namespace: namespace, + Subsystem: subsystem, + Name: "data_key_generation_failures_total", + Help: "Total number of failed data encryption key(DEK) generation operations.", + StabilityLevel: metrics.ALPHA, }, ) ) @@ -117,21 +135,21 @@ var registerMetrics sync.Once func RegisterMetrics() { registerMetrics.Do(func() { - prometheus.MustRegister(transformerLatencies) - prometheus.MustRegister(deprecatedTransformerLatencies) - prometheus.MustRegister(transformerOperationsTotal) - prometheus.MustRegister(deprecatedTransformerFailuresTotal) - prometheus.MustRegister(envelopeTransformationCacheMissTotal) - prometheus.MustRegister(dataKeyGenerationLatencies) - prometheus.MustRegister(deprecatedDataKeyGenerationLatencies) - prometheus.MustRegister(dataKeyGenerationFailuresTotal) + legacyregistry.MustRegister(transformerLatencies) + legacyregistry.MustRegister(deprecatedTransformerLatencies) + legacyregistry.MustRegister(transformerOperationsTotal) + legacyregistry.MustRegister(deprecatedTransformerFailuresTotal) + legacyregistry.MustRegister(envelopeTransformationCacheMissTotal) + legacyregistry.MustRegister(dataKeyGenerationLatencies) + legacyregistry.MustRegister(deprecatedDataKeyGenerationLatencies) + legacyregistry.MustRegister(dataKeyGenerationFailuresTotal) }) } // RecordTransformation records latencies and count of TransformFromStorage and TransformToStorage operations. // Note that transformation_failures_total metric is deprecated, use transformation_operations_total instead. -func RecordTransformation(transformationType string, start time.Time, err error) { - transformerOperationsTotal.WithLabelValues(transformationType, status.Code(err).String()).Inc() +func RecordTransformation(transformationType, transformerPrefix string, start time.Time, err error) { + transformerOperationsTotal.WithLabelValues(transformationType, transformerPrefix, status.Code(err).String()).Inc() switch { case err == nil: diff --git a/staging/src/k8s.io/apiserver/pkg/storage/value/metrics_test.go b/staging/src/k8s.io/apiserver/pkg/storage/value/metrics_test.go index aba5454591b..6ce15a265ec 100644 --- a/staging/src/k8s.io/apiserver/pkg/storage/value/metrics_test.go +++ b/staging/src/k8s.io/apiserver/pkg/storage/value/metrics_test.go @@ -18,6 +18,7 @@ package value import ( "errors" + "k8s.io/component-base/metrics/legacyregistry" "strings" "testing" "time" @@ -25,7 +26,6 @@ import ( "google.golang.org/grpc/codes" "google.golang.org/grpc/status" - "github.com/prometheus/client_golang/prometheus" "github.com/prometheus/client_golang/prometheus/testutil" ) @@ -44,12 +44,12 @@ func TestTotals(t *testing.T) { }, error: errors.New("foo"), want: ` - # HELP apiserver_storage_transformation_failures_total (Deprecated) Total number of failed transformation operations. + # HELP apiserver_storage_transformation_failures_total [ALPHA] (Deprecated) Total number of failed transformation operations. # TYPE apiserver_storage_transformation_failures_total counter apiserver_storage_transformation_failures_total{transformation_type="encrypt"} 1 - # HELP apiserver_storage_transformation_operations_total Total number of transformations. + # HELP apiserver_storage_transformation_operations_total [ALPHA] Total number of transformations. # TYPE apiserver_storage_transformation_operations_total counter - apiserver_storage_transformation_operations_total{status="Unknown",transformation_type="encrypt"} 1 + apiserver_storage_transformation_operations_total{status="Unknown",transformation_type="encrypt",transformer_prefix="k8s:enc:kms:v1:"} 1 `, }, { @@ -59,9 +59,9 @@ func TestTotals(t *testing.T) { "apiserver_storage_transformation_failures_total", }, want: ` - # HELP apiserver_storage_transformation_operations_total Total number of transformations. + # HELP apiserver_storage_transformation_operations_total [ALPHA] Total number of transformations. # TYPE apiserver_storage_transformation_operations_total counter - apiserver_storage_transformation_operations_total{status="OK",transformation_type="encrypt"} 1 + apiserver_storage_transformation_operations_total{status="OK",transformation_type="encrypt",transformer_prefix="k8s:enc:kms:v1:"} 1 `, }, { @@ -72,12 +72,12 @@ func TestTotals(t *testing.T) { }, error: status.Error(codes.FailedPrecondition, "foo"), want: ` - # HELP apiserver_storage_transformation_failures_total (Deprecated) Total number of failed transformation operations. + # HELP apiserver_storage_transformation_failures_total [ALPHA] (Deprecated) Total number of failed transformation operations. # TYPE apiserver_storage_transformation_failures_total counter apiserver_storage_transformation_failures_total{transformation_type="encrypt"} 1 - # HELP apiserver_storage_transformation_operations_total Total number of transformations. + # HELP apiserver_storage_transformation_operations_total [ALPHA] Total number of transformations. # TYPE apiserver_storage_transformation_operations_total counter - apiserver_storage_transformation_operations_total{status="FailedPrecondition",transformation_type="encrypt"} 1 + apiserver_storage_transformation_operations_total{status="FailedPrecondition",transformation_type="encrypt",transformer_prefix="k8s:enc:kms:v1:"} 1 `, }, } @@ -86,10 +86,10 @@ func TestTotals(t *testing.T) { for _, tt := range testCases { t.Run(tt.desc, func(t *testing.T) { - RecordTransformation("encrypt", time.Now(), tt.error) + RecordTransformation("encrypt", "k8s:enc:kms:v1:", time.Now(), tt.error) defer transformerOperationsTotal.Reset() defer deprecatedTransformerFailuresTotal.Reset() - if err := testutil.GatherAndCompare(prometheus.DefaultGatherer, strings.NewReader(tt.want), tt.metrics...); err != nil { + if err := testutil.GatherAndCompare(legacyregistry.DefaultGatherer, strings.NewReader(tt.want), tt.metrics...); err != nil { t.Fatal(err) } }) diff --git a/staging/src/k8s.io/apiserver/pkg/storage/value/transformer.go b/staging/src/k8s.io/apiserver/pkg/storage/value/transformer.go index bad6ed58e33..bb0f1157c34 100644 --- a/staging/src/k8s.io/apiserver/pkg/storage/value/transformer.go +++ b/staging/src/k8s.io/apiserver/pkg/storage/value/transformer.go @@ -85,18 +85,12 @@ func (t *MutableTransformer) Set(transformer Transformer) { } func (t *MutableTransformer) TransformFromStorage(data []byte, context Context) (out []byte, stale bool, err error) { - defer func(start time.Time) { - RecordTransformation("from_storage", start, err) - }(time.Now()) t.lock.RLock() transformer := t.transformer t.lock.RUnlock() return transformer.TransformFromStorage(data, context) } func (t *MutableTransformer) TransformToStorage(data []byte, context Context) (out []byte, err error) { - defer func(start time.Time) { - RecordTransformation("to_storage", start, err) - }(time.Now()) t.lock.RLock() transformer := t.transformer t.lock.RUnlock() @@ -134,28 +128,37 @@ func NewPrefixTransformers(err error, transformers ...PrefixTransformer) Transfo // the result of transforming the value. It will always mark any transformation as stale that is not using // the first transformer. func (t *prefixTransformers) TransformFromStorage(data []byte, context Context) ([]byte, bool, error) { + start := time.Now() for i, transformer := range t.transformers { if bytes.HasPrefix(data, transformer.Prefix) { result, stale, err := transformer.Transformer.TransformFromStorage(data[len(transformer.Prefix):], context) // To migrate away from encryption, user can specify an identity transformer higher up // (in the config file) than the encryption transformer. In that scenario, the identity transformer needs to // identify (during reads from disk) whether the data being read is encrypted or not. If the data is encrypted, - // it shall throw an error, but that error should not prevent subsequent transformers from being tried. + // it shall throw an error, but that error should not prevent the next subsequent transformer from being tried. if len(transformer.Prefix) == 0 && err != nil { continue } + if len(transformer.Prefix) == 0 { + RecordTransformation("from_storage", "identity", start, err) + } else { + RecordTransformation("from_storage", string(transformer.Prefix), start, err) + } return result, stale || i != 0, err } } + RecordTransformation("from_storage", "unknown", start, t.err) return nil, false, t.err } // TransformToStorage uses the first transformer and adds its prefix to the data. func (t *prefixTransformers) TransformToStorage(data []byte, context Context) ([]byte, error) { + start := time.Now() transformer := t.transformers[0] prefixedData := make([]byte, len(transformer.Prefix), len(data)+len(transformer.Prefix)) copy(prefixedData, transformer.Prefix) result, err := transformer.Transformer.TransformToStorage(data, context) + RecordTransformation("to_storage", string(transformer.Prefix), start, err) if err != nil { return nil, err } diff --git a/staging/src/k8s.io/apiserver/pkg/storage/value/transformer_test.go b/staging/src/k8s.io/apiserver/pkg/storage/value/transformer_test.go index 63b9e0a7543..27d2d9ee792 100644 --- a/staging/src/k8s.io/apiserver/pkg/storage/value/transformer_test.go +++ b/staging/src/k8s.io/apiserver/pkg/storage/value/transformer_test.go @@ -19,7 +19,11 @@ package value import ( "bytes" "fmt" + "k8s.io/component-base/metrics/legacyregistry" + "strings" "testing" + + "github.com/prometheus/client_golang/prometheus/testutil" ) type testTransformer struct { @@ -99,3 +103,149 @@ func TestPrefixTo(t *testing.T) { } } } + +func TestPrefixFromMetrics(t *testing.T) { + testErr := fmt.Errorf("test error") + transformerErr := fmt.Errorf("test error") + identityTransformer := PrefixTransformer{Prefix: []byte{}, Transformer: &testTransformer{from: []byte("value1")}} + identityTransformerErr := PrefixTransformer{Prefix: []byte{}, Transformer: &testTransformer{err: transformerErr}} + otherTransformer := PrefixTransformer{Prefix: []byte("other:"), Transformer: &testTransformer{from: []byte("value1")}} + otherTransformerErr := PrefixTransformer{Prefix: []byte("other:"), Transformer: &testTransformer{err: transformerErr}} + + testCases := []struct { + desc string + input []byte + prefix Transformer + metrics []string + want string + err error + }{ + { + desc: "identity prefix", + input: []byte("value"), + prefix: NewPrefixTransformers(testErr, identityTransformer, otherTransformer), + metrics: []string{ + "apiserver_storage_transformation_operations_total", + }, + want: ` + # HELP apiserver_storage_transformation_operations_total [ALPHA] Total number of transformations. + # TYPE apiserver_storage_transformation_operations_total counter + apiserver_storage_transformation_operations_total{status="OK",transformation_type="from_storage",transformer_prefix="identity"} 1 + `, + err: nil, + }, + { + desc: "other prefix (ok)", + input: []byte("other:value"), + prefix: NewPrefixTransformers(testErr, identityTransformerErr, otherTransformer), + metrics: []string{ + "apiserver_storage_transformation_operations_total", + }, + want: ` + # HELP apiserver_storage_transformation_operations_total [ALPHA] Total number of transformations. + # TYPE apiserver_storage_transformation_operations_total counter + apiserver_storage_transformation_operations_total{status="OK",transformation_type="from_storage",transformer_prefix="other:"} 1 + `, + err: nil, + }, + { + desc: "other prefix (error)", + input: []byte("other:value"), + prefix: NewPrefixTransformers(testErr, identityTransformerErr, otherTransformerErr), + metrics: []string{ + "apiserver_storage_transformation_operations_total", + }, + want: ` + # HELP apiserver_storage_transformation_operations_total [ALPHA] Total number of transformations. + # TYPE apiserver_storage_transformation_operations_total counter + apiserver_storage_transformation_operations_total{status="Unknown",transformation_type="from_storage",transformer_prefix="other:"} 1 + `, + err: nil, + }, + { + desc: "unknown prefix", + input: []byte("foo:value"), + prefix: NewPrefixTransformers(testErr, identityTransformerErr, otherTransformer), + metrics: []string{ + "apiserver_storage_transformation_operations_total", + }, + want: ` + # HELP apiserver_storage_transformation_operations_total [ALPHA] Total number of transformations. + # TYPE apiserver_storage_transformation_operations_total counter + apiserver_storage_transformation_operations_total{status="Unknown",transformation_type="from_storage",transformer_prefix="unknown"} 1 + `, + err: nil, + }, + } + + RegisterMetrics() + transformerOperationsTotal.Reset() + + for _, tc := range testCases { + t.Run(tc.desc, func(t *testing.T) { + tc.prefix.TransformFromStorage(tc.input, nil) + defer transformerOperationsTotal.Reset() + if err := testutil.GatherAndCompare(legacyregistry.DefaultGatherer, strings.NewReader(tc.want), tc.metrics...); err != nil { + t.Fatal(err) + } + }) + } +} + +func TestPrefixToMetrics(t *testing.T) { + testErr := fmt.Errorf("test error") + transformerErr := fmt.Errorf("test error") + otherTransformer := PrefixTransformer{Prefix: []byte("other:"), Transformer: &testTransformer{from: []byte("value1")}} + otherTransformerErr := PrefixTransformer{Prefix: []byte("other:"), Transformer: &testTransformer{err: transformerErr}} + + testCases := []struct { + desc string + input []byte + prefix Transformer + metrics []string + want string + err error + }{ + { + desc: "ok", + input: []byte("value"), + prefix: NewPrefixTransformers(testErr, otherTransformer), + metrics: []string{ + "apiserver_storage_transformation_operations_total", + }, + want: ` + # HELP apiserver_storage_transformation_operations_total [ALPHA] Total number of transformations. + # TYPE apiserver_storage_transformation_operations_total counter + apiserver_storage_transformation_operations_total{status="OK",transformation_type="to_storage",transformer_prefix="other:"} 1 + `, + err: nil, + }, + { + desc: "error", + input: []byte("value"), + prefix: NewPrefixTransformers(testErr, otherTransformerErr), + metrics: []string{ + "apiserver_storage_transformation_operations_total", + }, + want: ` + # HELP apiserver_storage_transformation_operations_total [ALPHA] Total number of transformations. + # TYPE apiserver_storage_transformation_operations_total counter + apiserver_storage_transformation_operations_total{status="Unknown",transformation_type="to_storage",transformer_prefix="other:"} 1 + `, + err: nil, + }, + } + + RegisterMetrics() + transformerOperationsTotal.Reset() + + for _, tc := range testCases { + t.Run(tc.desc, func(t *testing.T) { + tc.prefix.TransformToStorage(tc.input, nil) + defer transformerOperationsTotal.Reset() + if err := testutil.GatherAndCompare(legacyregistry.DefaultGatherer, strings.NewReader(tc.want), tc.metrics...); err != nil { + t.Fatal(err) + } + }) + } +} diff --git a/staging/src/k8s.io/arktos-ext/go.sum b/staging/src/k8s.io/arktos-ext/go.sum index 6bf9fd97538..958c4fd83e1 100644 --- a/staging/src/k8s.io/arktos-ext/go.sum +++ b/staging/src/k8s.io/arktos-ext/go.sum @@ -28,6 +28,7 @@ github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5y github.com/google/btree v1.0.0/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= github.com/google/go-cmp v0.3.0 h1:crn/baboCvb5fXaQ0IJ1SGTsTVrWpDsCWC8EGETZijY= github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= +github.com/google/gofuzz v0.0.0-20170612174753-24818f796faf h1:+RRA9JqSOZFfKrOeqr2z77+8R2RKyh8PG66dcu1V0ck= github.com/google/gofuzz v0.0.0-20170612174753-24818f796faf/go.mod h1:HP5RmnzzSNb993RKQDq4+1A4ia9nllfqcQFTQJedwGI= github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/googleapis/gnostic v0.0.0-20170729233727-0c5108395e2d h1:7XGaL1e6bYS1yIonGp9761ExpPPV1ui0SAC59Yube9k= @@ -36,10 +37,12 @@ github.com/gophercloud/gophercloud v0.6.0/go.mod h1:GICNByuaEBibcjmjvI7QvYJSZEbG github.com/grafov/bcast v0.0.0-20190217190352-1447f067e08d h1:Q2+KsA/1GLC9xyLsDun3/EOJ+83rY/IHRsO1DToPrdo= github.com/grafov/bcast v0.0.0-20190217190352-1447f067e08d/go.mod h1:RInr+B3/Tx70hYm0rpNPMTD7vH0pBG5ny/JsHAs2KcQ= github.com/gregjones/httpcache v0.0.0-20180305231024-9cad4c3443a7/go.mod h1:FecbI9+v66THATjSRHfNgh1IVFe/9kFxbXtjV0ctIMA= +github.com/hashicorp/golang-lru v0.5.0 h1:CL2msUPvZTLb5O648aiLNJw3hnBxN2+1Jq8rCOH9wdo= github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= github.com/hpcloud/tail v1.0.0 h1:nfCOvKYfkgYP8hkirhJocXT2+zOD8yUNjXaWfTlyFKI= github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU= github.com/imdario/mergo v0.3.5/go.mod h1:2EnlNZ0deacrJVfApfmtdGgDfMuh/nq6Ok1EcJh5FfA= +github.com/json-iterator/go v0.0.0-20180701071628-ab8a2e0c74be h1:AHimNtVIpiBjPUhEF5KNCkrUyqTSA5zWUl8sQ2bfGBE= github.com/json-iterator/go v0.0.0-20180701071628-ab8a2e0c74be/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU= github.com/kisielk/errcheck v1.2.0/go.mod h1:/BMXB+zMLi60iA8Vv6Ksmxu/1UDYcXs4uQLJ+jE2L00= github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= @@ -108,7 +111,9 @@ gopkg.in/yaml.v2 v2.2.8 h1:obN1ZagJSUGI0Ek/LBmuj4SNLPfIny3KsKFopxRdj10= gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= k8s.io/klog v1.0.0 h1:Pt+yjF5aB1xDSVbau4VsWe+dQNzA0qv1LlXdC2dF6Q8= k8s.io/klog v1.0.0/go.mod h1:4Bi6QPql/J/LkTDqv7R/cd3hPo4k2DG6Ptcz060Ez5I= +k8s.io/kube-openapi v0.0.0-20190228160746-b3a7cee44a30 h1:TRb4wNWoBVrH9plmkp2q86FIDppkbrEXdXlxU3a3BMI= k8s.io/kube-openapi v0.0.0-20190228160746-b3a7cee44a30/go.mod h1:BXM9ceUBTj2QnfH2MK1odQs778ajze1RxcmP6S8RVVc= +k8s.io/utils v0.0.0-20190221042446-c2654d5206da h1:ElyM7RPonbKnQqOcw7dG2IK5uvQQn3b/WPHqD5mBvP4= k8s.io/utils v0.0.0-20190221042446-c2654d5206da/go.mod h1:8k8uAuAQ0rXslZKaEWd0c3oVhZz7sSzSiPnVZayjIX0= sigs.k8s.io/yaml v1.1.0 h1:4A07+ZFc2wgJwo8YNlQpr1rVlgUDlxXHhPJciaPY5gs= sigs.k8s.io/yaml v1.1.0/go.mod h1:UJmg0vDUVViEyp3mgSv9WPwZCDxu4rQW1olrI1uml+o= diff --git a/staging/src/k8s.io/cli-runtime/go.sum b/staging/src/k8s.io/cli-runtime/go.sum index ec5234ae197..e7e7c52184f 100644 --- a/staging/src/k8s.io/cli-runtime/go.sum +++ b/staging/src/k8s.io/cli-runtime/go.sum @@ -50,6 +50,7 @@ github.com/golang/protobuf v1.2.0 h1:P3YflyNX/ehuJFLhxviNdFxQPkGK5cDcApsge1SqnvM github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/golang/protobuf v1.3.2 h1:6nsPYzhq5kReh6QImI3k5qWzO4PEbvbIW2cwSfR/6xs= github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= +github.com/google/btree v1.0.0 h1:0udJVsspx3VBr5FwtLhQQtuAsVc79tTq0ocGIPAU6qo= github.com/google/btree v1.0.0/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= github.com/google/go-cmp v0.3.0 h1:crn/baboCvb5fXaQ0IJ1SGTsTVrWpDsCWC8EGETZijY= github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= @@ -59,6 +60,7 @@ github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+ github.com/googleapis/gnostic v0.0.0-20170729233727-0c5108395e2d h1:7XGaL1e6bYS1yIonGp9761ExpPPV1ui0SAC59Yube9k= github.com/googleapis/gnostic v0.0.0-20170729233727-0c5108395e2d/go.mod h1:sJBsCZ4ayReDTBIg8b9dl28c5xFWyhBTVRp3pOg5EKY= github.com/gophercloud/gophercloud v0.6.0/go.mod h1:GICNByuaEBibcjmjvI7QvYJSZEbGkcYwAR7EZK2WMqM= +github.com/grafov/bcast v0.0.0-20190217190352-1447f067e08d h1:Q2+KsA/1GLC9xyLsDun3/EOJ+83rY/IHRsO1DToPrdo= github.com/grafov/bcast v0.0.0-20190217190352-1447f067e08d/go.mod h1:RInr+B3/Tx70hYm0rpNPMTD7vH0pBG5ny/JsHAs2KcQ= github.com/gregjones/httpcache v0.0.0-20180305231024-9cad4c3443a7 h1:pdN6V1QBWetyv/0+wjACpqVH+eVULgEjkurDLq3goeM= github.com/gregjones/httpcache v0.0.0-20180305231024-9cad4c3443a7/go.mod h1:FecbI9+v66THATjSRHfNgh1IVFe/9kFxbXtjV0ctIMA= @@ -155,6 +157,7 @@ google.golang.org/appengine v1.5.0 h1:KxkO13IPW4Lslp2bz+KHP2E3gtFlrIGNThxkZQ3g+4 google.golang.org/appengine v1.5.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 h1:qIbj1fsPNlZgppZ+VLlY7N33q108Sa+fhmuc+sWQYwY= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/fatih/set.v0 v0.2.1 h1:Xvyyp7LXu34P0ROhCyfXkmQCAoOUKb1E2JS9I7SE5CY= gopkg.in/fatih/set.v0 v0.2.1/go.mod h1:5eLWEndGL4zGGemXWrKuts+wTJR0y+w+auqUJZbmyBg= gopkg.in/fsnotify.v1 v1.4.7 h1:xOHLXZwVvI9hhs+cLKq5+I5onOuwQLhQwiu63xxlHs4= gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys= @@ -168,6 +171,7 @@ gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.8 h1:obN1ZagJSUGI0Ek/LBmuj4SNLPfIny3KsKFopxRdj10= gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +k8s.io/klog v1.0.0 h1:Pt+yjF5aB1xDSVbau4VsWe+dQNzA0qv1LlXdC2dF6Q8= k8s.io/klog v1.0.0/go.mod h1:4Bi6QPql/J/LkTDqv7R/cd3hPo4k2DG6Ptcz060Ez5I= k8s.io/kube-openapi v0.0.0-20190228160746-b3a7cee44a30 h1:TRb4wNWoBVrH9plmkp2q86FIDppkbrEXdXlxU3a3BMI= k8s.io/kube-openapi v0.0.0-20190228160746-b3a7cee44a30/go.mod h1:BXM9ceUBTj2QnfH2MK1odQs778ajze1RxcmP6S8RVVc= diff --git a/staging/src/k8s.io/client-go/go.sum b/staging/src/k8s.io/client-go/go.sum index 2faf4d09308..16fc2caadf1 100644 --- a/staging/src/k8s.io/client-go/go.sum +++ b/staging/src/k8s.io/client-go/go.sum @@ -1,11 +1,17 @@ cloud.google.com/go v0.34.0 h1:eOI3/cP2VTU6uZLDYAoic+eyzzB9YyGmJ7eIjl8rOPg= cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= +github.com/Azure/go-autorest/autorest v0.9.0 h1:MRvx8gncNaXJqOoLmhNjUAKh33JJF8LyxPhomEtOsjs= github.com/Azure/go-autorest/autorest v0.9.0/go.mod h1:xyHB1BMZT0cuDHU7I0+g046+BFDTQ8rEZB0s4Yfa6bI= +github.com/Azure/go-autorest/autorest/adal v0.5.0 h1:q2gDruN08/guU9vAjuPWff0+QIrpH6ediguzdAzXAUU= github.com/Azure/go-autorest/autorest/adal v0.5.0/go.mod h1:8Z9fGy2MpX0PvDjB1pEgQTmVqjGhiHBW7RJJEciWzS0= +github.com/Azure/go-autorest/autorest/date v0.1.0 h1:YGrhWfrgtFs84+h0o46rJrlmsZtyZRg470CqAXTZaGM= github.com/Azure/go-autorest/autorest/date v0.1.0/go.mod h1:plvfp3oPSKwf2DNjlBjWF/7vwR+cUD/ELuzDCXwHUVA= github.com/Azure/go-autorest/autorest/mocks v0.1.0/go.mod h1:OTyCOPRA2IgIlWxVYxBee2F5Gr4kF2zd2J5cFRaIDN0= +github.com/Azure/go-autorest/autorest/mocks v0.2.0 h1:Ww5g4zThfD/6cLb4z6xxgeyDa7QDkizMkJKe0ysZXp0= github.com/Azure/go-autorest/autorest/mocks v0.2.0/go.mod h1:OTyCOPRA2IgIlWxVYxBee2F5Gr4kF2zd2J5cFRaIDN0= +github.com/Azure/go-autorest/logger v0.1.0 h1:ruG4BSDXONFRrZZJ2GUXDiUyVpayPmb1GnWeHDdaNKY= github.com/Azure/go-autorest/logger v0.1.0/go.mod h1:oExouG+K6PryycPJfVSxi/koC6LSNgds39diKLz7Vrc= +github.com/Azure/go-autorest/tracing v0.5.0 h1:TRn4WjSnkcSy5AEG3pnbtFSwNtwzjr4VYyQflFE619k= github.com/Azure/go-autorest/tracing v0.5.0/go.mod h1:r/s2XiOKccPW3HrqB+W0TQzfbtp2fGCgRFtBroKn4Dk= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= @@ -29,6 +35,7 @@ github.com/golang/protobuf v1.2.0 h1:P3YflyNX/ehuJFLhxviNdFxQPkGK5cDcApsge1SqnvM github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/golang/protobuf v1.3.2 h1:6nsPYzhq5kReh6QImI3k5qWzO4PEbvbIW2cwSfR/6xs= github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= +github.com/google/btree v1.0.0 h1:0udJVsspx3VBr5FwtLhQQtuAsVc79tTq0ocGIPAU6qo= github.com/google/btree v1.0.0/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= github.com/google/go-cmp v0.3.0 h1:crn/baboCvb5fXaQ0IJ1SGTsTVrWpDsCWC8EGETZijY= github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= @@ -40,6 +47,7 @@ github.com/googleapis/gnostic v0.0.0-20170729233727-0c5108395e2d h1:7XGaL1e6bYS1 github.com/googleapis/gnostic v0.0.0-20170729233727-0c5108395e2d/go.mod h1:sJBsCZ4ayReDTBIg8b9dl28c5xFWyhBTVRp3pOg5EKY= github.com/gophercloud/gophercloud v0.6.0 h1:Xb2lcqZtml1XjgYZxbeayEemq7ASbeTp09m36gQFpEU= github.com/gophercloud/gophercloud v0.6.0/go.mod h1:GICNByuaEBibcjmjvI7QvYJSZEbGkcYwAR7EZK2WMqM= +github.com/grafov/bcast v0.0.0-20190217190352-1447f067e08d h1:Q2+KsA/1GLC9xyLsDun3/EOJ+83rY/IHRsO1DToPrdo= github.com/grafov/bcast v0.0.0-20190217190352-1447f067e08d/go.mod h1:RInr+B3/Tx70hYm0rpNPMTD7vH0pBG5ny/JsHAs2KcQ= github.com/gregjones/httpcache v0.0.0-20180305231024-9cad4c3443a7 h1:pdN6V1QBWetyv/0+wjACpqVH+eVULgEjkurDLq3goeM= github.com/gregjones/httpcache v0.0.0-20180305231024-9cad4c3443a7/go.mod h1:FecbI9+v66THATjSRHfNgh1IVFe/9kFxbXtjV0ctIMA= @@ -106,6 +114,7 @@ google.golang.org/appengine v1.5.0 h1:KxkO13IPW4Lslp2bz+KHP2E3gtFlrIGNThxkZQ3g+4 google.golang.org/appengine v1.5.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 h1:qIbj1fsPNlZgppZ+VLlY7N33q108Sa+fhmuc+sWQYwY= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/fatih/set.v0 v0.2.1 h1:Xvyyp7LXu34P0ROhCyfXkmQCAoOUKb1E2JS9I7SE5CY= gopkg.in/fatih/set.v0 v0.2.1/go.mod h1:5eLWEndGL4zGGemXWrKuts+wTJR0y+w+auqUJZbmyBg= gopkg.in/fsnotify.v1 v1.4.7 h1:xOHLXZwVvI9hhs+cLKq5+I5onOuwQLhQwiu63xxlHs4= gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys= @@ -119,6 +128,7 @@ gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.8 h1:obN1ZagJSUGI0Ek/LBmuj4SNLPfIny3KsKFopxRdj10= gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +k8s.io/klog v1.0.0 h1:Pt+yjF5aB1xDSVbau4VsWe+dQNzA0qv1LlXdC2dF6Q8= k8s.io/klog v1.0.0/go.mod h1:4Bi6QPql/J/LkTDqv7R/cd3hPo4k2DG6Ptcz060Ez5I= k8s.io/kube-openapi v0.0.0-20190228160746-b3a7cee44a30 h1:TRb4wNWoBVrH9plmkp2q86FIDppkbrEXdXlxU3a3BMI= k8s.io/kube-openapi v0.0.0-20190228160746-b3a7cee44a30/go.mod h1:BXM9ceUBTj2QnfH2MK1odQs778ajze1RxcmP6S8RVVc= diff --git a/staging/src/k8s.io/client-go/transport/round_trippers.go b/staging/src/k8s.io/client-go/transport/round_trippers.go index 117a9c8c4de..a362e893ab6 100644 --- a/staging/src/k8s.io/client-go/transport/round_trippers.go +++ b/staging/src/k8s.io/client-go/transport/round_trippers.go @@ -80,10 +80,6 @@ func DebugWrappers(rt http.RoundTripper) http.RoundTripper { return rt } -type requestCanceler interface { - CancelRequest(*http.Request) -} - type authProxyRoundTripper struct { username string groups []string @@ -140,11 +136,7 @@ func SetAuthProxyHeaders(req *http.Request, username string, groups []string, ex } func (rt *authProxyRoundTripper) CancelRequest(req *http.Request) { - if canceler, ok := rt.rt.(requestCanceler); ok { - canceler.CancelRequest(req) - } else { - klog.Errorf("CancelRequest not implemented by %T", rt.rt) - } + tryCancelRequest(rt.WrappedRoundTripper(), req) } func (rt *authProxyRoundTripper) WrappedRoundTripper() http.RoundTripper { return rt.rt } @@ -168,11 +160,7 @@ func (rt *userAgentRoundTripper) RoundTrip(req *http.Request) (*http.Response, e } func (rt *userAgentRoundTripper) CancelRequest(req *http.Request) { - if canceler, ok := rt.rt.(requestCanceler); ok { - canceler.CancelRequest(req) - } else { - klog.Errorf("CancelRequest not implemented by %T", rt.rt) - } + tryCancelRequest(rt.WrappedRoundTripper(), req) } func (rt *userAgentRoundTripper) WrappedRoundTripper() http.RoundTripper { return rt.rt } @@ -199,11 +187,7 @@ func (rt *basicAuthRoundTripper) RoundTrip(req *http.Request) (*http.Response, e } func (rt *basicAuthRoundTripper) CancelRequest(req *http.Request) { - if canceler, ok := rt.rt.(requestCanceler); ok { - canceler.CancelRequest(req) - } else { - klog.Errorf("CancelRequest not implemented by %T", rt.rt) - } + tryCancelRequest(rt.WrappedRoundTripper(), req) } func (rt *basicAuthRoundTripper) WrappedRoundTripper() http.RoundTripper { return rt.rt } @@ -259,11 +243,7 @@ func (rt *impersonatingRoundTripper) RoundTrip(req *http.Request) (*http.Respons } func (rt *impersonatingRoundTripper) CancelRequest(req *http.Request) { - if canceler, ok := rt.delegate.(requestCanceler); ok { - canceler.CancelRequest(req) - } else { - klog.Errorf("CancelRequest not implemented by %T", rt.delegate) - } + tryCancelRequest(rt.WrappedRoundTripper(), req) } func (rt *impersonatingRoundTripper) WrappedRoundTripper() http.RoundTripper { return rt.delegate } @@ -318,11 +298,7 @@ func (rt *bearerAuthRoundTripper) RoundTrip(req *http.Request) (*http.Response, } func (rt *bearerAuthRoundTripper) CancelRequest(req *http.Request) { - if canceler, ok := rt.rt.(requestCanceler); ok { - canceler.CancelRequest(req) - } else { - klog.Errorf("CancelRequest not implemented by %T", rt.rt) - } + tryCancelRequest(rt.WrappedRoundTripper(), req) } func (rt *bearerAuthRoundTripper) WrappedRoundTripper() http.RoundTripper { return rt.rt } @@ -402,11 +378,7 @@ func newDebuggingRoundTripper(rt http.RoundTripper, levels ...debugLevel) *debug } func (rt *debuggingRoundTripper) CancelRequest(req *http.Request) { - if canceler, ok := rt.delegatedRoundTripper.(requestCanceler); ok { - canceler.CancelRequest(req) - } else { - klog.Errorf("CancelRequest not implemented by %T", rt.delegatedRoundTripper) - } + tryCancelRequest(rt.WrappedRoundTripper(), req) } func (rt *debuggingRoundTripper) RoundTrip(req *http.Request) (*http.Response, error) { diff --git a/staging/src/k8s.io/client-go/transport/token_source.go b/staging/src/k8s.io/client-go/transport/token_source.go index b8cadd382af..bb32c3b4df5 100644 --- a/staging/src/k8s.io/client-go/transport/token_source.go +++ b/staging/src/k8s.io/client-go/transport/token_source.go @@ -25,6 +25,7 @@ import ( "time" "golang.org/x/oauth2" + "k8s.io/klog" ) @@ -81,6 +82,14 @@ func (tst *tokenSourceTransport) RoundTrip(req *http.Request) (*http.Response, e return tst.ort.RoundTrip(req) } +func (tst *tokenSourceTransport) CancelRequest(req *http.Request) { + if req.Header.Get("Authorization") != "" { + tryCancelRequest(tst.base, req) + return + } + tryCancelRequest(tst.ort, req) +} + type fileTokenSource struct { path string period time.Duration diff --git a/staging/src/k8s.io/client-go/transport/token_source_test.go b/staging/src/k8s.io/client-go/transport/token_source_test.go index a222495b94e..6d61cacaa9a 100644 --- a/staging/src/k8s.io/client-go/transport/token_source_test.go +++ b/staging/src/k8s.io/client-go/transport/token_source_test.go @@ -18,6 +18,7 @@ package transport import ( "fmt" + "net/http" "reflect" "sync" "testing" @@ -154,3 +155,85 @@ func TestCachingTokenSourceRace(t *testing.T) { } } } + +type uncancellableRT struct { + rt http.RoundTripper +} + +func (urt *uncancellableRT) RoundTrip(req *http.Request) (*http.Response, error) { + return urt.rt.RoundTrip(req) +} + +func TestCancellation(t *testing.T) { + tests := []struct { + name string + header http.Header + wrapTransport func(http.RoundTripper) http.RoundTripper + expectCancel bool + }{ + { + name: "cancel req with bearer token skips oauth rt", + header: map[string][]string{"Authorization": {"Bearer TOKEN"}}, + expectCancel: true, + }, + { + name: "cancel req without bearer token hits both rts", + expectCancel: true, + }, + { + name: "cancel req without bearer token hits both wrapped rts", + wrapTransport: func(rt http.RoundTripper) http.RoundTripper { + return NewUserAgentRoundTripper("testing testing", rt) + }, + expectCancel: true, + }, + { + name: "can't cancel request with rts that doesn't implent unwrap or cancel", + wrapTransport: func(rt http.RoundTripper) http.RoundTripper { + return &uncancellableRT{rt: rt} + }, + expectCancel: false, + }, + } + for _, test := range tests { + t.Run(test.name, func(t *testing.T) { + baseRecorder := &recordCancelRoundTripper{} + + var base http.RoundTripper = baseRecorder + if test.wrapTransport != nil { + base = test.wrapTransport(base) + } + + rt := &tokenSourceTransport{ + base: base, + ort: &oauth2.Transport{ + Base: base, + }, + } + + rt.CancelRequest(&http.Request{ + Header: test.header, + }) + + if baseRecorder.canceled != test.expectCancel { + t.Errorf("unexpected cancel: got=%v, want=%v", baseRecorder.canceled, test.expectCancel) + } + }) + } +} + +type recordCancelRoundTripper struct { + canceled bool + base http.RoundTripper +} + +func (rt *recordCancelRoundTripper) RoundTrip(req *http.Request) (*http.Response, error) { + return nil, nil +} + +func (rt *recordCancelRoundTripper) CancelRequest(req *http.Request) { + rt.canceled = true + if rt.base != nil { + tryCancelRequest(rt.base, req) + } +} diff --git a/staging/src/k8s.io/client-go/transport/transport.go b/staging/src/k8s.io/client-go/transport/transport.go index 2a145c971a3..1815c11ff32 100644 --- a/staging/src/k8s.io/client-go/transport/transport.go +++ b/staging/src/k8s.io/client-go/transport/transport.go @@ -23,6 +23,9 @@ import ( "fmt" "io/ioutil" "net/http" + + utilnet "k8s.io/apimachinery/pkg/util/net" + "k8s.io/klog" ) // New returns an http.RoundTripper that will provide the authentication @@ -225,3 +228,17 @@ func (b *contextCanceller) RoundTrip(req *http.Request) (*http.Response, error) return b.rt.RoundTrip(req) } } + +func tryCancelRequest(rt http.RoundTripper, req *http.Request) { + type canceler interface { + CancelRequest(*http.Request) + } + switch rt := rt.(type) { + case canceler: + rt.CancelRequest(req) + case utilnet.RoundTripperWrapper: + tryCancelRequest(rt.WrappedRoundTripper(), req) + default: + klog.Warningf("Unable to cancel request for %T", rt) + } +} diff --git a/staging/src/k8s.io/cloud-provider/go.sum b/staging/src/k8s.io/cloud-provider/go.sum index c50a27e2447..de8bf5d86ab 100644 --- a/staging/src/k8s.io/cloud-provider/go.sum +++ b/staging/src/k8s.io/cloud-provider/go.sum @@ -33,6 +33,7 @@ github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+ github.com/googleapis/gnostic v0.0.0-20170729233727-0c5108395e2d h1:7XGaL1e6bYS1yIonGp9761ExpPPV1ui0SAC59Yube9k= github.com/googleapis/gnostic v0.0.0-20170729233727-0c5108395e2d/go.mod h1:sJBsCZ4ayReDTBIg8b9dl28c5xFWyhBTVRp3pOg5EKY= github.com/gophercloud/gophercloud v0.6.0/go.mod h1:GICNByuaEBibcjmjvI7QvYJSZEbGkcYwAR7EZK2WMqM= +github.com/grafov/bcast v0.0.0-20190217190352-1447f067e08d h1:Q2+KsA/1GLC9xyLsDun3/EOJ+83rY/IHRsO1DToPrdo= github.com/grafov/bcast v0.0.0-20190217190352-1447f067e08d/go.mod h1:RInr+B3/Tx70hYm0rpNPMTD7vH0pBG5ny/JsHAs2KcQ= github.com/gregjones/httpcache v0.0.0-20180305231024-9cad4c3443a7/go.mod h1:FecbI9+v66THATjSRHfNgh1IVFe/9kFxbXtjV0ctIMA= github.com/hashicorp/golang-lru v0.5.0 h1:CL2msUPvZTLb5O648aiLNJw3hnBxN2+1Jq8rCOH9wdo= @@ -95,6 +96,7 @@ google.golang.org/appengine v1.5.0 h1:KxkO13IPW4Lslp2bz+KHP2E3gtFlrIGNThxkZQ3g+4 google.golang.org/appengine v1.5.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 h1:qIbj1fsPNlZgppZ+VLlY7N33q108Sa+fhmuc+sWQYwY= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/fatih/set.v0 v0.2.1 h1:Xvyyp7LXu34P0ROhCyfXkmQCAoOUKb1E2JS9I7SE5CY= gopkg.in/fatih/set.v0 v0.2.1/go.mod h1:5eLWEndGL4zGGemXWrKuts+wTJR0y+w+auqUJZbmyBg= gopkg.in/fsnotify.v1 v1.4.7 h1:xOHLXZwVvI9hhs+cLKq5+I5onOuwQLhQwiu63xxlHs4= gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys= @@ -108,6 +110,7 @@ gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.8 h1:obN1ZagJSUGI0Ek/LBmuj4SNLPfIny3KsKFopxRdj10= gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +k8s.io/klog v1.0.0 h1:Pt+yjF5aB1xDSVbau4VsWe+dQNzA0qv1LlXdC2dF6Q8= k8s.io/klog v1.0.0/go.mod h1:4Bi6QPql/J/LkTDqv7R/cd3hPo4k2DG6Ptcz060Ez5I= k8s.io/kube-openapi v0.0.0-20190228160746-b3a7cee44a30 h1:TRb4wNWoBVrH9plmkp2q86FIDppkbrEXdXlxU3a3BMI= k8s.io/kube-openapi v0.0.0-20190228160746-b3a7cee44a30/go.mod h1:BXM9ceUBTj2QnfH2MK1odQs778ajze1RxcmP6S8RVVc= diff --git a/staging/src/k8s.io/cluster-bootstrap/go.sum b/staging/src/k8s.io/cluster-bootstrap/go.sum index ba4d7bd935a..4e0feb5c0c4 100644 --- a/staging/src/k8s.io/cluster-bootstrap/go.sum +++ b/staging/src/k8s.io/cluster-bootstrap/go.sum @@ -67,6 +67,7 @@ gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.8 h1:obN1ZagJSUGI0Ek/LBmuj4SNLPfIny3KsKFopxRdj10= gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +k8s.io/klog v1.0.0 h1:Pt+yjF5aB1xDSVbau4VsWe+dQNzA0qv1LlXdC2dF6Q8= k8s.io/klog v1.0.0/go.mod h1:4Bi6QPql/J/LkTDqv7R/cd3hPo4k2DG6Ptcz060Ez5I= k8s.io/kube-openapi v0.0.0-20190228160746-b3a7cee44a30/go.mod h1:BXM9ceUBTj2QnfH2MK1odQs778ajze1RxcmP6S8RVVc= sigs.k8s.io/yaml v1.1.0 h1:4A07+ZFc2wgJwo8YNlQpr1rVlgUDlxXHhPJciaPY5gs= diff --git a/staging/src/k8s.io/code-generator/go.sum b/staging/src/k8s.io/code-generator/go.sum index fcb715b9f63..0a6b0b2fcc4 100644 --- a/staging/src/k8s.io/code-generator/go.sum +++ b/staging/src/k8s.io/code-generator/go.sum @@ -90,6 +90,7 @@ gopkg.in/yaml.v2 v2.2.8 h1:obN1ZagJSUGI0Ek/LBmuj4SNLPfIny3KsKFopxRdj10= gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= k8s.io/gengo v0.0.0-20200205140755-e0e292d8aa12 h1:pZzawYyz6VRNPVYpqGv61LWCimQv1BihyeqFrp50/G4= k8s.io/gengo v0.0.0-20200205140755-e0e292d8aa12/go.mod h1:ezvh/TsK7cY6rbqRK0oQQ8IAqLxYwwyPxAX1Pzy0ii0= +k8s.io/klog v1.0.0 h1:Pt+yjF5aB1xDSVbau4VsWe+dQNzA0qv1LlXdC2dF6Q8= k8s.io/klog v1.0.0/go.mod h1:4Bi6QPql/J/LkTDqv7R/cd3hPo4k2DG6Ptcz060Ez5I= k8s.io/kube-openapi v0.0.0-20190228160746-b3a7cee44a30/go.mod h1:BXM9ceUBTj2QnfH2MK1odQs778ajze1RxcmP6S8RVVc= modernc.org/cc v1.0.0/go.mod h1:1Sk4//wdnYJiUIxnW8ddKpaOJCF37yAdqYnkxUpaYxw= diff --git a/staging/src/k8s.io/component-base/go.mod b/staging/src/k8s.io/component-base/go.mod index 79a5d29ebcc..70dd584b197 100644 --- a/staging/src/k8s.io/component-base/go.mod +++ b/staging/src/k8s.io/component-base/go.mod @@ -13,21 +13,27 @@ require ( github.com/spf13/pflag v1.0.5 github.com/stretchr/testify v1.4.0 k8s.io/apimachinery v0.0.0 + k8s.io/client-go v0.0.0 k8s.io/klog v1.0.0 k8s.io/utils v0.0.0-20200324210504-a9aa75ae1b89 ) replace ( + cloud.google.com/go => cloud.google.com/go v0.34.0 + github.com/dgrijalva/jwt-go => github.com/dgrijalva/jwt-go v0.0.0-20160705203006-01aeca54ebda github.com/google/gofuzz => github.com/google/gofuzz v0.0.0-20170612174753-24818f796faf github.com/googleapis/gnostic => github.com/googleapis/gnostic v0.0.0-20170729233727-0c5108395e2d github.com/hashicorp/golang-lru => github.com/hashicorp/golang-lru v0.5.0 github.com/json-iterator/go => github.com/json-iterator/go v0.0.0-20180701071628-ab8a2e0c74be github.com/prometheus/client_golang => github.com/prometheus/client_golang v0.9.2 github.com/prometheus/common => github.com/prometheus/common v0.0.0-20181126121408-4724e9255275 + golang.org/x/sync => golang.org/x/sync v0.0.0-20181108010431-42b317875d0f golang.org/x/sys => golang.org/x/sys v0.0.0-20200622214017-ed371f2e16b4 golang.org/x/text => golang.org/x/text v0.3.1-0.20181227161524-e6919f6577db gopkg.in/check.v1 => gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 + k8s.io/api => ../api k8s.io/apimachinery => ../apimachinery + k8s.io/client-go => ../client-go k8s.io/component-base => ../component-base k8s.io/kube-openapi => k8s.io/kube-openapi v0.0.0-20190228160746-b3a7cee44a30 k8s.io/utils => k8s.io/utils v0.0.0-20190221042446-c2654d5206da diff --git a/staging/src/k8s.io/component-base/go.sum b/staging/src/k8s.io/component-base/go.sum index c421e7951e7..3ce366fb696 100644 --- a/staging/src/k8s.io/component-base/go.sum +++ b/staging/src/k8s.io/component-base/go.sum @@ -1,3 +1,11 @@ +cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= +github.com/Azure/go-autorest/autorest v0.9.0/go.mod h1:xyHB1BMZT0cuDHU7I0+g046+BFDTQ8rEZB0s4Yfa6bI= +github.com/Azure/go-autorest/autorest/adal v0.5.0/go.mod h1:8Z9fGy2MpX0PvDjB1pEgQTmVqjGhiHBW7RJJEciWzS0= +github.com/Azure/go-autorest/autorest/date v0.1.0/go.mod h1:plvfp3oPSKwf2DNjlBjWF/7vwR+cUD/ELuzDCXwHUVA= +github.com/Azure/go-autorest/autorest/mocks v0.1.0/go.mod h1:OTyCOPRA2IgIlWxVYxBee2F5Gr4kF2zd2J5cFRaIDN0= +github.com/Azure/go-autorest/autorest/mocks v0.2.0/go.mod h1:OTyCOPRA2IgIlWxVYxBee2F5Gr4kF2zd2J5cFRaIDN0= +github.com/Azure/go-autorest/logger v0.1.0/go.mod h1:oExouG+K6PryycPJfVSxi/koC6LSNgds39diKLz7Vrc= +github.com/Azure/go-autorest/tracing v0.5.0/go.mod h1:r/s2XiOKccPW3HrqB+W0TQzfbtp2fGCgRFtBroKn4Dk= github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973 h1:xJ4a3vCFaGF/jqvzLMYoU8P317H5OQ+Via4RmuPwCS0= github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q= github.com/blang/semver v3.5.0+incompatible h1:CGxCgetQ64DKk7rdZ++Vfnb1+ogGNnB17OJKJXD2Cfs= @@ -5,26 +13,38 @@ github.com/blang/semver v3.5.0+incompatible/go.mod h1:kRBLl5iJ+tD4TcOOxsy/0fnweb github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/dgrijalva/jwt-go v0.0.0-20160705203006-01aeca54ebda/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ= github.com/docker/spdystream v0.0.0-20160310174837-449fdfce4d96/go.mod h1:Qh8CwZgvJUkLughtfhJv5dyTYa91l1fOUCrgjqmcifM= github.com/elazarl/goproxy v0.0.0-20180725130230-947c36da3153/go.mod h1:/Zj4wYkgs4iZTTu3o/KG3Itv/qCCa8VVMlb3i9OVuzc= +github.com/evanphx/json-patch v4.9.0+incompatible h1:kLcOMZeuLAJvL2BPWLMIj5oaZQobrkAqrL+WFZwQses= github.com/evanphx/json-patch v4.9.0+incompatible/go.mod h1:50XU6AFN0ol/bzJsmQLiYLvXMP4fmwYFNcr97nuDLSk= +github.com/fsnotify/fsnotify v1.4.7 h1:IXs+QLmnXW2CcXuY+8Mzv/fWEsPGWxqefPtCP5CnV9I= github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo= github.com/go-logr/logr v0.1.0/go.mod h1:ixOQHD9gLJUVQQ2ZOR7zLEifBX6tGkNJF4QyIY7sIas= github.com/gogo/protobuf v1.3.1 h1:DqDEcV5aeaTmdFBePNpYsp3FlcVH/2ISVVM9Qf8PSls= github.com/gogo/protobuf v1.3.1/go.mod h1:SlYgWuQ5SjCEi6WLHjHCa1yvBfUnHcTbrrZtXPKa29o= +github.com/golang/groupcache v0.0.0-20160516000752-02826c3e7903 h1:LbsanbbD6LieFkXbj9YNNBupiGHJgFeLpO0j0Fza1h8= github.com/golang/groupcache v0.0.0-20160516000752-02826c3e7903/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= github.com/golang/protobuf v1.2.0 h1:P3YflyNX/ehuJFLhxviNdFxQPkGK5cDcApsge1SqnvM= github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/golang/protobuf v1.3.2 h1:6nsPYzhq5kReh6QImI3k5qWzO4PEbvbIW2cwSfR/6xs= github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= +github.com/google/btree v1.0.0/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= github.com/google/go-cmp v0.3.0 h1:crn/baboCvb5fXaQ0IJ1SGTsTVrWpDsCWC8EGETZijY= github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= github.com/google/gofuzz v0.0.0-20170612174753-24818f796faf h1:+RRA9JqSOZFfKrOeqr2z77+8R2RKyh8PG66dcu1V0ck= github.com/google/gofuzz v0.0.0-20170612174753-24818f796faf/go.mod h1:HP5RmnzzSNb993RKQDq4+1A4ia9nllfqcQFTQJedwGI= github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= +github.com/googleapis/gnostic v0.0.0-20170729233727-0c5108395e2d h1:7XGaL1e6bYS1yIonGp9761ExpPPV1ui0SAC59Yube9k= github.com/googleapis/gnostic v0.0.0-20170729233727-0c5108395e2d/go.mod h1:sJBsCZ4ayReDTBIg8b9dl28c5xFWyhBTVRp3pOg5EKY= +github.com/gophercloud/gophercloud v0.6.0/go.mod h1:GICNByuaEBibcjmjvI7QvYJSZEbGkcYwAR7EZK2WMqM= +github.com/grafov/bcast v0.0.0-20190217190352-1447f067e08d h1:Q2+KsA/1GLC9xyLsDun3/EOJ+83rY/IHRsO1DToPrdo= +github.com/grafov/bcast v0.0.0-20190217190352-1447f067e08d/go.mod h1:RInr+B3/Tx70hYm0rpNPMTD7vH0pBG5ny/JsHAs2KcQ= +github.com/gregjones/httpcache v0.0.0-20180305231024-9cad4c3443a7/go.mod h1:FecbI9+v66THATjSRHfNgh1IVFe/9kFxbXtjV0ctIMA= github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= +github.com/hpcloud/tail v1.0.0 h1:nfCOvKYfkgYP8hkirhJocXT2+zOD8yUNjXaWfTlyFKI= github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU= +github.com/imdario/mergo v0.3.5/go.mod h1:2EnlNZ0deacrJVfApfmtdGgDfMuh/nq6Ok1EcJh5FfA= github.com/json-iterator/go v0.0.0-20180701071628-ab8a2e0c74be h1:AHimNtVIpiBjPUhEF5KNCkrUyqTSA5zWUl8sQ2bfGBE= github.com/json-iterator/go v0.0.0-20180701071628-ab8a2e0c74be/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU= github.com/kisielk/errcheck v1.2.0/go.mod h1:/BMXB+zMLi60iA8Vv6Ksmxu/1UDYcXs4uQLJ+jE2L00= @@ -42,8 +62,12 @@ github.com/modern-go/reflect2 v1.0.1 h1:9f412s+6RmYXLWZSEzVVgPGK7C2PphHj5RJrvfx9 github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= github.com/mxk/go-flowrate v0.0.0-20140419014527-cca7078d478f/go.mod h1:ZdcZmHo+o7JKHSa8/e818NopupXU1YMK5fe1lsApnBw= github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= +github.com/onsi/ginkgo v1.11.0 h1:JAKSXpt1YjtLA7YpPiqO9ss6sNXEsPfSGdwN0UHqzrw= github.com/onsi/ginkgo v1.11.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= +github.com/onsi/gomega v1.7.0 h1:XPnZz8VVBHjVsy1vzJmRwIcSwiUO+JFfrv/xGiigmME= github.com/onsi/gomega v1.7.0/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY= +github.com/peterbourgon/diskv v2.0.1+incompatible/go.mod h1:uqqh8zWWbv1HBMNONnaR/tNboyR3/BZd58JJSHlUSCU= +github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= @@ -63,31 +87,49 @@ github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+ github.com/stretchr/testify v1.4.0 h1:2E4SXV/wtOkTonXsotYi4li6zVWxYlZuYNCXe9XRJyk= github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= +golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9 h1:psW17arqaxU48Z5kZ0CQnkZWQJsqcURM6tKiBApRjXI= golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= +golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20181201002055-351d144fa1fc/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20190108225652-1e06a53dbb7e/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20201008223702-a5fa9d4b7c91 h1:zd7kl5i5PDM0OnFbRWVM6B8mXojzv8LOkHN9LsOrRf4= golang.org/x/net v0.0.0-20201008223702-a5fa9d4b7c91/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= +golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45 h1:SVwTIAaPC2U/AvvLNZ2a7OVsmBpC8L5BlwK1whH3hm0= +golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/sync v0.0.0-20181108010431-42b317875d0f h1:Bl/8QSvNqXvPGPGXa2z5xUTmV7VDcZyvRZ+QQXkXTZQ= golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sys v0.0.0-20200622214017-ed371f2e16b4 h1:5/PjkGUjvEU5Gl6BxmvKRPpqo2uNMv4rcHBMwzk/st8= golang.org/x/sys v0.0.0-20200622214017-ed371f2e16b4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/text v0.3.1-0.20181227161524-e6919f6577db h1:6/JqlYfC1CCaLnGceQTI+sDGhC9UBSPAsBqI0Gun6kU= golang.org/x/text v0.3.1-0.20181227161524-e6919f6577db/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= +golang.org/x/time v0.0.0-20191024005414-555d28b269f0 h1:/5xXl8Y5W96D+TtHSlonuFqGHIWVuyCkGJLwGh9JJFs= +golang.org/x/time v0.0.0-20191024005414-555d28b269f0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20181030221726-6c7e314b6563/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= +google.golang.org/appengine v1.5.0 h1:KxkO13IPW4Lslp2bz+KHP2E3gtFlrIGNThxkZQ3g+4c= +google.golang.org/appengine v1.5.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 h1:qIbj1fsPNlZgppZ+VLlY7N33q108Sa+fhmuc+sWQYwY= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/fatih/set.v0 v0.2.1 h1:Xvyyp7LXu34P0ROhCyfXkmQCAoOUKb1E2JS9I7SE5CY= +gopkg.in/fatih/set.v0 v0.2.1/go.mod h1:5eLWEndGL4zGGemXWrKuts+wTJR0y+w+auqUJZbmyBg= +gopkg.in/fsnotify.v1 v1.4.7 h1:xOHLXZwVvI9hhs+cLKq5+I5onOuwQLhQwiu63xxlHs4= gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys= gopkg.in/inf.v0 v0.9.1 h1:73M5CoZyi3ZLMOyDlQh031Cx6N9NDJ2Vvfl76EDAgDc= gopkg.in/inf.v0 v0.9.1/go.mod h1:cWUDdTG/fYaXco+Dcufb5Vnc6Gp2YChqWtbxRZE0mXw= +gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 h1:uRGJdciOHaEIrze2W8Q3AKkepLTh2hOroT7a+7czfdQ= gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw= gopkg.in/yaml.v2 v2.2.1 h1:mUhvW9EsL+naU5Q3cakzfE91YhliOondGd6ZrsDBHQE= gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.8 h1:obN1ZagJSUGI0Ek/LBmuj4SNLPfIny3KsKFopxRdj10= gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +k8s.io/klog v1.0.0 h1:Pt+yjF5aB1xDSVbau4VsWe+dQNzA0qv1LlXdC2dF6Q8= k8s.io/klog v1.0.0/go.mod h1:4Bi6QPql/J/LkTDqv7R/cd3hPo4k2DG6Ptcz060Ez5I= +k8s.io/kube-openapi v0.0.0-20190228160746-b3a7cee44a30 h1:TRb4wNWoBVrH9plmkp2q86FIDppkbrEXdXlxU3a3BMI= k8s.io/kube-openapi v0.0.0-20190228160746-b3a7cee44a30/go.mod h1:BXM9ceUBTj2QnfH2MK1odQs778ajze1RxcmP6S8RVVc= k8s.io/utils v0.0.0-20190221042446-c2654d5206da h1:ElyM7RPonbKnQqOcw7dG2IK5uvQQn3b/WPHqD5mBvP4= k8s.io/utils v0.0.0-20190221042446-c2654d5206da/go.mod h1:8k8uAuAQ0rXslZKaEWd0c3oVhZz7sSzSiPnVZayjIX0= diff --git a/staging/src/k8s.io/component-base/metrics/BUILD b/staging/src/k8s.io/component-base/metrics/BUILD index 14e7359980c..a93d3ed12de 100644 --- a/staging/src/k8s.io/component-base/metrics/BUILD +++ b/staging/src/k8s.io/component-base/metrics/BUILD @@ -1,4 +1,4 @@ -load("@io_bazel_rules_go//go:def.bzl", "go_library") +load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") go_library( name = "go_default_library", @@ -47,8 +47,30 @@ filegroup( srcs = [ ":package-srcs", "//staging/src/k8s.io/component-base/metrics/legacyregistry:all-srcs", + "//staging/src/k8s.io/component-base/metrics/prometheus/clientgo:all-srcs", + "//staging/src/k8s.io/component-base/metrics/prometheus/restclient:all-srcs", + "//staging/src/k8s.io/component-base/metrics/prometheus/workqueue:all-srcs", "//staging/src/k8s.io/component-base/metrics/testutil:all-srcs", ], tags = ["automanaged"], visibility = ["//visibility:public"], ) + +go_test( + name = "go_default_test", + srcs = [ + "counter_test.go", + "gauge_test.go", + "histogram_test.go", + "registry_test.go", + "summary_test.go", + ], + embed = [":go_default_library"], + deps = [ + "//staging/src/k8s.io/apimachinery/pkg/version:go_default_library", + "//vendor/github.com/blang/semver:go_default_library", + "//vendor/github.com/prometheus/client_golang/prometheus:go_default_library", + "//vendor/github.com/prometheus/common/expfmt:go_default_library", + "//vendor/github.com/stretchr/testify/assert:go_default_library", + ], +) diff --git a/staging/src/k8s.io/component-base/metrics/counter_test.go b/staging/src/k8s.io/component-base/metrics/counter_test.go new file mode 100644 index 00000000000..c1d1a22e56c --- /dev/null +++ b/staging/src/k8s.io/component-base/metrics/counter_test.go @@ -0,0 +1,228 @@ +/* +Copyright 2019 The Kubernetes Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package metrics + +import ( + "bytes" + "github.com/blang/semver" + "github.com/prometheus/common/expfmt" + apimachineryversion "k8s.io/apimachinery/pkg/version" + "testing" +) + +func TestCounter(t *testing.T) { + var tests = []struct { + desc string + *CounterOpts + expectedMetricCount int + expectedHelp string + }{ + { + desc: "Test non deprecated", + CounterOpts: &CounterOpts{ + Namespace: "namespace", + Name: "metric_test_name", + Subsystem: "subsystem", + StabilityLevel: ALPHA, + Help: "counter help", + }, + expectedMetricCount: 1, + expectedHelp: "[ALPHA] counter help", + }, + { + desc: "Test deprecated", + CounterOpts: &CounterOpts{ + Namespace: "namespace", + Name: "metric_test_name", + Subsystem: "subsystem", + Help: "counter help", + StabilityLevel: ALPHA, + DeprecatedVersion: "1.15.0", + }, + expectedMetricCount: 1, + expectedHelp: "[ALPHA] (Deprecated since 1.15.0) counter help", + }, + { + desc: "Test hidden", + CounterOpts: &CounterOpts{ + Namespace: "namespace", + Name: "metric_test_name", + Subsystem: "subsystem", + Help: "counter help", + StabilityLevel: ALPHA, + DeprecatedVersion: "1.14.0", + }, + expectedMetricCount: 0, + }, + } + + for _, test := range tests { + t.Run(test.desc, func(t *testing.T) { + registry := newKubeRegistry(apimachineryversion.Info{ + Major: "1", + Minor: "15", + GitVersion: "v1.15.0-alpha-1.12345", + }) + c := NewCounter(test.CounterOpts) + registry.MustRegister(c) + + ms, err := registry.Gather() + var buf bytes.Buffer + enc := expfmt.NewEncoder(&buf, "text/plain; version=0.0.4; charset=utf-8") + + if len(ms) != test.expectedMetricCount { + t.Errorf("Got %v metrics, Want: %v metrics", len(ms), test.expectedMetricCount) + } + if err != nil { + t.Fatalf("Gather failed %v", err) + } + for _, metric := range ms { + err := enc.Encode(metric) + if err != nil { + t.Fatalf("Unexpected err %v in encoding the metric", err) + } + if metric.GetHelp() != test.expectedHelp { + t.Errorf("Got %s as help message, want %s", metric.GetHelp(), test.expectedHelp) + } + } + + // increment the counter N number of times and verify that the metric retains the count correctly + numberOfTimesToIncrement := 3 + for i := 0; i < numberOfTimesToIncrement; i++ { + c.Inc() + } + ms, err = registry.Gather() + if err != nil { + t.Fatalf("Gather failed %v", err) + } + for _, mf := range ms { + for _, m := range mf.GetMetric() { + if int(m.GetCounter().GetValue()) != numberOfTimesToIncrement { + t.Errorf("Got %v, wanted %v as the count", m.GetCounter().GetValue(), numberOfTimesToIncrement) + } + } + } + }) + } +} + +func TestCounterVec(t *testing.T) { + var tests = []struct { + desc string + *CounterOpts + labels []string + registryVersion *semver.Version + expectedMetricFamilyCount int + expectedHelp string + }{ + { + desc: "Test non deprecated", + CounterOpts: &CounterOpts{ + Namespace: "namespace", + Name: "metric_test_name", + Subsystem: "subsystem", + Help: "counter help", + }, + labels: []string{"label_a", "label_b"}, + expectedMetricFamilyCount: 1, + expectedHelp: "[ALPHA] counter help", + }, + { + desc: "Test deprecated", + CounterOpts: &CounterOpts{ + Namespace: "namespace", + Name: "metric_test_name", + Subsystem: "subsystem", + Help: "counter help", + DeprecatedVersion: "1.15.0", + }, + labels: []string{"label_a", "label_b"}, + expectedMetricFamilyCount: 1, + expectedHelp: "[ALPHA] (Deprecated since 1.15.0) counter help", + }, + { + desc: "Test hidden", + CounterOpts: &CounterOpts{ + Namespace: "namespace", + Name: "metric_test_name", + Subsystem: "subsystem", + Help: "counter help", + DeprecatedVersion: "1.14.0", + }, + labels: []string{"label_a", "label_b"}, + expectedMetricFamilyCount: 0, + expectedHelp: "counter help", + }, + { + desc: "Test alpha", + CounterOpts: &CounterOpts{ + StabilityLevel: ALPHA, + Namespace: "namespace", + Name: "metric_test_name", + Subsystem: "subsystem", + Help: "counter help", + }, + labels: []string{"label_a", "label_b"}, + expectedMetricFamilyCount: 1, + expectedHelp: "[ALPHA] counter help", + }, + } + + for _, test := range tests { + t.Run(test.desc, func(t *testing.T) { + registry := newKubeRegistry(apimachineryversion.Info{ + Major: "1", + Minor: "15", + GitVersion: "v1.15.0-alpha-1.12345", + }) + c := NewCounterVec(test.CounterOpts, test.labels) + registry.MustRegister(c) + c.WithLabelValues("1", "2").Inc() + mfs, err := registry.Gather() + if len(mfs) != test.expectedMetricFamilyCount { + t.Errorf("Got %v metric families, Want: %v metric families", len(mfs), test.expectedMetricFamilyCount) + } + if err != nil { + t.Fatalf("Gather failed %v", err) + } + // this no-opts here when there are no metric families (i.e. when the metric is hidden) + for _, mf := range mfs { + if len(mf.GetMetric()) != 1 { + t.Errorf("Got %v metrics, wanted 1 as the count", len(mf.GetMetric())) + } + if mf.GetHelp() != test.expectedHelp { + t.Errorf("Got %s as help message, want %s", mf.GetHelp(), test.expectedHelp) + } + } + + // let's increment the counter and verify that the metric still works + c.WithLabelValues("1", "3").Inc() + c.WithLabelValues("2", "3").Inc() + mfs, err = registry.Gather() + if err != nil { + t.Fatalf("Gather failed %v", err) + } + + // this no-opts here when there are no metric families (i.e. when the metric is hidden) + for _, mf := range mfs { + if len(mf.GetMetric()) != 3 { + t.Errorf("Got %v metrics, wanted 3 as the count", len(mf.GetMetric())) + } + } + }) + } +} diff --git a/staging/src/k8s.io/component-base/metrics/gauge_test.go b/staging/src/k8s.io/component-base/metrics/gauge_test.go new file mode 100644 index 00000000000..ada349ac979 --- /dev/null +++ b/staging/src/k8s.io/component-base/metrics/gauge_test.go @@ -0,0 +1,208 @@ +/* +Copyright 2019 The Kubernetes Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package metrics + +import ( + "github.com/blang/semver" + apimachineryversion "k8s.io/apimachinery/pkg/version" + "testing" +) + +func TestGauge(t *testing.T) { + v115 := semver.MustParse("1.15.0") + var tests = []struct { + desc string + GaugeOpts + registryVersion *semver.Version + expectedMetricCount int + expectedHelp string + }{ + { + desc: "Test non deprecated", + GaugeOpts: GaugeOpts{ + Namespace: "namespace", + Name: "metric_test_name", + Subsystem: "subsystem", + Help: "gauge help", + }, + registryVersion: &v115, + expectedMetricCount: 1, + expectedHelp: "[ALPHA] gauge help", + }, + { + desc: "Test deprecated", + GaugeOpts: GaugeOpts{ + Namespace: "namespace", + Name: "metric_test_name", + Subsystem: "subsystem", + Help: "gauge help", + DeprecatedVersion: "1.15.0", + }, + registryVersion: &v115, + expectedMetricCount: 1, + expectedHelp: "[ALPHA] (Deprecated since 1.15.0) gauge help", + }, + { + desc: "Test hidden", + GaugeOpts: GaugeOpts{ + Namespace: "namespace", + Name: "metric_test_name", + Subsystem: "subsystem", + Help: "gauge help", + DeprecatedVersion: "1.14.0", + }, + registryVersion: &v115, + expectedMetricCount: 0, + expectedHelp: "gauge help", + }, + } + + for _, test := range tests { + t.Run(test.desc, func(t *testing.T) { + registry := newKubeRegistry(apimachineryversion.Info{ + Major: "1", + Minor: "15", + GitVersion: "v1.15.0-alpha-1.12345", + }) + c := NewGauge(&test.GaugeOpts) + registry.MustRegister(c) + + ms, err := registry.Gather() + if len(ms) != test.expectedMetricCount { + t.Errorf("Got %v metrics, Want: %v metrics", len(ms), test.expectedMetricCount) + } + if err != nil { + t.Fatalf("Gather failed %v", err) + } + for _, metric := range ms { + if metric.GetHelp() != test.expectedHelp { + t.Errorf("Got %s as help message, want %s", metric.GetHelp(), test.expectedHelp) + } + } + + // let's increment the counter and verify that the metric still works + c.Set(100) + c.Set(101) + expected := 101 + ms, err = registry.Gather() + if err != nil { + t.Fatalf("Gather failed %v", err) + } + for _, mf := range ms { + for _, m := range mf.GetMetric() { + if int(m.GetGauge().GetValue()) != expected { + t.Errorf("Got %v, wanted %v as the count", m.GetGauge().GetValue(), expected) + } + t.Logf("%v\n", m.GetGauge().GetValue()) + } + } + }) + } +} + +func TestGaugeVec(t *testing.T) { + v115 := semver.MustParse("1.15.0") + var tests = []struct { + desc string + GaugeOpts + labels []string + registryVersion *semver.Version + expectedMetricCount int + expectedHelp string + }{ + { + desc: "Test non deprecated", + GaugeOpts: GaugeOpts{ + Namespace: "namespace", + Name: "metric_test_name", + Subsystem: "subsystem", + Help: "gauge help", + }, + labels: []string{"label_a", "label_b"}, + registryVersion: &v115, + expectedMetricCount: 1, + expectedHelp: "[ALPHA] gauge help", + }, + { + desc: "Test deprecated", + GaugeOpts: GaugeOpts{ + Namespace: "namespace", + Name: "metric_test_name", + Subsystem: "subsystem", + Help: "gauge help", + DeprecatedVersion: "1.15.0", + }, + labels: []string{"label_a", "label_b"}, + registryVersion: &v115, + expectedMetricCount: 1, + expectedHelp: "[ALPHA] (Deprecated since 1.15.0) gauge help", + }, + { + desc: "Test hidden", + GaugeOpts: GaugeOpts{ + Namespace: "namespace", + Name: "metric_test_name", + Subsystem: "subsystem", + Help: "gauge help", + DeprecatedVersion: "1.14.0", + }, + labels: []string{"label_a", "label_b"}, + registryVersion: &v115, + expectedMetricCount: 0, + expectedHelp: "gauge help", + }, + } + + for _, test := range tests { + t.Run(test.desc, func(t *testing.T) { + registry := newKubeRegistry(apimachineryversion.Info{ + Major: "1", + Minor: "15", + GitVersion: "v1.15.0-alpha-1.12345", + }) + c := NewGaugeVec(&test.GaugeOpts, test.labels) + registry.MustRegister(c) + c.WithLabelValues("1", "2").Set(1.0) + ms, err := registry.Gather() + + if len(ms) != test.expectedMetricCount { + t.Errorf("Got %v metrics, Want: %v metrics", len(ms), test.expectedMetricCount) + } + if err != nil { + t.Fatalf("Gather failed %v", err) + } + for _, metric := range ms { + if metric.GetHelp() != test.expectedHelp { + t.Errorf("Got %s as help message, want %s", metric.GetHelp(), test.expectedHelp) + } + } + + // let's increment the counter and verify that the metric still works + c.WithLabelValues("1", "3").Set(1.0) + c.WithLabelValues("2", "3").Set(1.0) + ms, err = registry.Gather() + if err != nil { + t.Fatalf("Gather failed %v", err) + } + for _, mf := range ms { + if len(mf.GetMetric()) != 3 { + t.Errorf("Got %v metrics, wanted 2 as the count", len(mf.GetMetric())) + } + } + }) + } +} diff --git a/staging/src/k8s.io/component-base/metrics/histogram_test.go b/staging/src/k8s.io/component-base/metrics/histogram_test.go new file mode 100644 index 00000000000..895178b9a71 --- /dev/null +++ b/staging/src/k8s.io/component-base/metrics/histogram_test.go @@ -0,0 +1,223 @@ +/* +Copyright 2019 The Kubernetes Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package metrics + +import ( + "github.com/blang/semver" + "github.com/prometheus/client_golang/prometheus" + apimachineryversion "k8s.io/apimachinery/pkg/version" + "testing" +) + +func TestHistogram(t *testing.T) { + v115 := semver.MustParse("1.15.0") + var tests = []struct { + desc string + HistogramOpts + registryVersion *semver.Version + expectedMetricCount int + expectedHelp string + }{ + { + desc: "Test non deprecated", + HistogramOpts: HistogramOpts{ + Namespace: "namespace", + Name: "metric_test_name", + Subsystem: "subsystem", + Help: "histogram help message", + Buckets: prometheus.DefBuckets, + }, + registryVersion: &v115, + expectedMetricCount: 1, + expectedHelp: "[ALPHA] histogram help message", + }, + { + desc: "Test deprecated", + HistogramOpts: HistogramOpts{ + Namespace: "namespace", + Name: "metric_test_name", + Subsystem: "subsystem", + Help: "histogram help message", + DeprecatedVersion: "1.15.0", + Buckets: prometheus.DefBuckets, + }, + registryVersion: &v115, + expectedMetricCount: 1, + expectedHelp: "[ALPHA] (Deprecated since 1.15.0) histogram help message", + }, + { + desc: "Test hidden", + HistogramOpts: HistogramOpts{ + Namespace: "namespace", + Name: "metric_test_name", + Subsystem: "subsystem", + Help: "histogram help message", + DeprecatedVersion: "1.14.0", + Buckets: prometheus.DefBuckets, + }, + registryVersion: &v115, + expectedMetricCount: 0, + expectedHelp: "histogram help message", + }, + } + + for _, test := range tests { + t.Run(test.desc, func(t *testing.T) { + registry := newKubeRegistry(apimachineryversion.Info{ + Major: "1", + Minor: "15", + GitVersion: "v1.15.0-alpha-1.12345", + }) + c := NewHistogram(&test.HistogramOpts) + registry.MustRegister(c) + + ms, err := registry.Gather() + if len(ms) != test.expectedMetricCount { + t.Errorf("Got %v metrics, Want: %v metrics", len(ms), test.expectedMetricCount) + } + if err != nil { + t.Fatalf("Gather failed %v", err) + } + for _, metric := range ms { + if metric.GetHelp() != test.expectedHelp { + t.Errorf("Got %s as help message, want %s", metric.GetHelp(), test.expectedHelp) + } + } + + // let's increment the counter and verify that the metric still works + c.Observe(1) + c.Observe(2) + c.Observe(3) + c.Observe(1.5) + expected := 4 + ms, err = registry.Gather() + if err != nil { + t.Fatalf("Gather failed %v", err) + } + for _, mf := range ms { + for _, m := range mf.GetMetric() { + if int(m.GetHistogram().GetSampleCount()) != expected { + t.Errorf("Got %v, want %v as the sample count", m.GetHistogram().GetSampleCount(), expected) + } + } + } + }) + } +} + +func TestHistogramVec(t *testing.T) { + v115 := semver.MustParse("1.15.0") + var tests = []struct { + desc string + HistogramOpts + labels []string + registryVersion *semver.Version + expectedMetricCount int + expectedHelp string + }{ + { + desc: "Test non deprecated", + HistogramOpts: HistogramOpts{ + Namespace: "namespace", + Name: "metric_test_name", + Subsystem: "subsystem", + Help: "histogram help message", + Buckets: prometheus.DefBuckets, + }, + labels: []string{"label_a", "label_b"}, + registryVersion: &v115, + expectedMetricCount: 1, + expectedHelp: "[ALPHA] histogram help message", + }, + { + desc: "Test deprecated", + HistogramOpts: HistogramOpts{ + Namespace: "namespace", + Name: "metric_test_name", + Subsystem: "subsystem", + Help: "histogram help message", + DeprecatedVersion: "1.15.0", + Buckets: prometheus.DefBuckets, + }, + labels: []string{"label_a", "label_b"}, + registryVersion: &v115, + expectedMetricCount: 1, + expectedHelp: "[ALPHA] (Deprecated since 1.15.0) histogram help message", + }, + { + desc: "Test hidden", + HistogramOpts: HistogramOpts{ + Namespace: "namespace", + Name: "metric_test_name", + Subsystem: "subsystem", + Help: "histogram help message", + DeprecatedVersion: "1.14.0", + Buckets: prometheus.DefBuckets, + }, + labels: []string{"label_a", "label_b"}, + registryVersion: &v115, + expectedMetricCount: 0, + expectedHelp: "histogram help message", + }, + } + + for _, test := range tests { + t.Run(test.desc, func(t *testing.T) { + registry := newKubeRegistry(apimachineryversion.Info{ + Major: "1", + Minor: "15", + GitVersion: "v1.15.0-alpha-1.12345", + }) + c := NewHistogramVec(&test.HistogramOpts, test.labels) + registry.MustRegister(c) + c.WithLabelValues("1", "2").Observe(1.0) + ms, err := registry.Gather() + + if len(ms) != test.expectedMetricCount { + t.Errorf("Got %v metrics, Want: %v metrics", len(ms), test.expectedMetricCount) + } + if err != nil { + t.Fatalf("Gather failed %v", err) + } + for _, metric := range ms { + if metric.GetHelp() != test.expectedHelp { + t.Errorf("Got %s as help message, want %s", metric.GetHelp(), test.expectedHelp) + } + } + + // let's increment the counter and verify that the metric still works + c.WithLabelValues("1", "3").Observe(1.0) + c.WithLabelValues("2", "3").Observe(1.0) + ms, err = registry.Gather() + if err != nil { + t.Fatalf("Gather failed %v", err) + } + for _, mf := range ms { + if len(mf.GetMetric()) != 3 { + t.Errorf("Got %v metrics, wanted 2 as the count", len(mf.GetMetric())) + } + for _, m := range mf.GetMetric() { + if m.GetHistogram().GetSampleCount() != 1 { + t.Errorf( + "Got %v metrics, expected histogram sample count to equal 1", + m.GetHistogram().GetSampleCount()) + } + } + } + }) + } +} diff --git a/staging/src/k8s.io/component-base/metrics/prometheus/clientgo/BUILD b/staging/src/k8s.io/component-base/metrics/prometheus/clientgo/BUILD new file mode 100644 index 00000000000..c519a817965 --- /dev/null +++ b/staging/src/k8s.io/component-base/metrics/prometheus/clientgo/BUILD @@ -0,0 +1,31 @@ +package(default_visibility = ["//visibility:public"]) + +load("@io_bazel_rules_go//go:def.bzl", "go_library") + +go_library( + name = "go_default_library", + srcs = ["metrics.go"], + importmap = "k8s.io/kubernetes/vendor/k8s.io/component-base/metrics/prometheus/clientgo", + importpath = "k8s.io/component-base/metrics/prometheus/clientgo", + deps = [ + "//staging/src/k8s.io/component-base/metrics/prometheus/clientgo/leaderelection:go_default_library", + "//staging/src/k8s.io/component-base/metrics/prometheus/restclient:go_default_library", + "//staging/src/k8s.io/component-base/metrics/prometheus/workqueue:go_default_library", + ], +) + +filegroup( + name = "package-srcs", + srcs = glob(["**"]), + tags = ["automanaged"], + visibility = ["//visibility:private"], +) + +filegroup( + name = "all-srcs", + srcs = [ + ":package-srcs", + "//staging/src/k8s.io/component-base/metrics/prometheus/clientgo/leaderelection:all-srcs", + ], + tags = ["automanaged"], +) diff --git a/staging/src/k8s.io/component-base/metrics/prometheus/clientgo/leaderelection/BUILD b/staging/src/k8s.io/component-base/metrics/prometheus/clientgo/leaderelection/BUILD new file mode 100644 index 00000000000..d4634d4d5e0 --- /dev/null +++ b/staging/src/k8s.io/component-base/metrics/prometheus/clientgo/leaderelection/BUILD @@ -0,0 +1,28 @@ +load("@io_bazel_rules_go//go:def.bzl", "go_library") + +go_library( + name = "go_default_library", + srcs = ["metrics.go"], + importmap = "k8s.io/kubernetes/vendor/k8s.io/component-base/metrics/prometheus/clientgo/leaderelection", + importpath = "k8s.io/component-base/metrics/prometheus/clientgo/leaderelection", + visibility = ["//visibility:public"], + deps = [ + "//staging/src/k8s.io/client-go/tools/leaderelection:go_default_library", + "//staging/src/k8s.io/component-base/metrics:go_default_library", + "//staging/src/k8s.io/component-base/metrics/legacyregistry:go_default_library", + ], +) + +filegroup( + name = "package-srcs", + srcs = glob(["**"]), + tags = ["automanaged"], + visibility = ["//visibility:private"], +) + +filegroup( + name = "all-srcs", + srcs = [":package-srcs"], + tags = ["automanaged"], + visibility = ["//visibility:public"], +) diff --git a/staging/src/k8s.io/component-base/metrics/prometheus/clientgo/leaderelection/metrics.go b/staging/src/k8s.io/component-base/metrics/prometheus/clientgo/leaderelection/metrics.go new file mode 100644 index 00000000000..6592c755b3f --- /dev/null +++ b/staging/src/k8s.io/component-base/metrics/prometheus/clientgo/leaderelection/metrics.go @@ -0,0 +1,53 @@ +/* +Copyright 2018 The Kubernetes Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package leaderelection + +import ( + "k8s.io/client-go/tools/leaderelection" + k8smetrics "k8s.io/component-base/metrics" + "k8s.io/component-base/metrics/legacyregistry" +) + +var ( + leaderGauge = k8smetrics.NewGaugeVec(&k8smetrics.GaugeOpts{ + Name: "leader_election_master_status", + Help: "Gauge of if the reporting system is master of the relevant lease, 0 indicates backup, 1 indicates master. 'name' is the string used to identify the lease. Please make sure to group by name.", + }, []string{"name"}) +) + +func init() { + legacyregistry.MustRegister(leaderGauge) + leaderelection.SetProvider(prometheusMetricsProvider{}) +} + +type prometheusMetricsProvider struct{} + +func (prometheusMetricsProvider) NewLeaderMetric() leaderelection.SwitchMetric { + return &switchAdapter{gauge: leaderGauge} +} + +type switchAdapter struct { + gauge *k8smetrics.GaugeVec +} + +func (s *switchAdapter) On(name string) { + s.gauge.WithLabelValues(name).Set(1.0) +} + +func (s *switchAdapter) Off(name string) { + s.gauge.WithLabelValues(name).Set(0.0) +} diff --git a/staging/src/k8s.io/component-base/metrics/prometheus/clientgo/metrics.go b/staging/src/k8s.io/component-base/metrics/prometheus/clientgo/metrics.go new file mode 100644 index 00000000000..43574ca9a39 --- /dev/null +++ b/staging/src/k8s.io/component-base/metrics/prometheus/clientgo/metrics.go @@ -0,0 +1,23 @@ +/* +Copyright 2019 The Kubernetes Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package clientgo + +import ( + _ "k8s.io/component-base/metrics/prometheus/clientgo/leaderelection" // load leaderelection metrics + _ "k8s.io/component-base/metrics/prometheus/restclient" // load restclient metrics + _ "k8s.io/component-base/metrics/prometheus/workqueue" // load the workqueue metrics +) diff --git a/staging/src/k8s.io/component-base/metrics/prometheus/restclient/BUILD b/staging/src/k8s.io/component-base/metrics/prometheus/restclient/BUILD new file mode 100644 index 00000000000..85098adcaa6 --- /dev/null +++ b/staging/src/k8s.io/component-base/metrics/prometheus/restclient/BUILD @@ -0,0 +1,32 @@ +package(default_visibility = ["//visibility:public"]) + +load( + "@io_bazel_rules_go//go:def.bzl", + "go_library", +) + +go_library( + name = "go_default_library", + srcs = ["metrics.go"], + importmap = "k8s.io/kubernetes/vendor/k8s.io/component-base/metrics/prometheus/restclient", + importpath = "k8s.io/component-base/metrics/prometheus/restclient", + deps = [ + "//staging/src/k8s.io/client-go/tools/metrics:go_default_library", + "//staging/src/k8s.io/component-base/metrics:go_default_library", + "//staging/src/k8s.io/component-base/metrics/legacyregistry:go_default_library", + "//vendor/github.com/prometheus/client_golang/prometheus:go_default_library", + ], +) + +filegroup( + name = "package-srcs", + srcs = glob(["**"]), + tags = ["automanaged"], + visibility = ["//visibility:private"], +) + +filegroup( + name = "all-srcs", + srcs = [":package-srcs"], + tags = ["automanaged"], +) diff --git a/staging/src/k8s.io/component-base/metrics/prometheus/restclient/metrics.go b/staging/src/k8s.io/component-base/metrics/prometheus/restclient/metrics.go new file mode 100644 index 00000000000..805ef722ef7 --- /dev/null +++ b/staging/src/k8s.io/component-base/metrics/prometheus/restclient/metrics.go @@ -0,0 +1,84 @@ +/* +Copyright 2016 The Kubernetes Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package restclient + +import ( + "net/url" + "time" + + "github.com/prometheus/client_golang/prometheus" + + "k8s.io/client-go/tools/metrics" + k8smetrics "k8s.io/component-base/metrics" + "k8s.io/component-base/metrics/legacyregistry" +) + +var ( + // requestLatency is a Prometheus Summary metric type partitioned by + // "verb" and "url" labels. It is used for the rest client latency metrics. + requestLatency = k8smetrics.NewHistogramVec( + &k8smetrics.HistogramOpts{ + Name: "rest_client_request_duration_seconds", + Help: "Request latency in seconds. Broken down by verb and URL.", + Buckets: prometheus.ExponentialBuckets(0.001, 2, 10), + }, + []string{"verb", "url"}, + ) + + // deprecatedRequestLatency is deprecated, please use requestLatency. + deprecatedRequestLatency = k8smetrics.NewHistogramVec( + &k8smetrics.HistogramOpts{ + Name: "rest_client_request_latency_seconds", + Help: "(Deprecated) Request latency in seconds. Broken down by verb and URL.", + Buckets: prometheus.ExponentialBuckets(0.001, 2, 10), + }, + []string{"verb", "url"}, + ) + + requestResult = k8smetrics.NewCounterVec( + &k8smetrics.CounterOpts{ + Name: "rest_client_requests_total", + Help: "Number of HTTP requests, partitioned by status code, method, and host.", + }, + []string{"code", "method", "host"}, + ) +) + +func init() { + legacyregistry.MustRegister(requestLatency) + legacyregistry.MustRegister(deprecatedRequestLatency) + legacyregistry.MustRegister(requestResult) + metrics.Register(&latencyAdapter{m: requestLatency, dm: deprecatedRequestLatency}, &resultAdapter{requestResult}) +} + +type latencyAdapter struct { + m *k8smetrics.HistogramVec + dm *k8smetrics.HistogramVec +} + +func (l *latencyAdapter) Observe(verb string, u url.URL, latency time.Duration) { + l.m.WithLabelValues(verb, u.String()).Observe(latency.Seconds()) + l.dm.WithLabelValues(verb, u.String()).Observe(latency.Seconds()) +} + +type resultAdapter struct { + m *k8smetrics.CounterVec +} + +func (r *resultAdapter) Increment(code, method, host string) { + r.m.WithLabelValues(code, method, host).Inc() +} diff --git a/staging/src/k8s.io/component-base/metrics/prometheus/workqueue/BUILD b/staging/src/k8s.io/component-base/metrics/prometheus/workqueue/BUILD new file mode 100644 index 00000000000..9b32cc0661e --- /dev/null +++ b/staging/src/k8s.io/component-base/metrics/prometheus/workqueue/BUILD @@ -0,0 +1,29 @@ +load("@io_bazel_rules_go//go:def.bzl", "go_library") + +go_library( + name = "go_default_library", + srcs = ["metrics.go"], + importmap = "k8s.io/kubernetes/vendor/k8s.io/component-base/metrics/prometheus/workqueue", + importpath = "k8s.io/component-base/metrics/prometheus/workqueue", + visibility = ["//visibility:public"], + deps = [ + "//staging/src/k8s.io/client-go/util/workqueue:go_default_library", + "//staging/src/k8s.io/component-base/metrics:go_default_library", + "//staging/src/k8s.io/component-base/metrics/legacyregistry:go_default_library", + "//vendor/github.com/prometheus/client_golang/prometheus:go_default_library", + ], +) + +filegroup( + name = "package-srcs", + srcs = glob(["**"]), + tags = ["automanaged"], + visibility = ["//visibility:private"], +) + +filegroup( + name = "all-srcs", + srcs = [":package-srcs"], + tags = ["automanaged"], + visibility = ["//visibility:public"], +) diff --git a/staging/src/k8s.io/component-base/metrics/prometheus/workqueue/metrics.go b/staging/src/k8s.io/component-base/metrics/prometheus/workqueue/metrics.go new file mode 100644 index 00000000000..bd9e6d11f05 --- /dev/null +++ b/staging/src/k8s.io/component-base/metrics/prometheus/workqueue/metrics.go @@ -0,0 +1,132 @@ +/* +Copyright 2019 The Kubernetes Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package workqueue + +import ( + "github.com/prometheus/client_golang/prometheus" + + "k8s.io/client-go/util/workqueue" + k8smetrics "k8s.io/component-base/metrics" + "k8s.io/component-base/metrics/legacyregistry" +) + +// Package prometheus sets the workqueue DefaultMetricsFactory to produce +// prometheus metrics. To use this package, you just have to import it. + +// Metrics subsystem and keys used by the workqueue. +const ( + WorkQueueSubsystem = "workqueue" + DepthKey = "depth" + AddsKey = "adds_total" + QueueLatencyKey = "queue_duration_seconds" + WorkDurationKey = "work_duration_seconds" + UnfinishedWorkKey = "unfinished_work_seconds" + LongestRunningProcessorKey = "longest_running_processor_seconds" + RetriesKey = "retries_total" +) + +var ( + depth = k8smetrics.NewGaugeVec(&k8smetrics.GaugeOpts{ + Subsystem: WorkQueueSubsystem, + Name: DepthKey, + Help: "Current depth of workqueue", + }, []string{"name"}) + + adds = k8smetrics.NewCounterVec(&k8smetrics.CounterOpts{ + Subsystem: WorkQueueSubsystem, + Name: AddsKey, + Help: "Total number of adds handled by workqueue", + }, []string{"name"}) + + latency = k8smetrics.NewHistogramVec(&k8smetrics.HistogramOpts{ + Subsystem: WorkQueueSubsystem, + Name: QueueLatencyKey, + Help: "How long in seconds an item stays in workqueue before being requested.", + Buckets: prometheus.ExponentialBuckets(10e-9, 10, 10), + }, []string{"name"}) + + workDuration = k8smetrics.NewHistogramVec(&k8smetrics.HistogramOpts{ + Subsystem: WorkQueueSubsystem, + Name: WorkDurationKey, + Help: "How long in seconds processing an item from workqueue takes.", + Buckets: prometheus.ExponentialBuckets(10e-9, 10, 10), + }, []string{"name"}) + + unfinished = k8smetrics.NewGaugeVec(&k8smetrics.GaugeOpts{ + Subsystem: WorkQueueSubsystem, + Name: UnfinishedWorkKey, + Help: "How many seconds of work has done that " + + "is in progress and hasn't been observed by work_duration. Large " + + "values indicate stuck threads. One can deduce the number of stuck " + + "threads by observing the rate at which this increases.", + }, []string{"name"}) + + longestRunningProcessor = k8smetrics.NewGaugeVec(&k8smetrics.GaugeOpts{ + Subsystem: WorkQueueSubsystem, + Name: LongestRunningProcessorKey, + Help: "How many seconds has the longest running " + + "processor for workqueue been running.", + }, []string{"name"}) + + retries = k8smetrics.NewCounterVec(&k8smetrics.CounterOpts{ + Subsystem: WorkQueueSubsystem, + Name: RetriesKey, + Help: "Total number of retries handled by workqueue", + }, []string{"name"}) + + metrics = []k8smetrics.Registerable{ + depth, adds, latency, workDuration, unfinished, longestRunningProcessor, retries, + } +) + +type prometheusMetricsProvider struct { +} + +func init() { + for _, m := range metrics { + legacyregistry.MustRegister(m) + } + workqueue.SetProvider(prometheusMetricsProvider{}) +} + +func (prometheusMetricsProvider) NewDepthMetric(name string) workqueue.GaugeMetric { + return depth.WithLabelValues(name) +} + +func (prometheusMetricsProvider) NewAddsMetric(name string) workqueue.CounterMetric { + return adds.WithLabelValues(name) +} + +func (prometheusMetricsProvider) NewLatencyMetric(name string) workqueue.HistogramMetric { + return latency.WithLabelValues(name) +} + +func (prometheusMetricsProvider) NewWorkDurationMetric(name string) workqueue.HistogramMetric { + return workDuration.WithLabelValues(name) +} + +func (prometheusMetricsProvider) NewUnfinishedWorkSecondsMetric(name string) workqueue.SettableGaugeMetric { + return unfinished.WithLabelValues(name) +} + +func (prometheusMetricsProvider) NewLongestRunningProcessorSecondsMetric(name string) workqueue.SettableGaugeMetric { + return longestRunningProcessor.WithLabelValues(name) +} + +func (prometheusMetricsProvider) NewRetriesMetric(name string) workqueue.CounterMetric { + return retries.WithLabelValues(name) +} diff --git a/staging/src/k8s.io/component-base/metrics/registry_test.go b/staging/src/k8s.io/component-base/metrics/registry_test.go new file mode 100644 index 00000000000..1b7ea08f605 --- /dev/null +++ b/staging/src/k8s.io/component-base/metrics/registry_test.go @@ -0,0 +1,237 @@ +/* +Copyright 2019 The Kubernetes Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package metrics + +import ( + "testing" + + "github.com/blang/semver" + "github.com/prometheus/client_golang/prometheus" + "github.com/stretchr/testify/assert" + apimachineryversion "k8s.io/apimachinery/pkg/version" +) + +var ( + v115 = semver.MustParse("1.15.0") + v114 = semver.MustParse("1.14.0") + alphaCounter = NewCounter( + &CounterOpts{ + Namespace: "some_namespace", + Name: "test_counter_name", + Subsystem: "subsystem", + StabilityLevel: ALPHA, + Help: "counter help", + }, + ) + alphaDeprecatedCounter = NewCounter( + &CounterOpts{ + Namespace: "some_namespace", + Name: "test_alpha_dep_counter", + Subsystem: "subsystem", + StabilityLevel: ALPHA, + Help: "counter help", + DeprecatedVersion: "1.15.0", + }, + ) + alphaHiddenCounter = NewCounter( + &CounterOpts{ + Namespace: "some_namespace", + Name: "test_alpha_hidden_counter", + Subsystem: "subsystem", + StabilityLevel: ALPHA, + Help: "counter help", + DeprecatedVersion: "1.14.0", + }, + ) +) + +func TestRegister(t *testing.T) { + var tests = []struct { + desc string + metrics []*Counter + registryVersion *semver.Version + expectedErrors []error + expectedIsCreatedValues []bool + expectedIsDeprecated []bool + expectedIsHidden []bool + }{ + { + desc: "test alpha metric", + metrics: []*Counter{alphaCounter}, + registryVersion: &v115, + expectedErrors: []error{nil}, + expectedIsCreatedValues: []bool{true}, + expectedIsDeprecated: []bool{false}, + expectedIsHidden: []bool{false}, + }, + { + desc: "test registering same metric multiple times", + metrics: []*Counter{alphaCounter, alphaCounter}, + registryVersion: &v115, + expectedErrors: []error{nil, prometheus.AlreadyRegisteredError{}}, + expectedIsCreatedValues: []bool{true, true}, + expectedIsDeprecated: []bool{false, false}, + expectedIsHidden: []bool{false, false}, + }, + { + desc: "test alpha deprecated metric", + metrics: []*Counter{alphaDeprecatedCounter}, + registryVersion: &v115, + expectedErrors: []error{nil}, + expectedIsCreatedValues: []bool{true}, + expectedIsDeprecated: []bool{true}, + expectedIsHidden: []bool{false}, + }, + { + desc: "test alpha hidden metric", + metrics: []*Counter{alphaHiddenCounter}, + registryVersion: &v115, + expectedErrors: []error{nil}, + expectedIsCreatedValues: []bool{false}, + expectedIsDeprecated: []bool{true}, + expectedIsHidden: []bool{true}, + }, + } + + for _, test := range tests { + t.Run(test.desc, func(t *testing.T) { + registry := newKubeRegistry(apimachineryversion.Info{ + Major: "1", + Minor: "15", + GitVersion: "v1.15.0-alpha-1.12345", + }) + for i, m := range test.metrics { + err := registry.Register(m) + if err != test.expectedErrors[i] && err.Error() != test.expectedErrors[i].Error() { + t.Errorf("Got unexpected error %v, wanted %v", err, test.expectedErrors[i]) + } + if m.IsCreated() != test.expectedIsCreatedValues[i] { + t.Errorf("Got isCreated == %v, wanted isCreated to be %v", m.IsCreated(), test.expectedIsCreatedValues[i]) + } + if m.IsDeprecated() != test.expectedIsDeprecated[i] { + t.Errorf("Got IsDeprecated == %v, wanted IsDeprecated to be %v", m.IsDeprecated(), test.expectedIsDeprecated[i]) + } + if m.IsHidden() != test.expectedIsHidden[i] { + t.Errorf("Got IsHidden == %v, wanted IsHidden to be %v", m.IsHidden(), test.expectedIsDeprecated[i]) + } + } + }) + } +} + +func TestMustRegister(t *testing.T) { + var tests = []struct { + desc string + metrics []*Counter + registryVersion *semver.Version + expectedPanics []bool + }{ + { + desc: "test alpha metric", + metrics: []*Counter{alphaCounter}, + registryVersion: &v115, + expectedPanics: []bool{false}, + }, + { + desc: "test registering same metric multiple times", + metrics: []*Counter{alphaCounter, alphaCounter}, + registryVersion: &v115, + expectedPanics: []bool{false, true}, + }, + { + desc: "test alpha deprecated metric", + metrics: []*Counter{alphaDeprecatedCounter}, + registryVersion: &v115, + expectedPanics: []bool{false}, + }, + { + desc: "test must registering same deprecated metric", + metrics: []*Counter{alphaDeprecatedCounter, alphaDeprecatedCounter}, + registryVersion: &v115, + expectedPanics: []bool{false, true}, + }, + { + desc: "test alpha hidden metric", + metrics: []*Counter{alphaHiddenCounter}, + registryVersion: &v115, + expectedPanics: []bool{false}, + }, + { + desc: "test must registering same hidden metric", + metrics: []*Counter{alphaHiddenCounter, alphaHiddenCounter}, + registryVersion: &v115, + expectedPanics: []bool{false, false}, // hidden metrics no-opt + }, + } + + for _, test := range tests { + t.Run(test.desc, func(t *testing.T) { + registry := newKubeRegistry(apimachineryversion.Info{ + Major: "1", + Minor: "15", + GitVersion: "v1.15.0-alpha-1.12345", + }) + for i, m := range test.metrics { + if test.expectedPanics[i] { + assert.Panics(t, + func() { registry.MustRegister(m) }, + "Did not panic even though we expected it.") + } else { + registry.MustRegister(m) + } + } + }) + } + +} +func TestShowHiddenMetric(t *testing.T) { + registry := newKubeRegistry(apimachineryversion.Info{ + Major: "1", + Minor: "15", + GitVersion: "v1.15.0-alpha-1.12345", + }) + + expectedMetricCount := 0 + registry.MustRegister(alphaHiddenCounter) + + ms, err := registry.Gather() + if len(ms) != expectedMetricCount { + t.Errorf("Got %v metrics, Want: %v metrics", len(ms), expectedMetricCount) + } + showHidden.Store(true) + defer showHidden.Store(false) + registry.MustRegister(NewCounter( + &CounterOpts{ + Namespace: "some_namespace", + Name: "test_alpha_show_hidden_counter", + Subsystem: "subsystem", + StabilityLevel: ALPHA, + Help: "counter help", + DeprecatedVersion: "1.14.0", + }, + )) + expectedMetricCount = 1 + + ms, err = registry.Gather() + if len(ms) != expectedMetricCount { + t.Errorf("Got %v metrics, Want: %v metrics", len(ms), expectedMetricCount) + } + if err != nil { + t.Fatalf("Gather failed %v", err) + } + +} diff --git a/staging/src/k8s.io/component-base/metrics/summary_test.go b/staging/src/k8s.io/component-base/metrics/summary_test.go new file mode 100644 index 00000000000..2facd2e446d --- /dev/null +++ b/staging/src/k8s.io/component-base/metrics/summary_test.go @@ -0,0 +1,218 @@ +/* +Copyright 2019 The Kubernetes Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package metrics + +import ( + "github.com/blang/semver" + apimachineryversion "k8s.io/apimachinery/pkg/version" + "testing" +) + +func TestSummary(t *testing.T) { + v115 := semver.MustParse("1.15.0") + var tests = []struct { + desc string + SummaryOpts + registryVersion *semver.Version + expectedMetricCount int + expectedHelp string + }{ + { + desc: "Test non deprecated", + SummaryOpts: SummaryOpts{ + Namespace: "namespace", + Name: "metric_test_name", + Subsystem: "subsystem", + Help: "summary help message", + StabilityLevel: ALPHA, + }, + registryVersion: &v115, + expectedMetricCount: 1, + expectedHelp: "[ALPHA] summary help message", + }, + { + desc: "Test deprecated", + SummaryOpts: SummaryOpts{ + Namespace: "namespace", + Name: "metric_test_name", + Subsystem: "subsystem", + Help: "summary help message", + DeprecatedVersion: "1.15.0", + StabilityLevel: ALPHA, + }, + registryVersion: &v115, + expectedMetricCount: 1, + expectedHelp: "[ALPHA] (Deprecated since 1.15.0) summary help message", + }, + { + desc: "Test hidden", + SummaryOpts: SummaryOpts{ + Namespace: "namespace", + Name: "metric_test_name", + Subsystem: "subsystem", + Help: "summary help message", + DeprecatedVersion: "1.14.0", + }, + registryVersion: &v115, + expectedMetricCount: 0, + expectedHelp: "summary help message", + }, + } + + for _, test := range tests { + t.Run(test.desc, func(t *testing.T) { + registry := newKubeRegistry(apimachineryversion.Info{ + Major: "1", + Minor: "15", + GitVersion: "v1.15.0-alpha-1.12345", + }) + c := NewSummary(&test.SummaryOpts) + registry.MustRegister(c) + + ms, err := registry.Gather() + if len(ms) != test.expectedMetricCount { + t.Errorf("Got %v metrics, Want: %v metrics", len(ms), test.expectedMetricCount) + } + if err != nil { + t.Fatalf("Gather failed %v", err) + } + for _, metric := range ms { + if metric.GetHelp() != test.expectedHelp { + t.Errorf("Got %s as help message, want %s", metric.GetHelp(), test.expectedHelp) + } + } + + // let's increment the counter and verify that the metric still works + c.Observe(1) + c.Observe(2) + c.Observe(3) + c.Observe(1.5) + expected := 4 + ms, err = registry.Gather() + if err != nil { + t.Fatalf("Gather failed %v", err) + } + for _, mf := range ms { + for _, m := range mf.GetMetric() { + if int(m.GetSummary().GetSampleCount()) != expected { + t.Errorf("Got %v, want %v as the sample count", m.GetHistogram().GetSampleCount(), expected) + } + } + } + }) + } +} + +func TestSummaryVec(t *testing.T) { + v115 := semver.MustParse("1.15.0") + var tests = []struct { + desc string + SummaryOpts + labels []string + registryVersion *semver.Version + expectedMetricCount int + expectedHelp string + }{ + { + desc: "Test non deprecated", + SummaryOpts: SummaryOpts{ + Namespace: "namespace", + Name: "metric_test_name", + Subsystem: "subsystem", + Help: "summary help message", + }, + labels: []string{"label_a", "label_b"}, + registryVersion: &v115, + expectedMetricCount: 1, + expectedHelp: "[ALPHA] summary help message", + }, + { + desc: "Test deprecated", + SummaryOpts: SummaryOpts{ + Namespace: "namespace", + Name: "metric_test_name", + Subsystem: "subsystem", + Help: "summary help message", + DeprecatedVersion: "1.15.0", + }, + labels: []string{"label_a", "label_b"}, + registryVersion: &v115, + expectedMetricCount: 1, + expectedHelp: "[ALPHA] (Deprecated since 1.15.0) summary help message", + }, + { + desc: "Test hidden", + SummaryOpts: SummaryOpts{ + Namespace: "namespace", + Name: "metric_test_name", + Subsystem: "subsystem", + Help: "summary help message", + DeprecatedVersion: "1.14.0", + }, + labels: []string{"label_a", "label_b"}, + registryVersion: &v115, + expectedMetricCount: 0, + expectedHelp: "summary help message", + }, + } + + for _, test := range tests { + t.Run(test.desc, func(t *testing.T) { + registry := newKubeRegistry(apimachineryversion.Info{ + Major: "1", + Minor: "15", + GitVersion: "v1.15.0-alpha-1.12345", + }) + c := NewSummaryVec(&test.SummaryOpts, test.labels) + registry.MustRegister(c) + c.WithLabelValues("1", "2").Observe(1.0) + ms, err := registry.Gather() + + if len(ms) != test.expectedMetricCount { + t.Errorf("Got %v metrics, Want: %v metrics", len(ms), test.expectedMetricCount) + } + if err != nil { + t.Fatalf("Gather failed %v", err) + } + for _, metric := range ms { + if metric.GetHelp() != test.expectedHelp { + t.Errorf("Got %s as help message, want %s", metric.GetHelp(), test.expectedHelp) + } + } + + // let's increment the counter and verify that the metric still works + c.WithLabelValues("1", "3").Observe(1.0) + c.WithLabelValues("2", "3").Observe(1.0) + ms, err = registry.Gather() + if err != nil { + t.Fatalf("Gather failed %v", err) + } + for _, mf := range ms { + if len(mf.GetMetric()) != 3 { + t.Errorf("Got %v metrics, wanted 2 as the count", len(mf.GetMetric())) + } + for _, m := range mf.GetMetric() { + if m.GetSummary().GetSampleCount() != 1 { + t.Errorf( + "Got %v metrics, wanted 2 as the summary sample count", + m.GetSummary().GetSampleCount()) + } + } + } + }) + } +} diff --git a/staging/src/k8s.io/cri-api/go.sum b/staging/src/k8s.io/cri-api/go.sum index 95c702bd33a..76632f6f1c4 100644 --- a/staging/src/k8s.io/cri-api/go.sum +++ b/staging/src/k8s.io/cri-api/go.sum @@ -17,6 +17,7 @@ github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5y github.com/golang/protobuf v1.3.2 h1:6nsPYzhq5kReh6QImI3k5qWzO4PEbvbIW2cwSfR/6xs= github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M= +github.com/google/go-cmp v0.3.0 h1:crn/baboCvb5fXaQ0IJ1SGTsTVrWpDsCWC8EGETZijY= github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= github.com/kisielk/errcheck v1.2.0/go.mod h1:/BMXB+zMLi60iA8Vv6Ksmxu/1UDYcXs4uQLJ+jE2L00= github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= diff --git a/staging/src/k8s.io/csi-translation-lib/go.sum b/staging/src/k8s.io/csi-translation-lib/go.sum index 7d352bac6aa..b5504804def 100644 --- a/staging/src/k8s.io/csi-translation-lib/go.sum +++ b/staging/src/k8s.io/csi-translation-lib/go.sum @@ -90,6 +90,7 @@ gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.8 h1:obN1ZagJSUGI0Ek/LBmuj4SNLPfIny3KsKFopxRdj10= gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +k8s.io/klog v1.0.0 h1:Pt+yjF5aB1xDSVbau4VsWe+dQNzA0qv1LlXdC2dF6Q8= k8s.io/klog v1.0.0/go.mod h1:4Bi6QPql/J/LkTDqv7R/cd3hPo4k2DG6Ptcz060Ez5I= k8s.io/kube-openapi v0.0.0-20190228160746-b3a7cee44a30/go.mod h1:BXM9ceUBTj2QnfH2MK1odQs778ajze1RxcmP6S8RVVc= k8s.io/utils v0.0.0-20190221042446-c2654d5206da/go.mod h1:8k8uAuAQ0rXslZKaEWd0c3oVhZz7sSzSiPnVZayjIX0= diff --git a/staging/src/k8s.io/kube-aggregator/go.mod b/staging/src/k8s.io/kube-aggregator/go.mod index 4e4471c9111..a3e16734153 100644 --- a/staging/src/k8s.io/kube-aggregator/go.mod +++ b/staging/src/k8s.io/kube-aggregator/go.mod @@ -10,7 +10,6 @@ require ( github.com/ghodss/yaml v0.0.0-20180820084758-c7ce16629ff4 // indirect github.com/go-openapi/spec v0.19.3 github.com/gogo/protobuf v1.3.1 - github.com/prometheus/client_golang v1.1.0 github.com/spf13/cobra v0.0.5 github.com/spf13/pflag v1.0.5 github.com/stretchr/testify v1.4.0 @@ -35,7 +34,6 @@ replace ( github.com/google/gofuzz => github.com/google/gofuzz v0.0.0-20170612174753-24818f796faf github.com/googleapis/gnostic => github.com/googleapis/gnostic v0.0.0-20170729233727-0c5108395e2d github.com/grpc-ecosystem/go-grpc-middleware => github.com/grpc-ecosystem/go-grpc-middleware v0.0.0-20190222133341-cfaf5686ec79 - github.com/grpc-ecosystem/go-grpc-prometheus => github.com/grpc-ecosystem/go-grpc-prometheus v0.0.0-20170330212424-2500245aa611 github.com/grpc-ecosystem/grpc-gateway => github.com/grpc-ecosystem/grpc-gateway v1.3.0 github.com/hashicorp/golang-lru => github.com/hashicorp/golang-lru v0.5.0 github.com/jonboulle/clockwork => github.com/jonboulle/clockwork v0.0.0-20141017032234-72f9bd7c4e0c diff --git a/staging/src/k8s.io/kube-aggregator/go.sum b/staging/src/k8s.io/kube-aggregator/go.sum index 30219ea825d..8ccb48eefd2 100644 --- a/staging/src/k8s.io/kube-aggregator/go.sum +++ b/staging/src/k8s.io/kube-aggregator/go.sum @@ -23,11 +23,13 @@ github.com/bgentry/speakeasy v0.1.0/go.mod h1:+zsyZBPWlz7T6j88CTgSN5bM796AkVf0kB github.com/blang/semver v3.5.0+incompatible/go.mod h1:kRBLl5iJ+tD4TcOOxsy/0fnwebNt5EWlYSAyrTnjyyk= github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= +github.com/cockroachdb/datadriven v0.0.0-20190809214429-80d97fb3cbaa h1:OaNxuTZr7kxeODyLWsRMC+OD03aFUH+mW6r2d+MWa5Y= github.com/cockroachdb/datadriven v0.0.0-20190809214429-80d97fb3cbaa/go.mod h1:zn76sxSg3SzpJ0PPJaLDCu+Bu0Lg3sKTORVIj19EIF8= github.com/coreos/etcd v3.3.10+incompatible/go.mod h1:uF7uidLiAD3TWHmW31ZFd/JWoc32PjwdhPthX9715RE= github.com/coreos/go-etcd v2.0.0+incompatible/go.mod h1:Jez6KQU2B/sWsbdaef3ED8NzMklzPG4d5KIOhIy30Tk= github.com/coreos/go-oidc v0.0.0-20180117170138-065b426bd416/go.mod h1:CgnwVTmzoESiwO9qyAFEMiHoZ1nMCKZlZ9V6mm3/LKc= github.com/coreos/go-semver v0.2.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk= +github.com/coreos/go-semver v0.3.0 h1:wkHLiw0WNATZnSG7epLsujiMCgPAc9xhjJ4tgnAxmfM= github.com/coreos/go-semver v0.3.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk= github.com/coreos/go-systemd v0.0.0-20180511133405-39ca1b05acc7 h1:u9SHYsPQNyt5tgDm3YN7+9dYrpK96E5wFilTFWIDZOM= github.com/coreos/go-systemd v0.0.0-20180511133405-39ca1b05acc7/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4= @@ -47,6 +49,7 @@ github.com/docker/docker v0.7.3-0.20190327010347-be7ac8be2ae0/go.mod h1:eEKB0N0r github.com/docker/spdystream v0.0.0-20160310174837-449fdfce4d96 h1:cenwrSVm+Z7QLSV/BsnenAOcDXdX4cMv4wP0B/5QbPg= github.com/docker/spdystream v0.0.0-20160310174837-449fdfce4d96/go.mod h1:Qh8CwZgvJUkLughtfhJv5dyTYa91l1fOUCrgjqmcifM= github.com/dustin/go-humanize v0.0.0-20171111073723-bb3d318650d4/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk= +github.com/dustin/go-humanize v1.0.0 h1:VSnTsYCnlFHaM2/igO1h6X3HA71jcobQuxemgkq4zYo= github.com/dustin/go-humanize v1.0.0/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk= github.com/elazarl/goproxy v0.0.0-20180725130230-947c36da3153 h1:yUdfgN0XgIJw7foRItutHYUIhlcKzcSf5vDpdhQAKTc= github.com/elazarl/goproxy v0.0.0-20180725130230-947c36da3153/go.mod h1:/Zj4wYkgs4iZTTu3o/KG3Itv/qCCa8VVMlb3i9OVuzc= @@ -86,6 +89,7 @@ github.com/golang/protobuf v1.2.0 h1:P3YflyNX/ehuJFLhxviNdFxQPkGK5cDcApsge1SqnvM github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/golang/protobuf v1.3.2 h1:6nsPYzhq5kReh6QImI3k5qWzO4PEbvbIW2cwSfR/6xs= github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= +github.com/google/btree v1.0.0 h1:0udJVsspx3VBr5FwtLhQQtuAsVc79tTq0ocGIPAU6qo= github.com/google/btree v1.0.0/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M= github.com/google/go-cmp v0.3.0 h1:crn/baboCvb5fXaQ0IJ1SGTsTVrWpDsCWC8EGETZijY= @@ -103,12 +107,13 @@ github.com/gorilla/websocket v0.0.0-20170926233335-4201258b820c h1:Lh2aW+HnU2Nbe github.com/gorilla/websocket v0.0.0-20170926233335-4201258b820c/go.mod h1:E7qHFY5m1UJ88s3WnNqhKjPHQ0heANvMoAMk2YaljkQ= github.com/gorilla/websocket v1.4.0 h1:WDFjx/TMzVgy9VdMMQi2K2Emtwi2QcUQsztZ/zLaH/Q= github.com/gorilla/websocket v1.4.0/go.mod h1:E7qHFY5m1UJ88s3WnNqhKjPHQ0heANvMoAMk2YaljkQ= +github.com/grafov/bcast v0.0.0-20190217190352-1447f067e08d h1:Q2+KsA/1GLC9xyLsDun3/EOJ+83rY/IHRsO1DToPrdo= github.com/grafov/bcast v0.0.0-20190217190352-1447f067e08d/go.mod h1:RInr+B3/Tx70hYm0rpNPMTD7vH0pBG5ny/JsHAs2KcQ= github.com/gregjones/httpcache v0.0.0-20180305231024-9cad4c3443a7/go.mod h1:FecbI9+v66THATjSRHfNgh1IVFe/9kFxbXtjV0ctIMA= github.com/grpc-ecosystem/go-grpc-middleware v0.0.0-20190222133341-cfaf5686ec79 h1:lR9ssWAqp9qL0bALxqEEkuudiP1eweOdv9jsRK3e7lE= github.com/grpc-ecosystem/go-grpc-middleware v0.0.0-20190222133341-cfaf5686ec79/go.mod h1:FiyG127CGDf3tlThmgyCl78X/SZQqEOJBCDaAfeWzPs= -github.com/grpc-ecosystem/go-grpc-prometheus v0.0.0-20170330212424-2500245aa611 h1:f5vL2EW5pL274ztMNnizZAEa457nKyKPEaN/sm/kdBk= -github.com/grpc-ecosystem/go-grpc-prometheus v0.0.0-20170330212424-2500245aa611/go.mod h1:8NvIoxWQoOIhqOTXgfV/d3M/q6VIi02HzZEHgUlZvzk= +github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0 h1:Ovs26xHkKqVztRpIrF/92BcuyuQ/YW4NSIpoGtfXNho= +github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0/go.mod h1:8NvIoxWQoOIhqOTXgfV/d3M/q6VIi02HzZEHgUlZvzk= github.com/grpc-ecosystem/grpc-gateway v1.3.0 h1:HJtP6RRwj2EpPCD/mhAWzSvLL/dFTdPm1UrWwanoFos= github.com/grpc-ecosystem/grpc-gateway v1.3.0/go.mod h1:RSKVYQBd5MCa4OVpNdGskqpgL2+G+NZTnrVHpWWfpdw= github.com/hashicorp/golang-lru v0.5.0 h1:CL2msUPvZTLb5O648aiLNJw3hnBxN2+1Jq8rCOH9wdo= @@ -215,7 +220,9 @@ github.com/urfave/cli v1.20.0/go.mod h1:70zkFmudgCuE/ngEzBv17Jvp/497gISqfk5gWijb github.com/xiang90/probing v0.0.0-20160813154853-07dd2e8dfe18 h1:MPPkRncZLN9Kh4MEFmbnK4h3BD7AUmskWv2+EeZJCCs= github.com/xiang90/probing v0.0.0-20160813154853-07dd2e8dfe18/go.mod h1:UETIi67q53MR2AWcXfiuqkDkRtnGDLqkBTpCHuJHxtU= github.com/xordataexchange/crypt v0.0.3-0.20170626215501-b2862e3d0a77/go.mod h1:aYKd//L2LvnjZzWKhF00oedf4jCCReLcmhLdhm1A27Q= +go.etcd.io/bbolt v1.3.3 h1:MUGmc65QhB3pIlaQ5bB4LwqSj6GIonVJXpZiaKNyaKk= go.etcd.io/bbolt v1.3.3/go.mod h1:IbVyRI1SCnLcuJnV2u8VeU0CEYM7e686BmAb1XKL+uU= +go.etcd.io/etcd v0.5.0-alpha.5.0.20200224211402-c65a9e2dd1fd h1:JwlSZ9TSTcRHDGbIr5QG3MEmKyMK99BbNLMJtwnJ0rY= go.etcd.io/etcd v0.5.0-alpha.5.0.20200224211402-c65a9e2dd1fd/go.mod h1:dnLIgRNXwCJa5e+c6mIZCrds/GIG4ncV9HhK5PX7jPg= go.uber.org/atomic v0.0.0-20181018215023-8dc6146f7569 h1:nSQar3Y0E3VQF/VdZ8PTAilaXpER+d7ypdABCrpwMdg= go.uber.org/atomic v0.0.0-20181018215023-8dc6146f7569/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE= @@ -296,6 +303,7 @@ google.golang.org/grpc v1.26.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8 gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 h1:qIbj1fsPNlZgppZ+VLlY7N33q108Sa+fhmuc+sWQYwY= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/cheggaaa/pb.v1 v1.0.25/go.mod h1:V/YB90LKu/1FcN3WVnfiiE5oMCibMjukxqG/qStrOgw= +gopkg.in/fatih/set.v0 v0.2.1 h1:Xvyyp7LXu34P0ROhCyfXkmQCAoOUKb1E2JS9I7SE5CY= gopkg.in/fatih/set.v0 v0.2.1/go.mod h1:5eLWEndGL4zGGemXWrKuts+wTJR0y+w+auqUJZbmyBg= gopkg.in/fsnotify.v1 v1.4.7 h1:xOHLXZwVvI9hhs+cLKq5+I5onOuwQLhQwiu63xxlHs4= gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys= @@ -317,6 +325,7 @@ honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWh honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= k8s.io/gengo v0.0.0-20200205140755-e0e292d8aa12 h1:pZzawYyz6VRNPVYpqGv61LWCimQv1BihyeqFrp50/G4= k8s.io/gengo v0.0.0-20200205140755-e0e292d8aa12/go.mod h1:ezvh/TsK7cY6rbqRK0oQQ8IAqLxYwwyPxAX1Pzy0ii0= +k8s.io/klog v1.0.0 h1:Pt+yjF5aB1xDSVbau4VsWe+dQNzA0qv1LlXdC2dF6Q8= k8s.io/klog v1.0.0/go.mod h1:4Bi6QPql/J/LkTDqv7R/cd3hPo4k2DG6Ptcz060Ez5I= k8s.io/kube-openapi v0.0.0-20190228160746-b3a7cee44a30 h1:TRb4wNWoBVrH9plmkp2q86FIDppkbrEXdXlxU3a3BMI= k8s.io/kube-openapi v0.0.0-20190228160746-b3a7cee44a30/go.mod h1:BXM9ceUBTj2QnfH2MK1odQs778ajze1RxcmP6S8RVVc= @@ -327,7 +336,7 @@ modernc.org/golex v1.0.0/go.mod h1:b/QX9oBD/LhixY6NDh+IdGv17hgB+51fET1i2kPSmvk= modernc.org/mathutil v1.0.0/go.mod h1:wU0vUrJsVWBZ4P6e7xtFJEhFSNsfRLJ8H458uRjg03k= modernc.org/strutil v1.0.0/go.mod h1:lstksw84oURvj9y3tn8lGvRxyRC1S2+g5uuIzNfIOBs= modernc.org/xc v1.0.0/go.mod h1:mRNCo0bvLjGhHO9WsyuKVU4q0ceiDDDoEeWDJHrNx8I= -sigs.k8s.io/structured-merge-diff v0.0.0-20190302045857-e85c7b244fd2 h1:9r5DY45ef9LtcA6BnkhW8MPV7OKAfbf2AUwUhq3LeRk= -sigs.k8s.io/structured-merge-diff v0.0.0-20190302045857-e85c7b244fd2/go.mod h1:wWxsB5ozmmv/SG7nM11ayaAW51xMvak/t1r0CSlcokI= +sigs.k8s.io/structured-merge-diff v0.0.0-20190719182312-e94e05bfbbe3 h1:yCY9zAYErawYwXdOYmwEBzcGCr/6eIUujYZE2DIQve8= +sigs.k8s.io/structured-merge-diff v0.0.0-20190719182312-e94e05bfbbe3/go.mod h1:wWxsB5ozmmv/SG7nM11ayaAW51xMvak/t1r0CSlcokI= sigs.k8s.io/yaml v1.1.0 h1:4A07+ZFc2wgJwo8YNlQpr1rVlgUDlxXHhPJciaPY5gs= sigs.k8s.io/yaml v1.1.0/go.mod h1:UJmg0vDUVViEyp3mgSv9WPwZCDxu4rQW1olrI1uml+o= diff --git a/staging/src/k8s.io/kube-aggregator/pkg/controllers/status/BUILD b/staging/src/k8s.io/kube-aggregator/pkg/controllers/status/BUILD index cfa96422e16..80551d3c2aa 100644 --- a/staging/src/k8s.io/kube-aggregator/pkg/controllers/status/BUILD +++ b/staging/src/k8s.io/kube-aggregator/pkg/controllers/status/BUILD @@ -30,12 +30,13 @@ go_library( "//staging/src/k8s.io/client-go/tools/cache:go_default_library", "//staging/src/k8s.io/client-go/transport:go_default_library", "//staging/src/k8s.io/client-go/util/workqueue:go_default_library", + "//staging/src/k8s.io/component-base/metrics:go_default_library", + "//staging/src/k8s.io/component-base/metrics/legacyregistry:go_default_library", "//staging/src/k8s.io/kube-aggregator/pkg/apis/apiregistration:go_default_library", "//staging/src/k8s.io/kube-aggregator/pkg/client/clientset_generated/internalclientset/typed/apiregistration/internalversion:go_default_library", "//staging/src/k8s.io/kube-aggregator/pkg/client/informers/internalversion/apiregistration/internalversion:go_default_library", "//staging/src/k8s.io/kube-aggregator/pkg/client/listers/apiregistration/internalversion:go_default_library", "//staging/src/k8s.io/kube-aggregator/pkg/controllers:go_default_library", - "//vendor/github.com/prometheus/client_golang/prometheus:go_default_library", "//vendor/k8s.io/klog:go_default_library", ], ) diff --git a/staging/src/k8s.io/kube-aggregator/pkg/controllers/status/metrics.go b/staging/src/k8s.io/kube-aggregator/pkg/controllers/status/metrics.go index 539641ea93b..d6727af576f 100644 --- a/staging/src/k8s.io/kube-aggregator/pkg/controllers/status/metrics.go +++ b/staging/src/k8s.io/kube-aggregator/pkg/controllers/status/metrics.go @@ -17,27 +17,38 @@ limitations under the License. package apiserver import ( - "github.com/prometheus/client_golang/prometheus" + "k8s.io/component-base/metrics" + "k8s.io/component-base/metrics/legacyregistry" ) +/* + * By default, all the following metrics are defined as falling under + * ALPHA stability level https://github.com/kubernetes/enhancements/blob/master/keps/sig-instrumentation/20190404-kubernetes-control-plane-metrics-stability.md#stability-classes) + * + * Promoting the stability level of the metric is a responsibility of the component owner, since it + * involves explicitly acknowledging support for the metric across multiple releases, in accordance with + * the metric stability policy. + */ var ( - unavailableCounter = prometheus.NewCounterVec( - prometheus.CounterOpts{ - Name: "aggregator_unavailable_apiservice_count", - Help: "Counter of APIServices which are marked as unavailable broken down by APIService name and reason.", + unavailableCounter = metrics.NewCounterVec( + &metrics.CounterOpts{ + Name: "aggregator_unavailable_apiservice_count", + Help: "Counter of APIServices which are marked as unavailable broken down by APIService name and reason.", + StabilityLevel: metrics.ALPHA, }, []string{"name", "reason"}, ) - unavailableGauge = prometheus.NewGaugeVec( - prometheus.GaugeOpts{ - Name: "aggregator_unavailable_apiservice", - Help: "Gauge of APIServices which are marked as unavailable broken down by APIService name.", + unavailableGauge = metrics.NewGaugeVec( + &metrics.GaugeOpts{ + Name: "aggregator_unavailable_apiservice", + Help: "Gauge of APIServices which are marked as unavailable broken down by APIService name.", + StabilityLevel: metrics.ALPHA, }, []string{"name"}, ) ) func init() { - prometheus.MustRegister(unavailableCounter) - prometheus.MustRegister(unavailableGauge) + legacyregistry.MustRegister(unavailableCounter) + legacyregistry.MustRegister(unavailableGauge) } diff --git a/staging/src/k8s.io/kube-controller-manager/go.mod b/staging/src/k8s.io/kube-controller-manager/go.mod index 834718572dc..13817176b5d 100644 --- a/staging/src/k8s.io/kube-controller-manager/go.mod +++ b/staging/src/k8s.io/kube-controller-manager/go.mod @@ -10,16 +10,21 @@ require ( ) replace ( + cloud.google.com/go => cloud.google.com/go v0.34.0 + github.com/dgrijalva/jwt-go => github.com/dgrijalva/jwt-go v0.0.0-20160705203006-01aeca54ebda github.com/google/gofuzz => github.com/google/gofuzz v0.0.0-20170612174753-24818f796faf github.com/googleapis/gnostic => github.com/googleapis/gnostic v0.0.0-20170729233727-0c5108395e2d github.com/hashicorp/golang-lru => github.com/hashicorp/golang-lru v0.5.0 github.com/json-iterator/go => github.com/json-iterator/go v0.0.0-20180701071628-ab8a2e0c74be github.com/prometheus/client_golang => github.com/prometheus/client_golang v0.9.2 github.com/prometheus/common => github.com/prometheus/common v0.0.0-20181126121408-4724e9255275 + golang.org/x/sync => golang.org/x/sync v0.0.0-20181108010431-42b317875d0f golang.org/x/sys => golang.org/x/sys v0.0.0-20200622214017-ed371f2e16b4 golang.org/x/text => golang.org/x/text v0.3.1-0.20181227161524-e6919f6577db gopkg.in/check.v1 => gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 + k8s.io/api => ../api k8s.io/apimachinery => ../apimachinery + k8s.io/client-go => ../client-go k8s.io/component-base => ../component-base k8s.io/kube-controller-manager => ../kube-controller-manager k8s.io/kube-openapi => k8s.io/kube-openapi v0.0.0-20190228160746-b3a7cee44a30 diff --git a/staging/src/k8s.io/kube-controller-manager/go.sum b/staging/src/k8s.io/kube-controller-manager/go.sum index 271c2d94de0..0471cadc776 100644 --- a/staging/src/k8s.io/kube-controller-manager/go.sum +++ b/staging/src/k8s.io/kube-controller-manager/go.sum @@ -1,8 +1,17 @@ +cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= +github.com/Azure/go-autorest/autorest v0.9.0/go.mod h1:xyHB1BMZT0cuDHU7I0+g046+BFDTQ8rEZB0s4Yfa6bI= +github.com/Azure/go-autorest/autorest/adal v0.5.0/go.mod h1:8Z9fGy2MpX0PvDjB1pEgQTmVqjGhiHBW7RJJEciWzS0= +github.com/Azure/go-autorest/autorest/date v0.1.0/go.mod h1:plvfp3oPSKwf2DNjlBjWF/7vwR+cUD/ELuzDCXwHUVA= +github.com/Azure/go-autorest/autorest/mocks v0.1.0/go.mod h1:OTyCOPRA2IgIlWxVYxBee2F5Gr4kF2zd2J5cFRaIDN0= +github.com/Azure/go-autorest/autorest/mocks v0.2.0/go.mod h1:OTyCOPRA2IgIlWxVYxBee2F5Gr4kF2zd2J5cFRaIDN0= +github.com/Azure/go-autorest/logger v0.1.0/go.mod h1:oExouG+K6PryycPJfVSxi/koC6LSNgds39diKLz7Vrc= +github.com/Azure/go-autorest/tracing v0.5.0/go.mod h1:r/s2XiOKccPW3HrqB+W0TQzfbtp2fGCgRFtBroKn4Dk= github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q= github.com/blang/semver v3.5.0+incompatible/go.mod h1:kRBLl5iJ+tD4TcOOxsy/0fnwebNt5EWlYSAyrTnjyyk= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/dgrijalva/jwt-go v0.0.0-20160705203006-01aeca54ebda/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ= github.com/docker/spdystream v0.0.0-20160310174837-449fdfce4d96/go.mod h1:Qh8CwZgvJUkLughtfhJv5dyTYa91l1fOUCrgjqmcifM= github.com/elazarl/goproxy v0.0.0-20180725130230-947c36da3153/go.mod h1:/Zj4wYkgs4iZTTu3o/KG3Itv/qCCa8VVMlb3i9OVuzc= github.com/evanphx/json-patch v4.9.0+incompatible/go.mod h1:50XU6AFN0ol/bzJsmQLiYLvXMP4fmwYFNcr97nuDLSk= @@ -13,14 +22,19 @@ github.com/gogo/protobuf v1.3.1/go.mod h1:SlYgWuQ5SjCEi6WLHjHCa1yvBfUnHcTbrrZtXP github.com/golang/groupcache v0.0.0-20160516000752-02826c3e7903/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= +github.com/google/btree v1.0.0/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= github.com/google/go-cmp v0.3.0 h1:crn/baboCvb5fXaQ0IJ1SGTsTVrWpDsCWC8EGETZijY= github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= github.com/google/gofuzz v0.0.0-20170612174753-24818f796faf h1:+RRA9JqSOZFfKrOeqr2z77+8R2RKyh8PG66dcu1V0ck= github.com/google/gofuzz v0.0.0-20170612174753-24818f796faf/go.mod h1:HP5RmnzzSNb993RKQDq4+1A4ia9nllfqcQFTQJedwGI= github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/googleapis/gnostic v0.0.0-20170729233727-0c5108395e2d/go.mod h1:sJBsCZ4ayReDTBIg8b9dl28c5xFWyhBTVRp3pOg5EKY= +github.com/gophercloud/gophercloud v0.6.0/go.mod h1:GICNByuaEBibcjmjvI7QvYJSZEbGkcYwAR7EZK2WMqM= +github.com/grafov/bcast v0.0.0-20190217190352-1447f067e08d/go.mod h1:RInr+B3/Tx70hYm0rpNPMTD7vH0pBG5ny/JsHAs2KcQ= +github.com/gregjones/httpcache v0.0.0-20180305231024-9cad4c3443a7/go.mod h1:FecbI9+v66THATjSRHfNgh1IVFe/9kFxbXtjV0ctIMA= github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU= +github.com/imdario/mergo v0.3.5/go.mod h1:2EnlNZ0deacrJVfApfmtdGgDfMuh/nq6Ok1EcJh5FfA= github.com/json-iterator/go v0.0.0-20180701071628-ab8a2e0c74be h1:AHimNtVIpiBjPUhEF5KNCkrUyqTSA5zWUl8sQ2bfGBE= github.com/json-iterator/go v0.0.0-20180701071628-ab8a2e0c74be/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU= github.com/kisielk/errcheck v1.2.0/go.mod h1:/BMXB+zMLi60iA8Vv6Ksmxu/1UDYcXs4uQLJ+jE2L00= @@ -39,6 +53,7 @@ github.com/mxk/go-flowrate v0.0.0-20140419014527-cca7078d478f/go.mod h1:ZdcZmHo+ github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= github.com/onsi/ginkgo v1.11.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= github.com/onsi/gomega v1.7.0/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY= +github.com/peterbourgon/diskv v2.0.1+incompatible/go.mod h1:uqqh8zWWbv1HBMNONnaR/tNboyR3/BZd58JJSHlUSCU= github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= @@ -54,19 +69,26 @@ github.com/stretchr/testify v1.4.0 h1:2E4SXV/wtOkTonXsotYi4li6zVWxYlZuYNCXe9XRJy github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= +golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20181201002055-351d144fa1fc/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20190108225652-1e06a53dbb7e/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20201008223702-a5fa9d4b7c91 h1:zd7kl5i5PDM0OnFbRWVM6B8mXojzv8LOkHN9LsOrRf4= golang.org/x/net v0.0.0-20201008223702-a5fa9d4b7c91/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= +golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sys v0.0.0-20200622214017-ed371f2e16b4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/text v0.3.1-0.20181227161524-e6919f6577db h1:6/JqlYfC1CCaLnGceQTI+sDGhC9UBSPAsBqI0Gun6kU= golang.org/x/text v0.3.1-0.20181227161524-e6919f6577db/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= +golang.org/x/time v0.0.0-20191024005414-555d28b269f0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20181030221726-6c7e314b6563/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= +google.golang.org/appengine v1.5.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 h1:qIbj1fsPNlZgppZ+VLlY7N33q108Sa+fhmuc+sWQYwY= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/fatih/set.v0 v0.2.1/go.mod h1:5eLWEndGL4zGGemXWrKuts+wTJR0y+w+auqUJZbmyBg= gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys= gopkg.in/inf.v0 v0.9.1 h1:73M5CoZyi3ZLMOyDlQh031Cx6N9NDJ2Vvfl76EDAgDc= gopkg.in/inf.v0 v0.9.1/go.mod h1:cWUDdTG/fYaXco+Dcufb5Vnc6Gp2YChqWtbxRZE0mXw= @@ -74,8 +96,10 @@ gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWD gopkg.in/yaml.v2 v2.2.1 h1:mUhvW9EsL+naU5Q3cakzfE91YhliOondGd6ZrsDBHQE= gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.8 h1:obN1ZagJSUGI0Ek/LBmuj4SNLPfIny3KsKFopxRdj10= gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +k8s.io/klog v1.0.0 h1:Pt+yjF5aB1xDSVbau4VsWe+dQNzA0qv1LlXdC2dF6Q8= k8s.io/klog v1.0.0/go.mod h1:4Bi6QPql/J/LkTDqv7R/cd3hPo4k2DG6Ptcz060Ez5I= k8s.io/kube-openapi v0.0.0-20190228160746-b3a7cee44a30/go.mod h1:BXM9ceUBTj2QnfH2MK1odQs778ajze1RxcmP6S8RVVc= k8s.io/utils v0.0.0-20190221042446-c2654d5206da h1:ElyM7RPonbKnQqOcw7dG2IK5uvQQn3b/WPHqD5mBvP4= diff --git a/staging/src/k8s.io/kube-proxy/go.mod b/staging/src/k8s.io/kube-proxy/go.mod index 763843b221e..6202d577daa 100644 --- a/staging/src/k8s.io/kube-proxy/go.mod +++ b/staging/src/k8s.io/kube-proxy/go.mod @@ -10,16 +10,21 @@ require ( ) replace ( + cloud.google.com/go => cloud.google.com/go v0.34.0 + github.com/dgrijalva/jwt-go => github.com/dgrijalva/jwt-go v0.0.0-20160705203006-01aeca54ebda github.com/google/gofuzz => github.com/google/gofuzz v0.0.0-20170612174753-24818f796faf github.com/googleapis/gnostic => github.com/googleapis/gnostic v0.0.0-20170729233727-0c5108395e2d github.com/hashicorp/golang-lru => github.com/hashicorp/golang-lru v0.5.0 github.com/json-iterator/go => github.com/json-iterator/go v0.0.0-20180701071628-ab8a2e0c74be github.com/prometheus/client_golang => github.com/prometheus/client_golang v0.9.2 github.com/prometheus/common => github.com/prometheus/common v0.0.0-20181126121408-4724e9255275 + golang.org/x/sync => golang.org/x/sync v0.0.0-20181108010431-42b317875d0f golang.org/x/sys => golang.org/x/sys v0.0.0-20200622214017-ed371f2e16b4 golang.org/x/text => golang.org/x/text v0.3.1-0.20181227161524-e6919f6577db gopkg.in/check.v1 => gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 + k8s.io/api => ../api k8s.io/apimachinery => ../apimachinery + k8s.io/client-go => ../client-go k8s.io/component-base => ../component-base k8s.io/kube-openapi => k8s.io/kube-openapi v0.0.0-20190228160746-b3a7cee44a30 k8s.io/kube-proxy => ../kube-proxy diff --git a/staging/src/k8s.io/kube-proxy/go.sum b/staging/src/k8s.io/kube-proxy/go.sum index 271c2d94de0..0471cadc776 100644 --- a/staging/src/k8s.io/kube-proxy/go.sum +++ b/staging/src/k8s.io/kube-proxy/go.sum @@ -1,8 +1,17 @@ +cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= +github.com/Azure/go-autorest/autorest v0.9.0/go.mod h1:xyHB1BMZT0cuDHU7I0+g046+BFDTQ8rEZB0s4Yfa6bI= +github.com/Azure/go-autorest/autorest/adal v0.5.0/go.mod h1:8Z9fGy2MpX0PvDjB1pEgQTmVqjGhiHBW7RJJEciWzS0= +github.com/Azure/go-autorest/autorest/date v0.1.0/go.mod h1:plvfp3oPSKwf2DNjlBjWF/7vwR+cUD/ELuzDCXwHUVA= +github.com/Azure/go-autorest/autorest/mocks v0.1.0/go.mod h1:OTyCOPRA2IgIlWxVYxBee2F5Gr4kF2zd2J5cFRaIDN0= +github.com/Azure/go-autorest/autorest/mocks v0.2.0/go.mod h1:OTyCOPRA2IgIlWxVYxBee2F5Gr4kF2zd2J5cFRaIDN0= +github.com/Azure/go-autorest/logger v0.1.0/go.mod h1:oExouG+K6PryycPJfVSxi/koC6LSNgds39diKLz7Vrc= +github.com/Azure/go-autorest/tracing v0.5.0/go.mod h1:r/s2XiOKccPW3HrqB+W0TQzfbtp2fGCgRFtBroKn4Dk= github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q= github.com/blang/semver v3.5.0+incompatible/go.mod h1:kRBLl5iJ+tD4TcOOxsy/0fnwebNt5EWlYSAyrTnjyyk= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/dgrijalva/jwt-go v0.0.0-20160705203006-01aeca54ebda/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ= github.com/docker/spdystream v0.0.0-20160310174837-449fdfce4d96/go.mod h1:Qh8CwZgvJUkLughtfhJv5dyTYa91l1fOUCrgjqmcifM= github.com/elazarl/goproxy v0.0.0-20180725130230-947c36da3153/go.mod h1:/Zj4wYkgs4iZTTu3o/KG3Itv/qCCa8VVMlb3i9OVuzc= github.com/evanphx/json-patch v4.9.0+incompatible/go.mod h1:50XU6AFN0ol/bzJsmQLiYLvXMP4fmwYFNcr97nuDLSk= @@ -13,14 +22,19 @@ github.com/gogo/protobuf v1.3.1/go.mod h1:SlYgWuQ5SjCEi6WLHjHCa1yvBfUnHcTbrrZtXP github.com/golang/groupcache v0.0.0-20160516000752-02826c3e7903/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= +github.com/google/btree v1.0.0/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= github.com/google/go-cmp v0.3.0 h1:crn/baboCvb5fXaQ0IJ1SGTsTVrWpDsCWC8EGETZijY= github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= github.com/google/gofuzz v0.0.0-20170612174753-24818f796faf h1:+RRA9JqSOZFfKrOeqr2z77+8R2RKyh8PG66dcu1V0ck= github.com/google/gofuzz v0.0.0-20170612174753-24818f796faf/go.mod h1:HP5RmnzzSNb993RKQDq4+1A4ia9nllfqcQFTQJedwGI= github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/googleapis/gnostic v0.0.0-20170729233727-0c5108395e2d/go.mod h1:sJBsCZ4ayReDTBIg8b9dl28c5xFWyhBTVRp3pOg5EKY= +github.com/gophercloud/gophercloud v0.6.0/go.mod h1:GICNByuaEBibcjmjvI7QvYJSZEbGkcYwAR7EZK2WMqM= +github.com/grafov/bcast v0.0.0-20190217190352-1447f067e08d/go.mod h1:RInr+B3/Tx70hYm0rpNPMTD7vH0pBG5ny/JsHAs2KcQ= +github.com/gregjones/httpcache v0.0.0-20180305231024-9cad4c3443a7/go.mod h1:FecbI9+v66THATjSRHfNgh1IVFe/9kFxbXtjV0ctIMA= github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU= +github.com/imdario/mergo v0.3.5/go.mod h1:2EnlNZ0deacrJVfApfmtdGgDfMuh/nq6Ok1EcJh5FfA= github.com/json-iterator/go v0.0.0-20180701071628-ab8a2e0c74be h1:AHimNtVIpiBjPUhEF5KNCkrUyqTSA5zWUl8sQ2bfGBE= github.com/json-iterator/go v0.0.0-20180701071628-ab8a2e0c74be/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU= github.com/kisielk/errcheck v1.2.0/go.mod h1:/BMXB+zMLi60iA8Vv6Ksmxu/1UDYcXs4uQLJ+jE2L00= @@ -39,6 +53,7 @@ github.com/mxk/go-flowrate v0.0.0-20140419014527-cca7078d478f/go.mod h1:ZdcZmHo+ github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= github.com/onsi/ginkgo v1.11.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= github.com/onsi/gomega v1.7.0/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY= +github.com/peterbourgon/diskv v2.0.1+incompatible/go.mod h1:uqqh8zWWbv1HBMNONnaR/tNboyR3/BZd58JJSHlUSCU= github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= @@ -54,19 +69,26 @@ github.com/stretchr/testify v1.4.0 h1:2E4SXV/wtOkTonXsotYi4li6zVWxYlZuYNCXe9XRJy github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= +golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20181201002055-351d144fa1fc/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20190108225652-1e06a53dbb7e/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20201008223702-a5fa9d4b7c91 h1:zd7kl5i5PDM0OnFbRWVM6B8mXojzv8LOkHN9LsOrRf4= golang.org/x/net v0.0.0-20201008223702-a5fa9d4b7c91/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= +golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sys v0.0.0-20200622214017-ed371f2e16b4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/text v0.3.1-0.20181227161524-e6919f6577db h1:6/JqlYfC1CCaLnGceQTI+sDGhC9UBSPAsBqI0Gun6kU= golang.org/x/text v0.3.1-0.20181227161524-e6919f6577db/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= +golang.org/x/time v0.0.0-20191024005414-555d28b269f0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20181030221726-6c7e314b6563/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= +google.golang.org/appengine v1.5.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 h1:qIbj1fsPNlZgppZ+VLlY7N33q108Sa+fhmuc+sWQYwY= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/fatih/set.v0 v0.2.1/go.mod h1:5eLWEndGL4zGGemXWrKuts+wTJR0y+w+auqUJZbmyBg= gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys= gopkg.in/inf.v0 v0.9.1 h1:73M5CoZyi3ZLMOyDlQh031Cx6N9NDJ2Vvfl76EDAgDc= gopkg.in/inf.v0 v0.9.1/go.mod h1:cWUDdTG/fYaXco+Dcufb5Vnc6Gp2YChqWtbxRZE0mXw= @@ -74,8 +96,10 @@ gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWD gopkg.in/yaml.v2 v2.2.1 h1:mUhvW9EsL+naU5Q3cakzfE91YhliOondGd6ZrsDBHQE= gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.8 h1:obN1ZagJSUGI0Ek/LBmuj4SNLPfIny3KsKFopxRdj10= gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +k8s.io/klog v1.0.0 h1:Pt+yjF5aB1xDSVbau4VsWe+dQNzA0qv1LlXdC2dF6Q8= k8s.io/klog v1.0.0/go.mod h1:4Bi6QPql/J/LkTDqv7R/cd3hPo4k2DG6Ptcz060Ez5I= k8s.io/kube-openapi v0.0.0-20190228160746-b3a7cee44a30/go.mod h1:BXM9ceUBTj2QnfH2MK1odQs778ajze1RxcmP6S8RVVc= k8s.io/utils v0.0.0-20190221042446-c2654d5206da h1:ElyM7RPonbKnQqOcw7dG2IK5uvQQn3b/WPHqD5mBvP4= diff --git a/staging/src/k8s.io/kube-scheduler/go.mod b/staging/src/k8s.io/kube-scheduler/go.mod index 4e924a54f46..63c895ff246 100644 --- a/staging/src/k8s.io/kube-scheduler/go.mod +++ b/staging/src/k8s.io/kube-scheduler/go.mod @@ -10,16 +10,21 @@ require ( ) replace ( + cloud.google.com/go => cloud.google.com/go v0.34.0 + github.com/dgrijalva/jwt-go => github.com/dgrijalva/jwt-go v0.0.0-20160705203006-01aeca54ebda github.com/google/gofuzz => github.com/google/gofuzz v0.0.0-20170612174753-24818f796faf github.com/googleapis/gnostic => github.com/googleapis/gnostic v0.0.0-20170729233727-0c5108395e2d github.com/hashicorp/golang-lru => github.com/hashicorp/golang-lru v0.5.0 github.com/json-iterator/go => github.com/json-iterator/go v0.0.0-20180701071628-ab8a2e0c74be github.com/prometheus/client_golang => github.com/prometheus/client_golang v0.9.2 github.com/prometheus/common => github.com/prometheus/common v0.0.0-20181126121408-4724e9255275 + golang.org/x/sync => golang.org/x/sync v0.0.0-20181108010431-42b317875d0f golang.org/x/sys => golang.org/x/sys v0.0.0-20200622214017-ed371f2e16b4 golang.org/x/text => golang.org/x/text v0.3.1-0.20181227161524-e6919f6577db gopkg.in/check.v1 => gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 + k8s.io/api => ../api k8s.io/apimachinery => ../apimachinery + k8s.io/client-go => ../client-go k8s.io/component-base => ../component-base k8s.io/kube-openapi => k8s.io/kube-openapi v0.0.0-20190228160746-b3a7cee44a30 k8s.io/kube-scheduler => ../kube-scheduler diff --git a/staging/src/k8s.io/kube-scheduler/go.sum b/staging/src/k8s.io/kube-scheduler/go.sum index 271c2d94de0..0471cadc776 100644 --- a/staging/src/k8s.io/kube-scheduler/go.sum +++ b/staging/src/k8s.io/kube-scheduler/go.sum @@ -1,8 +1,17 @@ +cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= +github.com/Azure/go-autorest/autorest v0.9.0/go.mod h1:xyHB1BMZT0cuDHU7I0+g046+BFDTQ8rEZB0s4Yfa6bI= +github.com/Azure/go-autorest/autorest/adal v0.5.0/go.mod h1:8Z9fGy2MpX0PvDjB1pEgQTmVqjGhiHBW7RJJEciWzS0= +github.com/Azure/go-autorest/autorest/date v0.1.0/go.mod h1:plvfp3oPSKwf2DNjlBjWF/7vwR+cUD/ELuzDCXwHUVA= +github.com/Azure/go-autorest/autorest/mocks v0.1.0/go.mod h1:OTyCOPRA2IgIlWxVYxBee2F5Gr4kF2zd2J5cFRaIDN0= +github.com/Azure/go-autorest/autorest/mocks v0.2.0/go.mod h1:OTyCOPRA2IgIlWxVYxBee2F5Gr4kF2zd2J5cFRaIDN0= +github.com/Azure/go-autorest/logger v0.1.0/go.mod h1:oExouG+K6PryycPJfVSxi/koC6LSNgds39diKLz7Vrc= +github.com/Azure/go-autorest/tracing v0.5.0/go.mod h1:r/s2XiOKccPW3HrqB+W0TQzfbtp2fGCgRFtBroKn4Dk= github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q= github.com/blang/semver v3.5.0+incompatible/go.mod h1:kRBLl5iJ+tD4TcOOxsy/0fnwebNt5EWlYSAyrTnjyyk= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/dgrijalva/jwt-go v0.0.0-20160705203006-01aeca54ebda/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ= github.com/docker/spdystream v0.0.0-20160310174837-449fdfce4d96/go.mod h1:Qh8CwZgvJUkLughtfhJv5dyTYa91l1fOUCrgjqmcifM= github.com/elazarl/goproxy v0.0.0-20180725130230-947c36da3153/go.mod h1:/Zj4wYkgs4iZTTu3o/KG3Itv/qCCa8VVMlb3i9OVuzc= github.com/evanphx/json-patch v4.9.0+incompatible/go.mod h1:50XU6AFN0ol/bzJsmQLiYLvXMP4fmwYFNcr97nuDLSk= @@ -13,14 +22,19 @@ github.com/gogo/protobuf v1.3.1/go.mod h1:SlYgWuQ5SjCEi6WLHjHCa1yvBfUnHcTbrrZtXP github.com/golang/groupcache v0.0.0-20160516000752-02826c3e7903/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= +github.com/google/btree v1.0.0/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= github.com/google/go-cmp v0.3.0 h1:crn/baboCvb5fXaQ0IJ1SGTsTVrWpDsCWC8EGETZijY= github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= github.com/google/gofuzz v0.0.0-20170612174753-24818f796faf h1:+RRA9JqSOZFfKrOeqr2z77+8R2RKyh8PG66dcu1V0ck= github.com/google/gofuzz v0.0.0-20170612174753-24818f796faf/go.mod h1:HP5RmnzzSNb993RKQDq4+1A4ia9nllfqcQFTQJedwGI= github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/googleapis/gnostic v0.0.0-20170729233727-0c5108395e2d/go.mod h1:sJBsCZ4ayReDTBIg8b9dl28c5xFWyhBTVRp3pOg5EKY= +github.com/gophercloud/gophercloud v0.6.0/go.mod h1:GICNByuaEBibcjmjvI7QvYJSZEbGkcYwAR7EZK2WMqM= +github.com/grafov/bcast v0.0.0-20190217190352-1447f067e08d/go.mod h1:RInr+B3/Tx70hYm0rpNPMTD7vH0pBG5ny/JsHAs2KcQ= +github.com/gregjones/httpcache v0.0.0-20180305231024-9cad4c3443a7/go.mod h1:FecbI9+v66THATjSRHfNgh1IVFe/9kFxbXtjV0ctIMA= github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU= +github.com/imdario/mergo v0.3.5/go.mod h1:2EnlNZ0deacrJVfApfmtdGgDfMuh/nq6Ok1EcJh5FfA= github.com/json-iterator/go v0.0.0-20180701071628-ab8a2e0c74be h1:AHimNtVIpiBjPUhEF5KNCkrUyqTSA5zWUl8sQ2bfGBE= github.com/json-iterator/go v0.0.0-20180701071628-ab8a2e0c74be/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU= github.com/kisielk/errcheck v1.2.0/go.mod h1:/BMXB+zMLi60iA8Vv6Ksmxu/1UDYcXs4uQLJ+jE2L00= @@ -39,6 +53,7 @@ github.com/mxk/go-flowrate v0.0.0-20140419014527-cca7078d478f/go.mod h1:ZdcZmHo+ github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= github.com/onsi/ginkgo v1.11.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= github.com/onsi/gomega v1.7.0/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY= +github.com/peterbourgon/diskv v2.0.1+incompatible/go.mod h1:uqqh8zWWbv1HBMNONnaR/tNboyR3/BZd58JJSHlUSCU= github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= @@ -54,19 +69,26 @@ github.com/stretchr/testify v1.4.0 h1:2E4SXV/wtOkTonXsotYi4li6zVWxYlZuYNCXe9XRJy github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= +golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20181201002055-351d144fa1fc/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20190108225652-1e06a53dbb7e/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20201008223702-a5fa9d4b7c91 h1:zd7kl5i5PDM0OnFbRWVM6B8mXojzv8LOkHN9LsOrRf4= golang.org/x/net v0.0.0-20201008223702-a5fa9d4b7c91/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= +golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sys v0.0.0-20200622214017-ed371f2e16b4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/text v0.3.1-0.20181227161524-e6919f6577db h1:6/JqlYfC1CCaLnGceQTI+sDGhC9UBSPAsBqI0Gun6kU= golang.org/x/text v0.3.1-0.20181227161524-e6919f6577db/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= +golang.org/x/time v0.0.0-20191024005414-555d28b269f0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20181030221726-6c7e314b6563/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= +google.golang.org/appengine v1.5.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 h1:qIbj1fsPNlZgppZ+VLlY7N33q108Sa+fhmuc+sWQYwY= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/fatih/set.v0 v0.2.1/go.mod h1:5eLWEndGL4zGGemXWrKuts+wTJR0y+w+auqUJZbmyBg= gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys= gopkg.in/inf.v0 v0.9.1 h1:73M5CoZyi3ZLMOyDlQh031Cx6N9NDJ2Vvfl76EDAgDc= gopkg.in/inf.v0 v0.9.1/go.mod h1:cWUDdTG/fYaXco+Dcufb5Vnc6Gp2YChqWtbxRZE0mXw= @@ -74,8 +96,10 @@ gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWD gopkg.in/yaml.v2 v2.2.1 h1:mUhvW9EsL+naU5Q3cakzfE91YhliOondGd6ZrsDBHQE= gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.8 h1:obN1ZagJSUGI0Ek/LBmuj4SNLPfIny3KsKFopxRdj10= gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +k8s.io/klog v1.0.0 h1:Pt+yjF5aB1xDSVbau4VsWe+dQNzA0qv1LlXdC2dF6Q8= k8s.io/klog v1.0.0/go.mod h1:4Bi6QPql/J/LkTDqv7R/cd3hPo4k2DG6Ptcz060Ez5I= k8s.io/kube-openapi v0.0.0-20190228160746-b3a7cee44a30/go.mod h1:BXM9ceUBTj2QnfH2MK1odQs778ajze1RxcmP6S8RVVc= k8s.io/utils v0.0.0-20190221042446-c2654d5206da h1:ElyM7RPonbKnQqOcw7dG2IK5uvQQn3b/WPHqD5mBvP4= diff --git a/staging/src/k8s.io/kubelet/go.sum b/staging/src/k8s.io/kubelet/go.sum index ba4d7bd935a..4e0feb5c0c4 100644 --- a/staging/src/k8s.io/kubelet/go.sum +++ b/staging/src/k8s.io/kubelet/go.sum @@ -67,6 +67,7 @@ gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.8 h1:obN1ZagJSUGI0Ek/LBmuj4SNLPfIny3KsKFopxRdj10= gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +k8s.io/klog v1.0.0 h1:Pt+yjF5aB1xDSVbau4VsWe+dQNzA0qv1LlXdC2dF6Q8= k8s.io/klog v1.0.0/go.mod h1:4Bi6QPql/J/LkTDqv7R/cd3hPo4k2DG6Ptcz060Ez5I= k8s.io/kube-openapi v0.0.0-20190228160746-b3a7cee44a30/go.mod h1:BXM9ceUBTj2QnfH2MK1odQs778ajze1RxcmP6S8RVVc= sigs.k8s.io/yaml v1.1.0 h1:4A07+ZFc2wgJwo8YNlQpr1rVlgUDlxXHhPJciaPY5gs= diff --git a/staging/src/k8s.io/legacy-cloud-providers/aws/BUILD b/staging/src/k8s.io/legacy-cloud-providers/aws/BUILD index 3fa4d5b4a49..0a608e29bc4 100644 --- a/staging/src/k8s.io/legacy-cloud-providers/aws/BUILD +++ b/staging/src/k8s.io/legacy-cloud-providers/aws/BUILD @@ -44,6 +44,8 @@ go_library( "//staging/src/k8s.io/cloud-provider/volume:go_default_library", "//staging/src/k8s.io/cloud-provider/volume/errors:go_default_library", "//staging/src/k8s.io/cloud-provider/volume/helpers:go_default_library", + "//staging/src/k8s.io/component-base/metrics:go_default_library", + "//staging/src/k8s.io/component-base/metrics/legacyregistry:go_default_library", "//staging/src/k8s.io/csi-translation-lib/plugins:go_default_library", "//vendor/github.com/aws/aws-sdk-go/aws:go_default_library", "//vendor/github.com/aws/aws-sdk-go/aws/awserr:go_default_library", diff --git a/staging/src/k8s.io/legacy-cloud-providers/aws/aws_metrics.go b/staging/src/k8s.io/legacy-cloud-providers/aws/aws_metrics.go index bb7958f04f0..b2da9535cf0 100644 --- a/staging/src/k8s.io/legacy-cloud-providers/aws/aws_metrics.go +++ b/staging/src/k8s.io/legacy-cloud-providers/aws/aws_metrics.go @@ -20,27 +20,33 @@ import ( "sync" "github.com/prometheus/client_golang/prometheus" + + "k8s.io/component-base/metrics" + "k8s.io/component-base/metrics/legacyregistry" ) var ( - awsAPIMetric = prometheus.NewHistogramVec( - prometheus.HistogramOpts{ - Name: "cloudprovider_aws_api_request_duration_seconds", - Help: "Latency of AWS API calls", + awsAPIMetric = metrics.NewHistogramVec( + &metrics.HistogramOpts{ + Name: "cloudprovider_aws_api_request_duration_seconds", + Help: "Latency of AWS API calls", + StabilityLevel: metrics.ALPHA, }, []string{"request"}) - awsAPIErrorMetric = prometheus.NewCounterVec( - prometheus.CounterOpts{ - Name: "cloudprovider_aws_api_request_errors", - Help: "AWS API errors", + awsAPIErrorMetric = metrics.NewCounterVec( + &metrics.CounterOpts{ + Name: "cloudprovider_aws_api_request_errors", + Help: "AWS API errors", + StabilityLevel: metrics.ALPHA, }, []string{"request"}) - awsAPIThrottlesMetric = prometheus.NewCounterVec( - prometheus.CounterOpts{ - Name: "cloudprovider_aws_api_throttled_requests_total", - Help: "AWS API throttled requests", + awsAPIThrottlesMetric = metrics.NewCounterVec( + &metrics.CounterOpts{ + Name: "cloudprovider_aws_api_throttled_requests_total", + Help: "AWS API throttled requests", + StabilityLevel: metrics.ALPHA, }, []string{"operation_name"}) ) @@ -61,8 +67,8 @@ var registerOnce sync.Once func registerMetrics() { registerOnce.Do(func() { - prometheus.MustRegister(awsAPIMetric) - prometheus.MustRegister(awsAPIErrorMetric) - prometheus.MustRegister(awsAPIThrottlesMetric) + legacyregistry.MustRegister(awsAPIMetric) + legacyregistry.MustRegister(awsAPIErrorMetric) + legacyregistry.MustRegister(awsAPIThrottlesMetric) }) } diff --git a/staging/src/k8s.io/legacy-cloud-providers/azure/BUILD b/staging/src/k8s.io/legacy-cloud-providers/azure/BUILD index 898a77be6a1..973e1e14e30 100644 --- a/staging/src/k8s.io/legacy-cloud-providers/azure/BUILD +++ b/staging/src/k8s.io/legacy-cloud-providers/azure/BUILD @@ -60,6 +60,8 @@ go_library( "//staging/src/k8s.io/cloud-provider/volume:go_default_library", "//staging/src/k8s.io/cloud-provider/volume/errors:go_default_library", "//staging/src/k8s.io/cloud-provider/volume/helpers:go_default_library", + "//staging/src/k8s.io/component-base/metrics:go_default_library", + "//staging/src/k8s.io/component-base/metrics/legacyregistry:go_default_library", "//staging/src/k8s.io/legacy-cloud-providers/azure/auth:go_default_library", "//vendor/github.com/Azure/azure-sdk-for-go/services/compute/mgmt/2019-07-01/compute:go_default_library", "//vendor/github.com/Azure/azure-sdk-for-go/services/network/mgmt/2019-06-01/network:go_default_library", @@ -69,7 +71,6 @@ go_library( "//vendor/github.com/Azure/go-autorest/autorest/adal:go_default_library", "//vendor/github.com/Azure/go-autorest/autorest/azure:go_default_library", "//vendor/github.com/Azure/go-autorest/autorest/to:go_default_library", - "//vendor/github.com/prometheus/client_golang/prometheus:go_default_library", "//vendor/github.com/rubiojr/go-vhd/vhd:go_default_library", "//vendor/k8s.io/klog:go_default_library", "//vendor/k8s.io/utils/keymutex:go_default_library", diff --git a/staging/src/k8s.io/legacy-cloud-providers/azure/azure_metrics.go b/staging/src/k8s.io/legacy-cloud-providers/azure/azure_metrics.go index 7eddafab9ff..cc5edd17608 100644 --- a/staging/src/k8s.io/legacy-cloud-providers/azure/azure_metrics.go +++ b/staging/src/k8s.io/legacy-cloud-providers/azure/azure_metrics.go @@ -20,12 +20,13 @@ import ( "strings" "time" - "github.com/prometheus/client_golang/prometheus" + "k8s.io/component-base/metrics" + "k8s.io/component-base/metrics/legacyregistry" ) type apiCallMetrics struct { - latency *prometheus.HistogramVec - errors *prometheus.CounterVec + latency *metrics.HistogramVec + errors *metrics.CounterVec } var ( @@ -63,24 +64,26 @@ func (mc *metricContext) Observe(err error) error { func registerAPIMetrics(attributes ...string) *apiCallMetrics { metrics := &apiCallMetrics{ - latency: prometheus.NewHistogramVec( - prometheus.HistogramOpts{ - Name: "cloudprovider_azure_api_request_duration_seconds", - Help: "Latency of an Azure API call", + latency: metrics.NewHistogramVec( + &metrics.HistogramOpts{ + Name: "cloudprovider_azure_api_request_duration_seconds", + Help: "Latency of an Azure API call", + StabilityLevel: metrics.ALPHA, }, attributes, ), - errors: prometheus.NewCounterVec( - prometheus.CounterOpts{ - Name: "cloudprovider_azure_api_request_errors", - Help: "Number of errors for an Azure API call", + errors: metrics.NewCounterVec( + &metrics.CounterOpts{ + Name: "cloudprovider_azure_api_request_errors", + Help: "Number of errors for an Azure API call", + StabilityLevel: metrics.ALPHA, }, attributes, ), } - prometheus.MustRegister(metrics.latency) - prometheus.MustRegister(metrics.errors) + legacyregistry.MustRegister(metrics.latency) + legacyregistry.MustRegister(metrics.errors) return metrics } diff --git a/staging/src/k8s.io/legacy-cloud-providers/gce/BUILD b/staging/src/k8s.io/legacy-cloud-providers/gce/BUILD index 1354a0ab1b7..bcbbaaef35d 100644 --- a/staging/src/k8s.io/legacy-cloud-providers/gce/BUILD +++ b/staging/src/k8s.io/legacy-cloud-providers/gce/BUILD @@ -66,12 +66,13 @@ go_library( "//staging/src/k8s.io/cloud-provider/volume:go_default_library", "//staging/src/k8s.io/cloud-provider/volume/errors:go_default_library", "//staging/src/k8s.io/cloud-provider/volume/helpers:go_default_library", + "//staging/src/k8s.io/component-base/metrics:go_default_library", + "//staging/src/k8s.io/component-base/metrics/legacyregistry:go_default_library", "//vendor/cloud.google.com/go/compute/metadata:go_default_library", "//vendor/github.com/GoogleCloudPlatform/k8s-cloud-provider/pkg/cloud:go_default_library", "//vendor/github.com/GoogleCloudPlatform/k8s-cloud-provider/pkg/cloud/filter:go_default_library", "//vendor/github.com/GoogleCloudPlatform/k8s-cloud-provider/pkg/cloud/meta:go_default_library", "//vendor/github.com/GoogleCloudPlatform/k8s-cloud-provider/pkg/cloud/mock:go_default_library", - "//vendor/github.com/prometheus/client_golang/prometheus:go_default_library", "//vendor/golang.org/x/oauth2:go_default_library", "//vendor/golang.org/x/oauth2/google:go_default_library", "//vendor/google.golang.org/api/compute/v0.alpha:go_default_library", diff --git a/staging/src/k8s.io/legacy-cloud-providers/gce/metrics.go b/staging/src/k8s.io/legacy-cloud-providers/gce/metrics.go index 22f1c2dde6f..6cc8e80a408 100644 --- a/staging/src/k8s.io/legacy-cloud-providers/gce/metrics.go +++ b/staging/src/k8s.io/legacy-cloud-providers/gce/metrics.go @@ -19,7 +19,8 @@ package gce import ( "time" - "github.com/prometheus/client_golang/prometheus" + "k8s.io/component-base/metrics" + "k8s.io/component-base/metrics/legacyregistry" ) const ( @@ -30,8 +31,8 @@ const ( ) type apiCallMetrics struct { - latency *prometheus.HistogramVec - errors *prometheus.CounterVec + latency *metrics.HistogramVec + errors *metrics.CounterVec } var ( @@ -82,24 +83,26 @@ func newGenericMetricContext(prefix, request, region, zone, version string) *met // registerApiMetrics adds metrics definitions for a category of API calls. func registerAPIMetrics(attributes ...string) *apiCallMetrics { metrics := &apiCallMetrics{ - latency: prometheus.NewHistogramVec( - prometheus.HistogramOpts{ - Name: "cloudprovider_gce_api_request_duration_seconds", - Help: "Latency of a GCE API call", + latency: metrics.NewHistogramVec( + &metrics.HistogramOpts{ + Name: "cloudprovider_gce_api_request_duration_seconds", + Help: "Latency of a GCE API call", + StabilityLevel: metrics.ALPHA, }, attributes, ), - errors: prometheus.NewCounterVec( - prometheus.CounterOpts{ - Name: "cloudprovider_gce_api_request_errors", - Help: "Number of errors for an API call", + errors: metrics.NewCounterVec( + &metrics.CounterOpts{ + Name: "cloudprovider_gce_api_request_errors", + Help: "Number of errors for an API call", + StabilityLevel: metrics.ALPHA, }, attributes, ), } - prometheus.MustRegister(metrics.latency) - prometheus.MustRegister(metrics.errors) + legacyregistry.MustRegister(metrics.latency) + legacyregistry.MustRegister(metrics.errors) return metrics } diff --git a/staging/src/k8s.io/legacy-cloud-providers/gce/token_source.go b/staging/src/k8s.io/legacy-cloud-providers/gce/token_source.go index e8434bd2a0c..72a47d29e43 100644 --- a/staging/src/k8s.io/legacy-cloud-providers/gce/token_source.go +++ b/staging/src/k8s.io/legacy-cloud-providers/gce/token_source.go @@ -22,12 +22,13 @@ import ( "strings" "time" - "k8s.io/client-go/util/flowcontrol" - - "github.com/prometheus/client_golang/prometheus" "golang.org/x/oauth2" "golang.org/x/oauth2/google" "google.golang.org/api/googleapi" + + "k8s.io/client-go/util/flowcontrol" + "k8s.io/component-base/metrics" + "k8s.io/component-base/metrics/legacyregistry" ) const ( @@ -37,24 +38,34 @@ const ( tokenURLBurst = 3 ) +/* + * By default, all the following metrics are defined as falling under + * ALPHA stability level https://github.com/kubernetes/enhancements/blob/master/keps/sig-instrumentation/20190404-kubernetes-control-plane-metrics-stability.md#stability-classes) + * + * Promoting the stability level of the metric is a responsibility of the component owner, since it + * involves explicitly acknowledging support for the metric across multiple releases, in accordance with + * the metric stability policy. + */ var ( - getTokenCounter = prometheus.NewCounter( - prometheus.CounterOpts{ - Name: "get_token_count", - Help: "Counter of total Token() requests to the alternate token source", + getTokenCounter = metrics.NewCounter( + &metrics.CounterOpts{ + Name: "get_token_count", + Help: "Counter of total Token() requests to the alternate token source", + StabilityLevel: metrics.ALPHA, }, ) - getTokenFailCounter = prometheus.NewCounter( - prometheus.CounterOpts{ - Name: "get_token_fail_count", - Help: "Counter of failed Token() requests to the alternate token source", + getTokenFailCounter = metrics.NewCounter( + &metrics.CounterOpts{ + Name: "get_token_fail_count", + Help: "Counter of failed Token() requests to the alternate token source", + StabilityLevel: metrics.ALPHA, }, ) ) func init() { - prometheus.MustRegister(getTokenCounter) - prometheus.MustRegister(getTokenFailCounter) + legacyregistry.MustRegister(getTokenCounter) + legacyregistry.MustRegister(getTokenFailCounter) } // AltTokenSource is the structure holding the data for the functionality needed to generates tokens diff --git a/staging/src/k8s.io/legacy-cloud-providers/go.sum b/staging/src/k8s.io/legacy-cloud-providers/go.sum index 720a16147c8..9e29987f5ba 100644 --- a/staging/src/k8s.io/legacy-cloud-providers/go.sum +++ b/staging/src/k8s.io/legacy-cloud-providers/go.sum @@ -1,14 +1,23 @@ cloud.google.com/go v0.34.0 h1:eOI3/cP2VTU6uZLDYAoic+eyzzB9YyGmJ7eIjl8rOPg= cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= +github.com/Azure/azure-sdk-for-go v35.0.0+incompatible h1:PkmdmQUmeSdQQ5258f4SyCf2Zcz0w67qztEg37cOR7U= github.com/Azure/azure-sdk-for-go v35.0.0+incompatible/go.mod h1:9XXNKU+eRnpl9moKnB4QOLf1HestfXbmab5FXxiDBjc= +github.com/Azure/go-autorest/autorest v0.9.0 h1:MRvx8gncNaXJqOoLmhNjUAKh33JJF8LyxPhomEtOsjs= github.com/Azure/go-autorest/autorest v0.9.0/go.mod h1:xyHB1BMZT0cuDHU7I0+g046+BFDTQ8rEZB0s4Yfa6bI= +github.com/Azure/go-autorest/autorest/adal v0.5.0 h1:q2gDruN08/guU9vAjuPWff0+QIrpH6ediguzdAzXAUU= github.com/Azure/go-autorest/autorest/adal v0.5.0/go.mod h1:8Z9fGy2MpX0PvDjB1pEgQTmVqjGhiHBW7RJJEciWzS0= +github.com/Azure/go-autorest/autorest/date v0.1.0 h1:YGrhWfrgtFs84+h0o46rJrlmsZtyZRg470CqAXTZaGM= github.com/Azure/go-autorest/autorest/date v0.1.0/go.mod h1:plvfp3oPSKwf2DNjlBjWF/7vwR+cUD/ELuzDCXwHUVA= github.com/Azure/go-autorest/autorest/mocks v0.1.0/go.mod h1:OTyCOPRA2IgIlWxVYxBee2F5Gr4kF2zd2J5cFRaIDN0= +github.com/Azure/go-autorest/autorest/mocks v0.2.0 h1:Ww5g4zThfD/6cLb4z6xxgeyDa7QDkizMkJKe0ysZXp0= github.com/Azure/go-autorest/autorest/mocks v0.2.0/go.mod h1:OTyCOPRA2IgIlWxVYxBee2F5Gr4kF2zd2J5cFRaIDN0= +github.com/Azure/go-autorest/autorest/to v0.2.0 h1:nQOZzFCudTh+TvquAtCRjM01VEYx85e9qbwt5ncW4L8= github.com/Azure/go-autorest/autorest/to v0.2.0/go.mod h1:GunWKJp1AEqgMaGLV+iocmRAJWqST1wQYhyyjXJ3SJc= +github.com/Azure/go-autorest/autorest/validation v0.1.0 h1:ISSNzGUh+ZSzizJWOWzs8bwpXIePbGLW4z/AmUFGH5A= github.com/Azure/go-autorest/autorest/validation v0.1.0/go.mod h1:Ha3z/SqBeaalWQvokg3NZAlQTalVMtOIAs1aGK7G6u8= +github.com/Azure/go-autorest/logger v0.1.0 h1:ruG4BSDXONFRrZZJ2GUXDiUyVpayPmb1GnWeHDdaNKY= github.com/Azure/go-autorest/logger v0.1.0/go.mod h1:oExouG+K6PryycPJfVSxi/koC6LSNgds39diKLz7Vrc= +github.com/Azure/go-autorest/tracing v0.5.0 h1:TRn4WjSnkcSy5AEG3pnbtFSwNtwzjr4VYyQflFE619k= github.com/Azure/go-autorest/tracing v0.5.0/go.mod h1:r/s2XiOKccPW3HrqB+W0TQzfbtp2fGCgRFtBroKn4Dk= github.com/GoogleCloudPlatform/k8s-cloud-provider v0.0.0-20181220005116-f8e995905100 h1:EXrpgbxknFeRM6X/OgRqcbVtl5zqUFD5eV8O8M1BLzo= github.com/GoogleCloudPlatform/k8s-cloud-provider v0.0.0-20181220005116-f8e995905100/go.mod h1:iroGtC8B3tQiqtds1l+mgk/BBOrxbqjH+eUfFQYRc14= @@ -48,6 +57,7 @@ github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+ github.com/googleapis/gnostic v0.0.0-20170729233727-0c5108395e2d h1:7XGaL1e6bYS1yIonGp9761ExpPPV1ui0SAC59Yube9k= github.com/googleapis/gnostic v0.0.0-20170729233727-0c5108395e2d/go.mod h1:sJBsCZ4ayReDTBIg8b9dl28c5xFWyhBTVRp3pOg5EKY= github.com/gophercloud/gophercloud v0.6.0/go.mod h1:GICNByuaEBibcjmjvI7QvYJSZEbGkcYwAR7EZK2WMqM= +github.com/grafov/bcast v0.0.0-20190217190352-1447f067e08d h1:Q2+KsA/1GLC9xyLsDun3/EOJ+83rY/IHRsO1DToPrdo= github.com/grafov/bcast v0.0.0-20190217190352-1447f067e08d/go.mod h1:RInr+B3/Tx70hYm0rpNPMTD7vH0pBG5ny/JsHAs2KcQ= github.com/gregjones/httpcache v0.0.0-20180305231024-9cad4c3443a7/go.mod h1:FecbI9+v66THATjSRHfNgh1IVFe/9kFxbXtjV0ctIMA= github.com/hashicorp/golang-lru v0.5.0 h1:CL2msUPvZTLb5O648aiLNJw3hnBxN2+1Jq8rCOH9wdo= @@ -137,6 +147,7 @@ google.golang.org/appengine v1.5.0 h1:KxkO13IPW4Lslp2bz+KHP2E3gtFlrIGNThxkZQ3g+4 google.golang.org/appengine v1.5.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 h1:qIbj1fsPNlZgppZ+VLlY7N33q108Sa+fhmuc+sWQYwY= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/fatih/set.v0 v0.2.1 h1:Xvyyp7LXu34P0ROhCyfXkmQCAoOUKb1E2JS9I7SE5CY= gopkg.in/fatih/set.v0 v0.2.1/go.mod h1:5eLWEndGL4zGGemXWrKuts+wTJR0y+w+auqUJZbmyBg= gopkg.in/fsnotify.v1 v1.4.7 h1:xOHLXZwVvI9hhs+cLKq5+I5onOuwQLhQwiu63xxlHs4= gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys= @@ -154,6 +165,7 @@ gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.8 h1:obN1ZagJSUGI0Ek/LBmuj4SNLPfIny3KsKFopxRdj10= gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +k8s.io/klog v1.0.0 h1:Pt+yjF5aB1xDSVbau4VsWe+dQNzA0qv1LlXdC2dF6Q8= k8s.io/klog v1.0.0/go.mod h1:4Bi6QPql/J/LkTDqv7R/cd3hPo4k2DG6Ptcz060Ez5I= k8s.io/kube-openapi v0.0.0-20190228160746-b3a7cee44a30 h1:TRb4wNWoBVrH9plmkp2q86FIDppkbrEXdXlxU3a3BMI= k8s.io/kube-openapi v0.0.0-20190228160746-b3a7cee44a30/go.mod h1:BXM9ceUBTj2QnfH2MK1odQs778ajze1RxcmP6S8RVVc= diff --git a/staging/src/k8s.io/legacy-cloud-providers/vsphere/vclib/BUILD b/staging/src/k8s.io/legacy-cloud-providers/vsphere/vclib/BUILD index 8a32963b285..a720bb901e5 100644 --- a/staging/src/k8s.io/legacy-cloud-providers/vsphere/vclib/BUILD +++ b/staging/src/k8s.io/legacy-cloud-providers/vsphere/vclib/BUILD @@ -26,6 +26,8 @@ go_library( importpath = "k8s.io/legacy-cloud-providers/vsphere/vclib", deps = [ "//staging/src/k8s.io/client-go/pkg/version:go_default_library", + "//staging/src/k8s.io/component-base/metrics:go_default_library", + "//staging/src/k8s.io/component-base/metrics/legacyregistry:go_default_library", "//vendor/github.com/prometheus/client_golang/prometheus:go_default_library", "//vendor/github.com/vmware/govmomi/find:go_default_library", "//vendor/github.com/vmware/govmomi/object:go_default_library", diff --git a/staging/src/k8s.io/legacy-cloud-providers/vsphere/vclib/vsphere_metrics.go b/staging/src/k8s.io/legacy-cloud-providers/vsphere/vclib/vsphere_metrics.go index ab5b45f87f9..5baafc4ff0e 100644 --- a/staging/src/k8s.io/legacy-cloud-providers/vsphere/vclib/vsphere_metrics.go +++ b/staging/src/k8s.io/legacy-cloud-providers/vsphere/vclib/vsphere_metrics.go @@ -20,6 +20,9 @@ import ( "time" "github.com/prometheus/client_golang/prometheus" + + "k8s.io/component-base/metrics" + "k8s.io/component-base/metrics/legacyregistry" ) // Cloud Provider API constants @@ -43,45 +46,49 @@ const ( ) // vsphereAPIMetric is for recording latency of Single API Call. -var vsphereAPIMetric = prometheus.NewHistogramVec( - prometheus.HistogramOpts{ - Name: "cloudprovider_vsphere_api_request_duration_seconds", - Help: "Latency of vsphere api call", +var vsphereAPIMetric = metrics.NewHistogramVec( + &metrics.HistogramOpts{ + Name: "cloudprovider_vsphere_api_request_duration_seconds", + Help: "Latency of vsphere api call", + StabilityLevel: metrics.ALPHA, }, []string{"request"}, ) -var vsphereAPIErrorMetric = prometheus.NewCounterVec( - prometheus.CounterOpts{ - Name: "cloudprovider_vsphere_api_request_errors", - Help: "vsphere Api errors", +var vsphereAPIErrorMetric = metrics.NewCounterVec( + &metrics.CounterOpts{ + Name: "cloudprovider_vsphere_api_request_errors", + Help: "vsphere Api errors", + StabilityLevel: metrics.ALPHA, }, []string{"request"}, ) // vsphereOperationMetric is for recording latency of vSphere Operation which invokes multiple APIs to get the task done. -var vsphereOperationMetric = prometheus.NewHistogramVec( - prometheus.HistogramOpts{ - Name: "cloudprovider_vsphere_operation_duration_seconds", - Help: "Latency of vsphere operation call", +var vsphereOperationMetric = metrics.NewHistogramVec( + &metrics.HistogramOpts{ + Name: "cloudprovider_vsphere_operation_duration_seconds", + Help: "Latency of vsphere operation call", + StabilityLevel: metrics.ALPHA, }, []string{"operation"}, ) -var vsphereOperationErrorMetric = prometheus.NewCounterVec( - prometheus.CounterOpts{ - Name: "cloudprovider_vsphere_operation_errors", - Help: "vsphere operation errors", +var vsphereOperationErrorMetric = metrics.NewCounterVec( + &metrics.CounterOpts{ + Name: "cloudprovider_vsphere_operation_errors", + Help: "vsphere operation errors", + StabilityLevel: metrics.ALPHA, }, []string{"operation"}, ) // RegisterMetrics registers all the API and Operation metrics func RegisterMetrics() { - prometheus.MustRegister(vsphereAPIMetric) - prometheus.MustRegister(vsphereAPIErrorMetric) - prometheus.MustRegister(vsphereOperationMetric) - prometheus.MustRegister(vsphereOperationErrorMetric) + legacyregistry.MustRegister(vsphereAPIMetric) + legacyregistry.MustRegister(vsphereAPIErrorMetric) + legacyregistry.MustRegister(vsphereOperationMetric) + legacyregistry.MustRegister(vsphereOperationErrorMetric) } // RecordvSphereMetric records the vSphere API and Operation metrics diff --git a/staging/src/k8s.io/metrics/go.sum b/staging/src/k8s.io/metrics/go.sum index a1ca95651c4..a6bccaeb73c 100644 --- a/staging/src/k8s.io/metrics/go.sum +++ b/staging/src/k8s.io/metrics/go.sum @@ -34,6 +34,7 @@ github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+ github.com/googleapis/gnostic v0.0.0-20170729233727-0c5108395e2d h1:7XGaL1e6bYS1yIonGp9761ExpPPV1ui0SAC59Yube9k= github.com/googleapis/gnostic v0.0.0-20170729233727-0c5108395e2d/go.mod h1:sJBsCZ4ayReDTBIg8b9dl28c5xFWyhBTVRp3pOg5EKY= github.com/gophercloud/gophercloud v0.6.0/go.mod h1:GICNByuaEBibcjmjvI7QvYJSZEbGkcYwAR7EZK2WMqM= +github.com/grafov/bcast v0.0.0-20190217190352-1447f067e08d h1:Q2+KsA/1GLC9xyLsDun3/EOJ+83rY/IHRsO1DToPrdo= github.com/grafov/bcast v0.0.0-20190217190352-1447f067e08d/go.mod h1:RInr+B3/Tx70hYm0rpNPMTD7vH0pBG5ny/JsHAs2KcQ= github.com/gregjones/httpcache v0.0.0-20180305231024-9cad4c3443a7/go.mod h1:FecbI9+v66THATjSRHfNgh1IVFe/9kFxbXtjV0ctIMA= github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= @@ -114,6 +115,7 @@ google.golang.org/appengine v1.5.0 h1:KxkO13IPW4Lslp2bz+KHP2E3gtFlrIGNThxkZQ3g+4 google.golang.org/appengine v1.5.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 h1:qIbj1fsPNlZgppZ+VLlY7N33q108Sa+fhmuc+sWQYwY= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/fatih/set.v0 v0.2.1 h1:Xvyyp7LXu34P0ROhCyfXkmQCAoOUKb1E2JS9I7SE5CY= gopkg.in/fatih/set.v0 v0.2.1/go.mod h1:5eLWEndGL4zGGemXWrKuts+wTJR0y+w+auqUJZbmyBg= gopkg.in/fsnotify.v1 v1.4.7 h1:xOHLXZwVvI9hhs+cLKq5+I5onOuwQLhQwiu63xxlHs4= gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys= @@ -129,6 +131,7 @@ gopkg.in/yaml.v2 v2.2.8 h1:obN1ZagJSUGI0Ek/LBmuj4SNLPfIny3KsKFopxRdj10= gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= k8s.io/gengo v0.0.0-20200205140755-e0e292d8aa12 h1:pZzawYyz6VRNPVYpqGv61LWCimQv1BihyeqFrp50/G4= k8s.io/gengo v0.0.0-20200205140755-e0e292d8aa12/go.mod h1:ezvh/TsK7cY6rbqRK0oQQ8IAqLxYwwyPxAX1Pzy0ii0= +k8s.io/klog v1.0.0 h1:Pt+yjF5aB1xDSVbau4VsWe+dQNzA0qv1LlXdC2dF6Q8= k8s.io/klog v1.0.0/go.mod h1:4Bi6QPql/J/LkTDqv7R/cd3hPo4k2DG6Ptcz060Ez5I= k8s.io/kube-openapi v0.0.0-20190228160746-b3a7cee44a30 h1:TRb4wNWoBVrH9plmkp2q86FIDppkbrEXdXlxU3a3BMI= k8s.io/kube-openapi v0.0.0-20190228160746-b3a7cee44a30/go.mod h1:BXM9ceUBTj2QnfH2MK1odQs778ajze1RxcmP6S8RVVc= diff --git a/staging/src/k8s.io/node-api/go.sum b/staging/src/k8s.io/node-api/go.sum index 3c7116db8c9..237ff21faaa 100644 --- a/staging/src/k8s.io/node-api/go.sum +++ b/staging/src/k8s.io/node-api/go.sum @@ -35,6 +35,7 @@ github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+ github.com/googleapis/gnostic v0.0.0-20170729233727-0c5108395e2d h1:7XGaL1e6bYS1yIonGp9761ExpPPV1ui0SAC59Yube9k= github.com/googleapis/gnostic v0.0.0-20170729233727-0c5108395e2d/go.mod h1:sJBsCZ4ayReDTBIg8b9dl28c5xFWyhBTVRp3pOg5EKY= github.com/gophercloud/gophercloud v0.6.0/go.mod h1:GICNByuaEBibcjmjvI7QvYJSZEbGkcYwAR7EZK2WMqM= +github.com/grafov/bcast v0.0.0-20190217190352-1447f067e08d h1:Q2+KsA/1GLC9xyLsDun3/EOJ+83rY/IHRsO1DToPrdo= github.com/grafov/bcast v0.0.0-20190217190352-1447f067e08d/go.mod h1:RInr+B3/Tx70hYm0rpNPMTD7vH0pBG5ny/JsHAs2KcQ= github.com/gregjones/httpcache v0.0.0-20180305231024-9cad4c3443a7/go.mod h1:FecbI9+v66THATjSRHfNgh1IVFe/9kFxbXtjV0ctIMA= github.com/hashicorp/golang-lru v0.5.0 h1:CL2msUPvZTLb5O648aiLNJw3hnBxN2+1Jq8rCOH9wdo= @@ -116,6 +117,7 @@ google.golang.org/appengine v1.5.0 h1:KxkO13IPW4Lslp2bz+KHP2E3gtFlrIGNThxkZQ3g+4 google.golang.org/appengine v1.5.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 h1:qIbj1fsPNlZgppZ+VLlY7N33q108Sa+fhmuc+sWQYwY= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/fatih/set.v0 v0.2.1 h1:Xvyyp7LXu34P0ROhCyfXkmQCAoOUKb1E2JS9I7SE5CY= gopkg.in/fatih/set.v0 v0.2.1/go.mod h1:5eLWEndGL4zGGemXWrKuts+wTJR0y+w+auqUJZbmyBg= gopkg.in/fsnotify.v1 v1.4.7 h1:xOHLXZwVvI9hhs+cLKq5+I5onOuwQLhQwiu63xxlHs4= gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys= @@ -131,6 +133,7 @@ gopkg.in/yaml.v2 v2.2.8 h1:obN1ZagJSUGI0Ek/LBmuj4SNLPfIny3KsKFopxRdj10= gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= k8s.io/gengo v0.0.0-20200205140755-e0e292d8aa12 h1:pZzawYyz6VRNPVYpqGv61LWCimQv1BihyeqFrp50/G4= k8s.io/gengo v0.0.0-20200205140755-e0e292d8aa12/go.mod h1:ezvh/TsK7cY6rbqRK0oQQ8IAqLxYwwyPxAX1Pzy0ii0= +k8s.io/klog v1.0.0 h1:Pt+yjF5aB1xDSVbau4VsWe+dQNzA0qv1LlXdC2dF6Q8= k8s.io/klog v1.0.0/go.mod h1:4Bi6QPql/J/LkTDqv7R/cd3hPo4k2DG6Ptcz060Ez5I= k8s.io/kube-openapi v0.0.0-20190228160746-b3a7cee44a30 h1:TRb4wNWoBVrH9plmkp2q86FIDppkbrEXdXlxU3a3BMI= k8s.io/kube-openapi v0.0.0-20190228160746-b3a7cee44a30/go.mod h1:BXM9ceUBTj2QnfH2MK1odQs778ajze1RxcmP6S8RVVc= diff --git a/staging/src/k8s.io/sample-apiserver/go.mod b/staging/src/k8s.io/sample-apiserver/go.mod index a4f3dedb754..5087df4ca53 100644 --- a/staging/src/k8s.io/sample-apiserver/go.mod +++ b/staging/src/k8s.io/sample-apiserver/go.mod @@ -24,7 +24,6 @@ replace ( github.com/google/gofuzz => github.com/google/gofuzz v0.0.0-20170612174753-24818f796faf github.com/googleapis/gnostic => github.com/googleapis/gnostic v0.0.0-20170729233727-0c5108395e2d github.com/grpc-ecosystem/go-grpc-middleware => github.com/grpc-ecosystem/go-grpc-middleware v0.0.0-20190222133341-cfaf5686ec79 - github.com/grpc-ecosystem/go-grpc-prometheus => github.com/grpc-ecosystem/go-grpc-prometheus v0.0.0-20170330212424-2500245aa611 github.com/grpc-ecosystem/grpc-gateway => github.com/grpc-ecosystem/grpc-gateway v1.3.0 github.com/hashicorp/golang-lru => github.com/hashicorp/golang-lru v0.5.0 github.com/jonboulle/clockwork => github.com/jonboulle/clockwork v0.0.0-20141017032234-72f9bd7c4e0c diff --git a/staging/src/k8s.io/sample-apiserver/go.sum b/staging/src/k8s.io/sample-apiserver/go.sum index 0538e10dce0..872824fe16b 100644 --- a/staging/src/k8s.io/sample-apiserver/go.sum +++ b/staging/src/k8s.io/sample-apiserver/go.sum @@ -23,11 +23,13 @@ github.com/bgentry/speakeasy v0.1.0/go.mod h1:+zsyZBPWlz7T6j88CTgSN5bM796AkVf0kB github.com/blang/semver v3.5.0+incompatible/go.mod h1:kRBLl5iJ+tD4TcOOxsy/0fnwebNt5EWlYSAyrTnjyyk= github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= +github.com/cockroachdb/datadriven v0.0.0-20190809214429-80d97fb3cbaa h1:OaNxuTZr7kxeODyLWsRMC+OD03aFUH+mW6r2d+MWa5Y= github.com/cockroachdb/datadriven v0.0.0-20190809214429-80d97fb3cbaa/go.mod h1:zn76sxSg3SzpJ0PPJaLDCu+Bu0Lg3sKTORVIj19EIF8= github.com/coreos/etcd v3.3.10+incompatible/go.mod h1:uF7uidLiAD3TWHmW31ZFd/JWoc32PjwdhPthX9715RE= github.com/coreos/go-etcd v2.0.0+incompatible/go.mod h1:Jez6KQU2B/sWsbdaef3ED8NzMklzPG4d5KIOhIy30Tk= github.com/coreos/go-oidc v0.0.0-20180117170138-065b426bd416/go.mod h1:CgnwVTmzoESiwO9qyAFEMiHoZ1nMCKZlZ9V6mm3/LKc= github.com/coreos/go-semver v0.2.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk= +github.com/coreos/go-semver v0.3.0 h1:wkHLiw0WNATZnSG7epLsujiMCgPAc9xhjJ4tgnAxmfM= github.com/coreos/go-semver v0.3.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk= github.com/coreos/go-systemd v0.0.0-20180511133405-39ca1b05acc7 h1:u9SHYsPQNyt5tgDm3YN7+9dYrpK96E5wFilTFWIDZOM= github.com/coreos/go-systemd v0.0.0-20180511133405-39ca1b05acc7/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4= @@ -46,6 +48,7 @@ github.com/dgrijalva/jwt-go v0.0.0-20160705203006-01aeca54ebda/go.mod h1:E3ru+11 github.com/docker/docker v0.7.3-0.20190327010347-be7ac8be2ae0/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk= github.com/docker/spdystream v0.0.0-20160310174837-449fdfce4d96/go.mod h1:Qh8CwZgvJUkLughtfhJv5dyTYa91l1fOUCrgjqmcifM= github.com/dustin/go-humanize v0.0.0-20171111073723-bb3d318650d4/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk= +github.com/dustin/go-humanize v1.0.0 h1:VSnTsYCnlFHaM2/igO1h6X3HA71jcobQuxemgkq4zYo= github.com/dustin/go-humanize v1.0.0/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk= github.com/elazarl/goproxy v0.0.0-20180725130230-947c36da3153/go.mod h1:/Zj4wYkgs4iZTTu3o/KG3Itv/qCCa8VVMlb3i9OVuzc= github.com/emicklei/go-restful v2.9.5+incompatible h1:spTtZBk5DYEvbxMVutUuTyh1Ao2r4iyvLdACqsl/Ljk= @@ -82,6 +85,7 @@ github.com/golang/protobuf v1.2.0 h1:P3YflyNX/ehuJFLhxviNdFxQPkGK5cDcApsge1SqnvM github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/golang/protobuf v1.3.2 h1:6nsPYzhq5kReh6QImI3k5qWzO4PEbvbIW2cwSfR/6xs= github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= +github.com/google/btree v1.0.0 h1:0udJVsspx3VBr5FwtLhQQtuAsVc79tTq0ocGIPAU6qo= github.com/google/btree v1.0.0/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M= github.com/google/go-cmp v0.3.0 h1:crn/baboCvb5fXaQ0IJ1SGTsTVrWpDsCWC8EGETZijY= @@ -99,12 +103,13 @@ github.com/gorilla/websocket v0.0.0-20170926233335-4201258b820c h1:Lh2aW+HnU2Nbe github.com/gorilla/websocket v0.0.0-20170926233335-4201258b820c/go.mod h1:E7qHFY5m1UJ88s3WnNqhKjPHQ0heANvMoAMk2YaljkQ= github.com/gorilla/websocket v1.4.0 h1:WDFjx/TMzVgy9VdMMQi2K2Emtwi2QcUQsztZ/zLaH/Q= github.com/gorilla/websocket v1.4.0/go.mod h1:E7qHFY5m1UJ88s3WnNqhKjPHQ0heANvMoAMk2YaljkQ= +github.com/grafov/bcast v0.0.0-20190217190352-1447f067e08d h1:Q2+KsA/1GLC9xyLsDun3/EOJ+83rY/IHRsO1DToPrdo= github.com/grafov/bcast v0.0.0-20190217190352-1447f067e08d/go.mod h1:RInr+B3/Tx70hYm0rpNPMTD7vH0pBG5ny/JsHAs2KcQ= github.com/gregjones/httpcache v0.0.0-20180305231024-9cad4c3443a7/go.mod h1:FecbI9+v66THATjSRHfNgh1IVFe/9kFxbXtjV0ctIMA= github.com/grpc-ecosystem/go-grpc-middleware v0.0.0-20190222133341-cfaf5686ec79 h1:lR9ssWAqp9qL0bALxqEEkuudiP1eweOdv9jsRK3e7lE= github.com/grpc-ecosystem/go-grpc-middleware v0.0.0-20190222133341-cfaf5686ec79/go.mod h1:FiyG127CGDf3tlThmgyCl78X/SZQqEOJBCDaAfeWzPs= -github.com/grpc-ecosystem/go-grpc-prometheus v0.0.0-20170330212424-2500245aa611 h1:f5vL2EW5pL274ztMNnizZAEa457nKyKPEaN/sm/kdBk= -github.com/grpc-ecosystem/go-grpc-prometheus v0.0.0-20170330212424-2500245aa611/go.mod h1:8NvIoxWQoOIhqOTXgfV/d3M/q6VIi02HzZEHgUlZvzk= +github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0 h1:Ovs26xHkKqVztRpIrF/92BcuyuQ/YW4NSIpoGtfXNho= +github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0/go.mod h1:8NvIoxWQoOIhqOTXgfV/d3M/q6VIi02HzZEHgUlZvzk= github.com/grpc-ecosystem/grpc-gateway v1.3.0 h1:HJtP6RRwj2EpPCD/mhAWzSvLL/dFTdPm1UrWwanoFos= github.com/grpc-ecosystem/grpc-gateway v1.3.0/go.mod h1:RSKVYQBd5MCa4OVpNdGskqpgL2+G+NZTnrVHpWWfpdw= github.com/hashicorp/golang-lru v0.5.0 h1:CL2msUPvZTLb5O648aiLNJw3hnBxN2+1Jq8rCOH9wdo= @@ -210,7 +215,9 @@ github.com/urfave/cli v1.20.0/go.mod h1:70zkFmudgCuE/ngEzBv17Jvp/497gISqfk5gWijb github.com/xiang90/probing v0.0.0-20160813154853-07dd2e8dfe18 h1:MPPkRncZLN9Kh4MEFmbnK4h3BD7AUmskWv2+EeZJCCs= github.com/xiang90/probing v0.0.0-20160813154853-07dd2e8dfe18/go.mod h1:UETIi67q53MR2AWcXfiuqkDkRtnGDLqkBTpCHuJHxtU= github.com/xordataexchange/crypt v0.0.3-0.20170626215501-b2862e3d0a77/go.mod h1:aYKd//L2LvnjZzWKhF00oedf4jCCReLcmhLdhm1A27Q= +go.etcd.io/bbolt v1.3.3 h1:MUGmc65QhB3pIlaQ5bB4LwqSj6GIonVJXpZiaKNyaKk= go.etcd.io/bbolt v1.3.3/go.mod h1:IbVyRI1SCnLcuJnV2u8VeU0CEYM7e686BmAb1XKL+uU= +go.etcd.io/etcd v0.5.0-alpha.5.0.20200224211402-c65a9e2dd1fd h1:JwlSZ9TSTcRHDGbIr5QG3MEmKyMK99BbNLMJtwnJ0rY= go.etcd.io/etcd v0.5.0-alpha.5.0.20200224211402-c65a9e2dd1fd/go.mod h1:dnLIgRNXwCJa5e+c6mIZCrds/GIG4ncV9HhK5PX7jPg= go.uber.org/atomic v0.0.0-20181018215023-8dc6146f7569 h1:nSQar3Y0E3VQF/VdZ8PTAilaXpER+d7ypdABCrpwMdg= go.uber.org/atomic v0.0.0-20181018215023-8dc6146f7569/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE= @@ -291,6 +298,7 @@ google.golang.org/grpc v1.26.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8 gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 h1:qIbj1fsPNlZgppZ+VLlY7N33q108Sa+fhmuc+sWQYwY= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/cheggaaa/pb.v1 v1.0.25/go.mod h1:V/YB90LKu/1FcN3WVnfiiE5oMCibMjukxqG/qStrOgw= +gopkg.in/fatih/set.v0 v0.2.1 h1:Xvyyp7LXu34P0ROhCyfXkmQCAoOUKb1E2JS9I7SE5CY= gopkg.in/fatih/set.v0 v0.2.1/go.mod h1:5eLWEndGL4zGGemXWrKuts+wTJR0y+w+auqUJZbmyBg= gopkg.in/fsnotify.v1 v1.4.7 h1:xOHLXZwVvI9hhs+cLKq5+I5onOuwQLhQwiu63xxlHs4= gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys= @@ -312,6 +320,7 @@ honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWh honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= k8s.io/gengo v0.0.0-20200205140755-e0e292d8aa12 h1:pZzawYyz6VRNPVYpqGv61LWCimQv1BihyeqFrp50/G4= k8s.io/gengo v0.0.0-20200205140755-e0e292d8aa12/go.mod h1:ezvh/TsK7cY6rbqRK0oQQ8IAqLxYwwyPxAX1Pzy0ii0= +k8s.io/klog v1.0.0 h1:Pt+yjF5aB1xDSVbau4VsWe+dQNzA0qv1LlXdC2dF6Q8= k8s.io/klog v1.0.0/go.mod h1:4Bi6QPql/J/LkTDqv7R/cd3hPo4k2DG6Ptcz060Ez5I= k8s.io/kube-openapi v0.0.0-20190228160746-b3a7cee44a30 h1:TRb4wNWoBVrH9plmkp2q86FIDppkbrEXdXlxU3a3BMI= k8s.io/kube-openapi v0.0.0-20190228160746-b3a7cee44a30/go.mod h1:BXM9ceUBTj2QnfH2MK1odQs778ajze1RxcmP6S8RVVc= @@ -322,7 +331,7 @@ modernc.org/golex v1.0.0/go.mod h1:b/QX9oBD/LhixY6NDh+IdGv17hgB+51fET1i2kPSmvk= modernc.org/mathutil v1.0.0/go.mod h1:wU0vUrJsVWBZ4P6e7xtFJEhFSNsfRLJ8H458uRjg03k= modernc.org/strutil v1.0.0/go.mod h1:lstksw84oURvj9y3tn8lGvRxyRC1S2+g5uuIzNfIOBs= modernc.org/xc v1.0.0/go.mod h1:mRNCo0bvLjGhHO9WsyuKVU4q0ceiDDDoEeWDJHrNx8I= -sigs.k8s.io/structured-merge-diff v0.0.0-20190302045857-e85c7b244fd2 h1:9r5DY45ef9LtcA6BnkhW8MPV7OKAfbf2AUwUhq3LeRk= -sigs.k8s.io/structured-merge-diff v0.0.0-20190302045857-e85c7b244fd2/go.mod h1:wWxsB5ozmmv/SG7nM11ayaAW51xMvak/t1r0CSlcokI= +sigs.k8s.io/structured-merge-diff v0.0.0-20190719182312-e94e05bfbbe3 h1:yCY9zAYErawYwXdOYmwEBzcGCr/6eIUujYZE2DIQve8= +sigs.k8s.io/structured-merge-diff v0.0.0-20190719182312-e94e05bfbbe3/go.mod h1:wWxsB5ozmmv/SG7nM11ayaAW51xMvak/t1r0CSlcokI= sigs.k8s.io/yaml v1.1.0 h1:4A07+ZFc2wgJwo8YNlQpr1rVlgUDlxXHhPJciaPY5gs= sigs.k8s.io/yaml v1.1.0/go.mod h1:UJmg0vDUVViEyp3mgSv9WPwZCDxu4rQW1olrI1uml+o= diff --git a/staging/src/k8s.io/sample-cli-plugin/go.sum b/staging/src/k8s.io/sample-cli-plugin/go.sum index ec5234ae197..e7e7c52184f 100644 --- a/staging/src/k8s.io/sample-cli-plugin/go.sum +++ b/staging/src/k8s.io/sample-cli-plugin/go.sum @@ -50,6 +50,7 @@ github.com/golang/protobuf v1.2.0 h1:P3YflyNX/ehuJFLhxviNdFxQPkGK5cDcApsge1SqnvM github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/golang/protobuf v1.3.2 h1:6nsPYzhq5kReh6QImI3k5qWzO4PEbvbIW2cwSfR/6xs= github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= +github.com/google/btree v1.0.0 h1:0udJVsspx3VBr5FwtLhQQtuAsVc79tTq0ocGIPAU6qo= github.com/google/btree v1.0.0/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= github.com/google/go-cmp v0.3.0 h1:crn/baboCvb5fXaQ0IJ1SGTsTVrWpDsCWC8EGETZijY= github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= @@ -59,6 +60,7 @@ github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+ github.com/googleapis/gnostic v0.0.0-20170729233727-0c5108395e2d h1:7XGaL1e6bYS1yIonGp9761ExpPPV1ui0SAC59Yube9k= github.com/googleapis/gnostic v0.0.0-20170729233727-0c5108395e2d/go.mod h1:sJBsCZ4ayReDTBIg8b9dl28c5xFWyhBTVRp3pOg5EKY= github.com/gophercloud/gophercloud v0.6.0/go.mod h1:GICNByuaEBibcjmjvI7QvYJSZEbGkcYwAR7EZK2WMqM= +github.com/grafov/bcast v0.0.0-20190217190352-1447f067e08d h1:Q2+KsA/1GLC9xyLsDun3/EOJ+83rY/IHRsO1DToPrdo= github.com/grafov/bcast v0.0.0-20190217190352-1447f067e08d/go.mod h1:RInr+B3/Tx70hYm0rpNPMTD7vH0pBG5ny/JsHAs2KcQ= github.com/gregjones/httpcache v0.0.0-20180305231024-9cad4c3443a7 h1:pdN6V1QBWetyv/0+wjACpqVH+eVULgEjkurDLq3goeM= github.com/gregjones/httpcache v0.0.0-20180305231024-9cad4c3443a7/go.mod h1:FecbI9+v66THATjSRHfNgh1IVFe/9kFxbXtjV0ctIMA= @@ -155,6 +157,7 @@ google.golang.org/appengine v1.5.0 h1:KxkO13IPW4Lslp2bz+KHP2E3gtFlrIGNThxkZQ3g+4 google.golang.org/appengine v1.5.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 h1:qIbj1fsPNlZgppZ+VLlY7N33q108Sa+fhmuc+sWQYwY= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/fatih/set.v0 v0.2.1 h1:Xvyyp7LXu34P0ROhCyfXkmQCAoOUKb1E2JS9I7SE5CY= gopkg.in/fatih/set.v0 v0.2.1/go.mod h1:5eLWEndGL4zGGemXWrKuts+wTJR0y+w+auqUJZbmyBg= gopkg.in/fsnotify.v1 v1.4.7 h1:xOHLXZwVvI9hhs+cLKq5+I5onOuwQLhQwiu63xxlHs4= gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys= @@ -168,6 +171,7 @@ gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.8 h1:obN1ZagJSUGI0Ek/LBmuj4SNLPfIny3KsKFopxRdj10= gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +k8s.io/klog v1.0.0 h1:Pt+yjF5aB1xDSVbau4VsWe+dQNzA0qv1LlXdC2dF6Q8= k8s.io/klog v1.0.0/go.mod h1:4Bi6QPql/J/LkTDqv7R/cd3hPo4k2DG6Ptcz060Ez5I= k8s.io/kube-openapi v0.0.0-20190228160746-b3a7cee44a30 h1:TRb4wNWoBVrH9plmkp2q86FIDppkbrEXdXlxU3a3BMI= k8s.io/kube-openapi v0.0.0-20190228160746-b3a7cee44a30/go.mod h1:BXM9ceUBTj2QnfH2MK1odQs778ajze1RxcmP6S8RVVc= diff --git a/staging/src/k8s.io/sample-controller/go.sum b/staging/src/k8s.io/sample-controller/go.sum index 6c270cdc693..914e43a1328 100644 --- a/staging/src/k8s.io/sample-controller/go.sum +++ b/staging/src/k8s.io/sample-controller/go.sum @@ -35,6 +35,7 @@ github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+ github.com/googleapis/gnostic v0.0.0-20170729233727-0c5108395e2d h1:7XGaL1e6bYS1yIonGp9761ExpPPV1ui0SAC59Yube9k= github.com/googleapis/gnostic v0.0.0-20170729233727-0c5108395e2d/go.mod h1:sJBsCZ4ayReDTBIg8b9dl28c5xFWyhBTVRp3pOg5EKY= github.com/gophercloud/gophercloud v0.6.0/go.mod h1:GICNByuaEBibcjmjvI7QvYJSZEbGkcYwAR7EZK2WMqM= +github.com/grafov/bcast v0.0.0-20190217190352-1447f067e08d h1:Q2+KsA/1GLC9xyLsDun3/EOJ+83rY/IHRsO1DToPrdo= github.com/grafov/bcast v0.0.0-20190217190352-1447f067e08d/go.mod h1:RInr+B3/Tx70hYm0rpNPMTD7vH0pBG5ny/JsHAs2KcQ= github.com/gregjones/httpcache v0.0.0-20180305231024-9cad4c3443a7/go.mod h1:FecbI9+v66THATjSRHfNgh1IVFe/9kFxbXtjV0ctIMA= github.com/hashicorp/golang-lru v0.5.0 h1:CL2msUPvZTLb5O648aiLNJw3hnBxN2+1Jq8rCOH9wdo= @@ -117,6 +118,7 @@ google.golang.org/appengine v1.5.0 h1:KxkO13IPW4Lslp2bz+KHP2E3gtFlrIGNThxkZQ3g+4 google.golang.org/appengine v1.5.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 h1:qIbj1fsPNlZgppZ+VLlY7N33q108Sa+fhmuc+sWQYwY= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/fatih/set.v0 v0.2.1 h1:Xvyyp7LXu34P0ROhCyfXkmQCAoOUKb1E2JS9I7SE5CY= gopkg.in/fatih/set.v0 v0.2.1/go.mod h1:5eLWEndGL4zGGemXWrKuts+wTJR0y+w+auqUJZbmyBg= gopkg.in/fsnotify.v1 v1.4.7 h1:xOHLXZwVvI9hhs+cLKq5+I5onOuwQLhQwiu63xxlHs4= gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys= @@ -132,6 +134,7 @@ gopkg.in/yaml.v2 v2.2.8 h1:obN1ZagJSUGI0Ek/LBmuj4SNLPfIny3KsKFopxRdj10= gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= k8s.io/gengo v0.0.0-20200205140755-e0e292d8aa12 h1:pZzawYyz6VRNPVYpqGv61LWCimQv1BihyeqFrp50/G4= k8s.io/gengo v0.0.0-20200205140755-e0e292d8aa12/go.mod h1:ezvh/TsK7cY6rbqRK0oQQ8IAqLxYwwyPxAX1Pzy0ii0= +k8s.io/klog v1.0.0 h1:Pt+yjF5aB1xDSVbau4VsWe+dQNzA0qv1LlXdC2dF6Q8= k8s.io/klog v1.0.0/go.mod h1:4Bi6QPql/J/LkTDqv7R/cd3hPo4k2DG6Ptcz060Ez5I= k8s.io/kube-openapi v0.0.0-20190228160746-b3a7cee44a30 h1:TRb4wNWoBVrH9plmkp2q86FIDppkbrEXdXlxU3a3BMI= k8s.io/kube-openapi v0.0.0-20190228160746-b3a7cee44a30/go.mod h1:BXM9ceUBTj2QnfH2MK1odQs778ajze1RxcmP6S8RVVc= diff --git a/vendor/github.com/grpc-ecosystem/go-grpc-prometheus/.gitignore b/vendor/github.com/grpc-ecosystem/go-grpc-prometheus/.gitignore index 364c624e63d..2233cff9d1f 100644 --- a/vendor/github.com/grpc-ecosystem/go-grpc-prometheus/.gitignore +++ b/vendor/github.com/grpc-ecosystem/go-grpc-prometheus/.gitignore @@ -1,3 +1,6 @@ +#vendor +vendor/ + # Created by .ignore support plugin (hsz.mobi) coverage.txt ### Go template diff --git a/vendor/github.com/grpc-ecosystem/go-grpc-prometheus/.travis.yml b/vendor/github.com/grpc-ecosystem/go-grpc-prometheus/.travis.yml index 47d7f90b372..2a845b96aef 100644 --- a/vendor/github.com/grpc-ecosystem/go-grpc-prometheus/.travis.yml +++ b/vendor/github.com/grpc-ecosystem/go-grpc-prometheus/.travis.yml @@ -1,18 +1,25 @@ sudo: false language: go +# * github.com/grpc/grpc-go still supports go1.6 +# - When we drop support for go1.6 we can remove golang.org/x/net/context +# below as it is part of the Go std library since go1.7 +# * github.com/prometheus/client_golang already requires at least go1.7 since +# September 2017 go: - 1.6.x - 1.7.x - 1.8.x + - 1.9.x + - 1.10.x + - master install: - go get github.com/prometheus/client_golang/prometheus - go get google.golang.org/grpc - go get golang.org/x/net/context - go get github.com/stretchr/testify - script: - - ./test_all.sh + - make test after_success: - bash <(curl -s https://codecov.io/bash) diff --git a/vendor/github.com/grpc-ecosystem/go-grpc-prometheus/BUILD b/vendor/github.com/grpc-ecosystem/go-grpc-prometheus/BUILD index aaabadb14d3..543abafbca6 100644 --- a/vendor/github.com/grpc-ecosystem/go-grpc-prometheus/BUILD +++ b/vendor/github.com/grpc-ecosystem/go-grpc-prometheus/BUILD @@ -4,8 +4,11 @@ go_library( name = "go_default_library", srcs = [ "client.go", + "client_metrics.go", "client_reporter.go", + "metric_options.go", "server.go", + "server_metrics.go", "server_reporter.go", "util.go", ], @@ -17,6 +20,7 @@ go_library( "//vendor/golang.org/x/net/context:go_default_library", "//vendor/google.golang.org/grpc:go_default_library", "//vendor/google.golang.org/grpc/codes:go_default_library", + "//vendor/google.golang.org/grpc/status:go_default_library", ], ) diff --git a/vendor/github.com/grpc-ecosystem/go-grpc-prometheus/CHANGELOG.md b/vendor/github.com/grpc-ecosystem/go-grpc-prometheus/CHANGELOG.md new file mode 100644 index 00000000000..19a8059e1b5 --- /dev/null +++ b/vendor/github.com/grpc-ecosystem/go-grpc-prometheus/CHANGELOG.md @@ -0,0 +1,24 @@ +# Changelog +All notable changes to this project will be documented in this file. + +The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) +and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html). + +## [Unreleased] + +## [1.2.0](https://github.com/grpc-ecosystem/go-grpc-prometheus/releases/tag/v1.2.0) - 2018-06-04 + +### Added + +* Provide metrics object as `prometheus.Collector`, for conventional metric registration. +* Support non-default/global Prometheus registry. +* Allow configuring counters with `prometheus.CounterOpts`. + +### Changed + +* Remove usage of deprecated `grpc.Code()`. +* Remove usage of deprecated `grpc.Errorf` and replace with `status.Errorf`. + +--- + +This changelog was started with version `v1.2.0`, for earlier versions refer to the respective [GitHub releases](https://github.com/grpc-ecosystem/go-grpc-prometheus/releases). diff --git a/vendor/github.com/grpc-ecosystem/go-grpc-prometheus/README.md b/vendor/github.com/grpc-ecosystem/go-grpc-prometheus/README.md index 616547a78db..499c5835533 100644 --- a/vendor/github.com/grpc-ecosystem/go-grpc-prometheus/README.md +++ b/vendor/github.com/grpc-ecosystem/go-grpc-prometheus/README.md @@ -38,7 +38,7 @@ import "github.com/grpc-ecosystem/go-grpc-prometheus" // After all your registrations, make sure all of the Prometheus metrics are initialized. grpc_prometheus.Register(myServer) // Register Prometheus metrics handler. - http.Handle("/metrics", prometheus.Handler()) + http.Handle("/metrics", promhttp.Handler()) ... ``` @@ -49,8 +49,8 @@ import "github.com/grpc-ecosystem/go-grpc-prometheus" ... clientConn, err = grpc.Dial( address, - grpc.WithUnaryInterceptor(UnaryClientInterceptor), - grpc.WithStreamInterceptor(StreamClientInterceptor) + grpc.WithUnaryInterceptor(grpc_prometheus.UnaryClientInterceptor), + grpc.WithStreamInterceptor(grpc_prometheus.StreamClientInterceptor) ) client = pb_testproto.NewTestServiceClient(clientConn) resp, err := client.PingEmpty(s.ctx, &myservice.Request{Msg: "hello"}) @@ -118,7 +118,7 @@ each of the 20 messages sent back, a counter will be incremented: grpc_server_msg_sent_total{grpc_method="PingList",grpc_service="mwitkow.testproto.TestService",grpc_type="server_stream"} 20 ``` -After the call completes, it's status (`OK` or other [gRPC status code](https://github.com/grpc/grpc-go/blob/master/codes/codes.go)) +After the call completes, its status (`OK` or other [gRPC status code](https://github.com/grpc/grpc-go/blob/master/codes/codes.go)) and the relevant call labels increment the `grpc_server_handled_total` counter. ```jsoniq @@ -128,8 +128,8 @@ grpc_server_handled_total{grpc_code="OK",grpc_method="PingList",grpc_service="mw ## Histograms [Prometheus histograms](https://prometheus.io/docs/concepts/metric_types/#histogram) are a great way -to measure latency distributions of your RPCs. However since it is bad practice to have metrics -of [high cardinality](https://prometheus.io/docs/practices/instrumentation/#do-not-overuse-labels)) +to measure latency distributions of your RPCs. However, since it is bad practice to have metrics +of [high cardinality](https://prometheus.io/docs/practices/instrumentation/#do-not-overuse-labels) the latency monitoring metrics are disabled by default. To enable them please call the following in your server initialization code: @@ -137,8 +137,8 @@ in your server initialization code: grpc_prometheus.EnableHandlingTimeHistogram() ``` -After the call completes, it's handling time will be recorded in a [Prometheus histogram](https://prometheus.io/docs/concepts/metric_types/#histogram) -variable `grpc_server_handling_seconds`. It contains three sub-metrics: +After the call completes, its handling time will be recorded in a [Prometheus histogram](https://prometheus.io/docs/concepts/metric_types/#histogram) +variable `grpc_server_handling_seconds`. The histogram variable contains three sub-metrics: * `grpc_server_handling_seconds_count` - the count of all completed RPCs by status and method * `grpc_server_handling_seconds_sum` - cumulative time of RPCs by status and method, useful for @@ -168,7 +168,7 @@ grpc_server_handling_seconds_count{grpc_code="OK",grpc_method="PingList",grpc_se ## Useful query examples -Prometheus philosophy is to provide the most detailed metrics possible to the monitoring system, and +Prometheus philosophy is to provide raw metrics to the monitoring system, and let the aggregations be handled there. The verbosity of above metrics make it possible to have that flexibility. Here's a couple of useful monitoring queries: diff --git a/vendor/github.com/grpc-ecosystem/go-grpc-prometheus/client.go b/vendor/github.com/grpc-ecosystem/go-grpc-prometheus/client.go index d9e87b2f735..751a4c72d7e 100644 --- a/vendor/github.com/grpc-ecosystem/go-grpc-prometheus/client.go +++ b/vendor/github.com/grpc-ecosystem/go-grpc-prometheus/client.go @@ -6,67 +6,34 @@ package grpc_prometheus import ( - "io" - - "golang.org/x/net/context" - "google.golang.org/grpc" - "google.golang.org/grpc/codes" + prom "github.com/prometheus/client_golang/prometheus" ) -// UnaryClientInterceptor is a gRPC client-side interceptor that provides Prometheus monitoring for Unary RPCs. -func UnaryClientInterceptor(ctx context.Context, method string, req, reply interface{}, cc *grpc.ClientConn, invoker grpc.UnaryInvoker, opts ...grpc.CallOption) error { - monitor := newClientReporter(Unary, method) - monitor.SentMessage() - err := invoker(ctx, method, req, reply, cc, opts...) - if err != nil { - monitor.ReceivedMessage() - } - monitor.Handled(grpc.Code(err)) - return err -} +var ( + // DefaultClientMetrics is the default instance of ClientMetrics. It is + // intended to be used in conjunction the default Prometheus metrics + // registry. + DefaultClientMetrics = NewClientMetrics() -// StreamServerInterceptor is a gRPC client-side interceptor that provides Prometheus monitoring for Streaming RPCs. -func StreamClientInterceptor(ctx context.Context, desc *grpc.StreamDesc, cc *grpc.ClientConn, method string, streamer grpc.Streamer, opts ...grpc.CallOption) (grpc.ClientStream, error) { - monitor := newClientReporter(clientStreamType(desc), method) - clientStream, err := streamer(ctx, desc, cc, method, opts...) - if err != nil { - monitor.Handled(grpc.Code(err)) - return nil, err - } - return &monitoredClientStream{clientStream, monitor}, nil -} + // UnaryClientInterceptor is a gRPC client-side interceptor that provides Prometheus monitoring for Unary RPCs. + UnaryClientInterceptor = DefaultClientMetrics.UnaryClientInterceptor() -func clientStreamType(desc *grpc.StreamDesc) grpcType { - if desc.ClientStreams && !desc.ServerStreams { - return ClientStream - } else if !desc.ClientStreams && desc.ServerStreams { - return ServerStream - } - return BidiStream -} - -// monitoredClientStream wraps grpc.ClientStream allowing each Sent/Recv of message to increment counters. -type monitoredClientStream struct { - grpc.ClientStream - monitor *clientReporter -} + // StreamClientInterceptor is a gRPC client-side interceptor that provides Prometheus monitoring for Streaming RPCs. + StreamClientInterceptor = DefaultClientMetrics.StreamClientInterceptor() +) -func (s *monitoredClientStream) SendMsg(m interface{}) error { - err := s.ClientStream.SendMsg(m) - if err == nil { - s.monitor.SentMessage() - } - return err +func init() { + prom.MustRegister(DefaultClientMetrics.clientStartedCounter) + prom.MustRegister(DefaultClientMetrics.clientHandledCounter) + prom.MustRegister(DefaultClientMetrics.clientStreamMsgReceived) + prom.MustRegister(DefaultClientMetrics.clientStreamMsgSent) } -func (s *monitoredClientStream) RecvMsg(m interface{}) error { - err := s.ClientStream.RecvMsg(m) - if err == nil { - s.monitor.ReceivedMessage() - } else if err == io.EOF { - s.monitor.Handled(codes.OK) - } else { - s.monitor.Handled(grpc.Code(err)) - } - return err +// EnableClientHandlingTimeHistogram turns on recording of handling time of +// RPCs. Histogram metrics can be very expensive for Prometheus to retain and +// query. This function acts on the DefaultClientMetrics variable and the +// default Prometheus metrics registry. +func EnableClientHandlingTimeHistogram(opts ...HistogramOption) { + DefaultClientMetrics.EnableClientHandlingTimeHistogram(opts...) + prom.Register(DefaultClientMetrics.clientHandledHistogram) } diff --git a/vendor/github.com/grpc-ecosystem/go-grpc-prometheus/client_metrics.go b/vendor/github.com/grpc-ecosystem/go-grpc-prometheus/client_metrics.go new file mode 100644 index 00000000000..9b476f9832c --- /dev/null +++ b/vendor/github.com/grpc-ecosystem/go-grpc-prometheus/client_metrics.go @@ -0,0 +1,170 @@ +package grpc_prometheus + +import ( + "io" + + prom "github.com/prometheus/client_golang/prometheus" + "golang.org/x/net/context" + "google.golang.org/grpc" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/status" +) + +// ClientMetrics represents a collection of metrics to be registered on a +// Prometheus metrics registry for a gRPC client. +type ClientMetrics struct { + clientStartedCounter *prom.CounterVec + clientHandledCounter *prom.CounterVec + clientStreamMsgReceived *prom.CounterVec + clientStreamMsgSent *prom.CounterVec + clientHandledHistogramEnabled bool + clientHandledHistogramOpts prom.HistogramOpts + clientHandledHistogram *prom.HistogramVec +} + +// NewClientMetrics returns a ClientMetrics object. Use a new instance of +// ClientMetrics when not using the default Prometheus metrics registry, for +// example when wanting to control which metrics are added to a registry as +// opposed to automatically adding metrics via init functions. +func NewClientMetrics(counterOpts ...CounterOption) *ClientMetrics { + opts := counterOptions(counterOpts) + return &ClientMetrics{ + clientStartedCounter: prom.NewCounterVec( + opts.apply(prom.CounterOpts{ + Name: "grpc_client_started_total", + Help: "Total number of RPCs started on the client.", + }), []string{"grpc_type", "grpc_service", "grpc_method"}), + + clientHandledCounter: prom.NewCounterVec( + opts.apply(prom.CounterOpts{ + Name: "grpc_client_handled_total", + Help: "Total number of RPCs completed by the client, regardless of success or failure.", + }), []string{"grpc_type", "grpc_service", "grpc_method", "grpc_code"}), + + clientStreamMsgReceived: prom.NewCounterVec( + opts.apply(prom.CounterOpts{ + Name: "grpc_client_msg_received_total", + Help: "Total number of RPC stream messages received by the client.", + }), []string{"grpc_type", "grpc_service", "grpc_method"}), + + clientStreamMsgSent: prom.NewCounterVec( + opts.apply(prom.CounterOpts{ + Name: "grpc_client_msg_sent_total", + Help: "Total number of gRPC stream messages sent by the client.", + }), []string{"grpc_type", "grpc_service", "grpc_method"}), + + clientHandledHistogramEnabled: false, + clientHandledHistogramOpts: prom.HistogramOpts{ + Name: "grpc_client_handling_seconds", + Help: "Histogram of response latency (seconds) of the gRPC until it is finished by the application.", + Buckets: prom.DefBuckets, + }, + clientHandledHistogram: nil, + } +} + +// Describe sends the super-set of all possible descriptors of metrics +// collected by this Collector to the provided channel and returns once +// the last descriptor has been sent. +func (m *ClientMetrics) Describe(ch chan<- *prom.Desc) { + m.clientStartedCounter.Describe(ch) + m.clientHandledCounter.Describe(ch) + m.clientStreamMsgReceived.Describe(ch) + m.clientStreamMsgSent.Describe(ch) + if m.clientHandledHistogramEnabled { + m.clientHandledHistogram.Describe(ch) + } +} + +// Collect is called by the Prometheus registry when collecting +// metrics. The implementation sends each collected metric via the +// provided channel and returns once the last metric has been sent. +func (m *ClientMetrics) Collect(ch chan<- prom.Metric) { + m.clientStartedCounter.Collect(ch) + m.clientHandledCounter.Collect(ch) + m.clientStreamMsgReceived.Collect(ch) + m.clientStreamMsgSent.Collect(ch) + if m.clientHandledHistogramEnabled { + m.clientHandledHistogram.Collect(ch) + } +} + +// EnableClientHandlingTimeHistogram turns on recording of handling time of RPCs. +// Histogram metrics can be very expensive for Prometheus to retain and query. +func (m *ClientMetrics) EnableClientHandlingTimeHistogram(opts ...HistogramOption) { + for _, o := range opts { + o(&m.clientHandledHistogramOpts) + } + if !m.clientHandledHistogramEnabled { + m.clientHandledHistogram = prom.NewHistogramVec( + m.clientHandledHistogramOpts, + []string{"grpc_type", "grpc_service", "grpc_method"}, + ) + } + m.clientHandledHistogramEnabled = true +} + +// UnaryClientInterceptor is a gRPC client-side interceptor that provides Prometheus monitoring for Unary RPCs. +func (m *ClientMetrics) UnaryClientInterceptor() func(ctx context.Context, method string, req, reply interface{}, cc *grpc.ClientConn, invoker grpc.UnaryInvoker, opts ...grpc.CallOption) error { + return func(ctx context.Context, method string, req, reply interface{}, cc *grpc.ClientConn, invoker grpc.UnaryInvoker, opts ...grpc.CallOption) error { + monitor := newClientReporter(m, Unary, method) + monitor.SentMessage() + err := invoker(ctx, method, req, reply, cc, opts...) + if err != nil { + monitor.ReceivedMessage() + } + st, _ := status.FromError(err) + monitor.Handled(st.Code()) + return err + } +} + +// StreamClientInterceptor is a gRPC client-side interceptor that provides Prometheus monitoring for Streaming RPCs. +func (m *ClientMetrics) StreamClientInterceptor() func(ctx context.Context, desc *grpc.StreamDesc, cc *grpc.ClientConn, method string, streamer grpc.Streamer, opts ...grpc.CallOption) (grpc.ClientStream, error) { + return func(ctx context.Context, desc *grpc.StreamDesc, cc *grpc.ClientConn, method string, streamer grpc.Streamer, opts ...grpc.CallOption) (grpc.ClientStream, error) { + monitor := newClientReporter(m, clientStreamType(desc), method) + clientStream, err := streamer(ctx, desc, cc, method, opts...) + if err != nil { + st, _ := status.FromError(err) + monitor.Handled(st.Code()) + return nil, err + } + return &monitoredClientStream{clientStream, monitor}, nil + } +} + +func clientStreamType(desc *grpc.StreamDesc) grpcType { + if desc.ClientStreams && !desc.ServerStreams { + return ClientStream + } else if !desc.ClientStreams && desc.ServerStreams { + return ServerStream + } + return BidiStream +} + +// monitoredClientStream wraps grpc.ClientStream allowing each Sent/Recv of message to increment counters. +type monitoredClientStream struct { + grpc.ClientStream + monitor *clientReporter +} + +func (s *monitoredClientStream) SendMsg(m interface{}) error { + err := s.ClientStream.SendMsg(m) + if err == nil { + s.monitor.SentMessage() + } + return err +} + +func (s *monitoredClientStream) RecvMsg(m interface{}) error { + err := s.ClientStream.RecvMsg(m) + if err == nil { + s.monitor.ReceivedMessage() + } else if err == io.EOF { + s.monitor.Handled(codes.OK) + } else { + st, _ := status.FromError(err) + s.monitor.Handled(st.Code()) + } + return err +} diff --git a/vendor/github.com/grpc-ecosystem/go-grpc-prometheus/client_reporter.go b/vendor/github.com/grpc-ecosystem/go-grpc-prometheus/client_reporter.go index 16b76155302..cbf15322996 100644 --- a/vendor/github.com/grpc-ecosystem/go-grpc-prometheus/client_reporter.go +++ b/vendor/github.com/grpc-ecosystem/go-grpc-prometheus/client_reporter.go @@ -7,105 +7,40 @@ import ( "time" "google.golang.org/grpc/codes" - - prom "github.com/prometheus/client_golang/prometheus" -) - -var ( - clientStartedCounter = prom.NewCounterVec( - prom.CounterOpts{ - Namespace: "grpc", - Subsystem: "client", - Name: "started_total", - Help: "Total number of RPCs started on the client.", - }, []string{"grpc_type", "grpc_service", "grpc_method"}) - - clientHandledCounter = prom.NewCounterVec( - prom.CounterOpts{ - Namespace: "grpc", - Subsystem: "client", - Name: "handled_total", - Help: "Total number of RPCs completed by the client, regardless of success or failure.", - }, []string{"grpc_type", "grpc_service", "grpc_method", "grpc_code"}) - - clientStreamMsgReceived = prom.NewCounterVec( - prom.CounterOpts{ - Namespace: "grpc", - Subsystem: "client", - Name: "msg_received_total", - Help: "Total number of RPC stream messages received by the client.", - }, []string{"grpc_type", "grpc_service", "grpc_method"}) - - clientStreamMsgSent = prom.NewCounterVec( - prom.CounterOpts{ - Namespace: "grpc", - Subsystem: "client", - Name: "msg_sent_total", - Help: "Total number of gRPC stream messages sent by the client.", - }, []string{"grpc_type", "grpc_service", "grpc_method"}) - - clientHandledHistogramEnabled = false - clientHandledHistogramOpts = prom.HistogramOpts{ - Namespace: "grpc", - Subsystem: "client", - Name: "handling_seconds", - Help: "Histogram of response latency (seconds) of the gRPC until it is finished by the application.", - Buckets: prom.DefBuckets, - } - clientHandledHistogram *prom.HistogramVec ) -func init() { - prom.MustRegister(clientStartedCounter) - prom.MustRegister(clientHandledCounter) - prom.MustRegister(clientStreamMsgReceived) - prom.MustRegister(clientStreamMsgSent) -} - -// EnableClientHandlingTimeHistogram turns on recording of handling time of RPCs. -// Histogram metrics can be very expensive for Prometheus to retain and query. -func EnableClientHandlingTimeHistogram(opts ...HistogramOption) { - for _, o := range opts { - o(&clientHandledHistogramOpts) - } - if !clientHandledHistogramEnabled { - clientHandledHistogram = prom.NewHistogramVec( - clientHandledHistogramOpts, - []string{"grpc_type", "grpc_service", "grpc_method"}, - ) - prom.Register(clientHandledHistogram) - } - clientHandledHistogramEnabled = true -} - type clientReporter struct { + metrics *ClientMetrics rpcType grpcType serviceName string methodName string startTime time.Time } -func newClientReporter(rpcType grpcType, fullMethod string) *clientReporter { - r := &clientReporter{rpcType: rpcType} - if clientHandledHistogramEnabled { +func newClientReporter(m *ClientMetrics, rpcType grpcType, fullMethod string) *clientReporter { + r := &clientReporter{ + metrics: m, + rpcType: rpcType, + } + if r.metrics.clientHandledHistogramEnabled { r.startTime = time.Now() } r.serviceName, r.methodName = splitMethodName(fullMethod) - clientStartedCounter.WithLabelValues(string(r.rpcType), r.serviceName, r.methodName).Inc() + r.metrics.clientStartedCounter.WithLabelValues(string(r.rpcType), r.serviceName, r.methodName).Inc() return r } func (r *clientReporter) ReceivedMessage() { - clientStreamMsgReceived.WithLabelValues(string(r.rpcType), r.serviceName, r.methodName).Inc() + r.metrics.clientStreamMsgReceived.WithLabelValues(string(r.rpcType), r.serviceName, r.methodName).Inc() } func (r *clientReporter) SentMessage() { - clientStreamMsgSent.WithLabelValues(string(r.rpcType), r.serviceName, r.methodName).Inc() + r.metrics.clientStreamMsgSent.WithLabelValues(string(r.rpcType), r.serviceName, r.methodName).Inc() } func (r *clientReporter) Handled(code codes.Code) { - clientHandledCounter.WithLabelValues(string(r.rpcType), r.serviceName, r.methodName, code.String()).Inc() - if clientHandledHistogramEnabled { - clientHandledHistogram.WithLabelValues(string(r.rpcType), r.serviceName, r.methodName).Observe(time.Since(r.startTime).Seconds()) + r.metrics.clientHandledCounter.WithLabelValues(string(r.rpcType), r.serviceName, r.methodName, code.String()).Inc() + if r.metrics.clientHandledHistogramEnabled { + r.metrics.clientHandledHistogram.WithLabelValues(string(r.rpcType), r.serviceName, r.methodName).Observe(time.Since(r.startTime).Seconds()) } } diff --git a/vendor/github.com/grpc-ecosystem/go-grpc-prometheus/makefile b/vendor/github.com/grpc-ecosystem/go-grpc-prometheus/makefile new file mode 100644 index 00000000000..74c08422305 --- /dev/null +++ b/vendor/github.com/grpc-ecosystem/go-grpc-prometheus/makefile @@ -0,0 +1,16 @@ +SHELL="/bin/bash" + +GOFILES_NOVENDOR = $(shell go list ./... | grep -v /vendor/) + +all: vet fmt test + +fmt: + go fmt $(GOFILES_NOVENDOR) + +vet: + go vet $(GOFILES_NOVENDOR) + +test: vet + ./scripts/test_all.sh + +.PHONY: all vet test diff --git a/vendor/github.com/grpc-ecosystem/go-grpc-prometheus/metric_options.go b/vendor/github.com/grpc-ecosystem/go-grpc-prometheus/metric_options.go new file mode 100644 index 00000000000..9d51aec9816 --- /dev/null +++ b/vendor/github.com/grpc-ecosystem/go-grpc-prometheus/metric_options.go @@ -0,0 +1,41 @@ +package grpc_prometheus + +import ( + prom "github.com/prometheus/client_golang/prometheus" +) + +// A CounterOption lets you add options to Counter metrics using With* funcs. +type CounterOption func(*prom.CounterOpts) + +type counterOptions []CounterOption + +func (co counterOptions) apply(o prom.CounterOpts) prom.CounterOpts { + for _, f := range co { + f(&o) + } + return o +} + +// WithConstLabels allows you to add ConstLabels to Counter metrics. +func WithConstLabels(labels prom.Labels) CounterOption { + return func(o *prom.CounterOpts) { + o.ConstLabels = labels + } +} + +// A HistogramOption lets you add options to Histogram metrics using With* +// funcs. +type HistogramOption func(*prom.HistogramOpts) + +// WithHistogramBuckets allows you to specify custom bucket ranges for histograms if EnableHandlingTimeHistogram is on. +func WithHistogramBuckets(buckets []float64) HistogramOption { + return func(o *prom.HistogramOpts) { o.Buckets = buckets } +} + +// WithHistogramConstLabels allows you to add custom ConstLabels to +// histograms metrics. +func WithHistogramConstLabels(labels prom.Labels) HistogramOption { + return func(o *prom.HistogramOpts) { + o.ConstLabels = labels + } +} diff --git a/vendor/github.com/grpc-ecosystem/go-grpc-prometheus/server.go b/vendor/github.com/grpc-ecosystem/go-grpc-prometheus/server.go index f85c8c2374c..322f99046fd 100644 --- a/vendor/github.com/grpc-ecosystem/go-grpc-prometheus/server.go +++ b/vendor/github.com/grpc-ecosystem/go-grpc-prometheus/server.go @@ -6,69 +6,43 @@ package grpc_prometheus import ( - "golang.org/x/net/context" + prom "github.com/prometheus/client_golang/prometheus" "google.golang.org/grpc" ) -// PreregisterServices takes a gRPC server and pre-initializes all counters to 0. -// This allows for easier monitoring in Prometheus (no missing metrics), and should be called *after* all services have -// been registered with the server. -func Register(server *grpc.Server) { - serviceInfo := server.GetServiceInfo() - for serviceName, info := range serviceInfo { - for _, mInfo := range info.Methods { - preRegisterMethod(serviceName, &mInfo) - } - } -} - -// UnaryServerInterceptor is a gRPC server-side interceptor that provides Prometheus monitoring for Unary RPCs. -func UnaryServerInterceptor(ctx context.Context, req interface{}, info *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (interface{}, error) { - monitor := newServerReporter(Unary, info.FullMethod) - monitor.ReceivedMessage() - resp, err := handler(ctx, req) - monitor.Handled(grpc.Code(err)) - if err == nil { - monitor.SentMessage() - } - return resp, err -} +var ( + // DefaultServerMetrics is the default instance of ServerMetrics. It is + // intended to be used in conjunction the default Prometheus metrics + // registry. + DefaultServerMetrics = NewServerMetrics() -// StreamServerInterceptor is a gRPC server-side interceptor that provides Prometheus monitoring for Streaming RPCs. -func StreamServerInterceptor(srv interface{}, ss grpc.ServerStream, info *grpc.StreamServerInfo, handler grpc.StreamHandler) error { - monitor := newServerReporter(streamRpcType(info), info.FullMethod) - err := handler(srv, &monitoredServerStream{ss, monitor}) - monitor.Handled(grpc.Code(err)) - return err -} + // UnaryServerInterceptor is a gRPC server-side interceptor that provides Prometheus monitoring for Unary RPCs. + UnaryServerInterceptor = DefaultServerMetrics.UnaryServerInterceptor() -func streamRpcType(info *grpc.StreamServerInfo) grpcType { - if info.IsClientStream && !info.IsServerStream { - return ClientStream - } else if !info.IsClientStream && info.IsServerStream { - return ServerStream - } - return BidiStream -} + // StreamServerInterceptor is a gRPC server-side interceptor that provides Prometheus monitoring for Streaming RPCs. + StreamServerInterceptor = DefaultServerMetrics.StreamServerInterceptor() +) -// monitoredStream wraps grpc.ServerStream allowing each Sent/Recv of message to increment counters. -type monitoredServerStream struct { - grpc.ServerStream - monitor *serverReporter +func init() { + prom.MustRegister(DefaultServerMetrics.serverStartedCounter) + prom.MustRegister(DefaultServerMetrics.serverHandledCounter) + prom.MustRegister(DefaultServerMetrics.serverStreamMsgReceived) + prom.MustRegister(DefaultServerMetrics.serverStreamMsgSent) } -func (s *monitoredServerStream) SendMsg(m interface{}) error { - err := s.ServerStream.SendMsg(m) - if err == nil { - s.monitor.SentMessage() - } - return err +// Register takes a gRPC server and pre-initializes all counters to 0. This +// allows for easier monitoring in Prometheus (no missing metrics), and should +// be called *after* all services have been registered with the server. This +// function acts on the DefaultServerMetrics variable. +func Register(server *grpc.Server) { + DefaultServerMetrics.InitializeMetrics(server) } -func (s *monitoredServerStream) RecvMsg(m interface{}) error { - err := s.ServerStream.RecvMsg(m) - if err == nil { - s.monitor.ReceivedMessage() - } - return err +// EnableHandlingTimeHistogram turns on recording of handling time +// of RPCs. Histogram metrics can be very expensive for Prometheus +// to retain and query. This function acts on the DefaultServerMetrics +// variable and the default Prometheus metrics registry. +func EnableHandlingTimeHistogram(opts ...HistogramOption) { + DefaultServerMetrics.EnableHandlingTimeHistogram(opts...) + prom.Register(DefaultServerMetrics.serverHandledHistogram) } diff --git a/vendor/github.com/grpc-ecosystem/go-grpc-prometheus/server_metrics.go b/vendor/github.com/grpc-ecosystem/go-grpc-prometheus/server_metrics.go new file mode 100644 index 00000000000..5b1467e7aac --- /dev/null +++ b/vendor/github.com/grpc-ecosystem/go-grpc-prometheus/server_metrics.go @@ -0,0 +1,185 @@ +package grpc_prometheus + +import ( + prom "github.com/prometheus/client_golang/prometheus" + "golang.org/x/net/context" + "google.golang.org/grpc" + "google.golang.org/grpc/status" +) + +// ServerMetrics represents a collection of metrics to be registered on a +// Prometheus metrics registry for a gRPC server. +type ServerMetrics struct { + serverStartedCounter *prom.CounterVec + serverHandledCounter *prom.CounterVec + serverStreamMsgReceived *prom.CounterVec + serverStreamMsgSent *prom.CounterVec + serverHandledHistogramEnabled bool + serverHandledHistogramOpts prom.HistogramOpts + serverHandledHistogram *prom.HistogramVec +} + +// NewServerMetrics returns a ServerMetrics object. Use a new instance of +// ServerMetrics when not using the default Prometheus metrics registry, for +// example when wanting to control which metrics are added to a registry as +// opposed to automatically adding metrics via init functions. +func NewServerMetrics(counterOpts ...CounterOption) *ServerMetrics { + opts := counterOptions(counterOpts) + return &ServerMetrics{ + serverStartedCounter: prom.NewCounterVec( + opts.apply(prom.CounterOpts{ + Name: "grpc_server_started_total", + Help: "Total number of RPCs started on the server.", + }), []string{"grpc_type", "grpc_service", "grpc_method"}), + serverHandledCounter: prom.NewCounterVec( + opts.apply(prom.CounterOpts{ + Name: "grpc_server_handled_total", + Help: "Total number of RPCs completed on the server, regardless of success or failure.", + }), []string{"grpc_type", "grpc_service", "grpc_method", "grpc_code"}), + serverStreamMsgReceived: prom.NewCounterVec( + opts.apply(prom.CounterOpts{ + Name: "grpc_server_msg_received_total", + Help: "Total number of RPC stream messages received on the server.", + }), []string{"grpc_type", "grpc_service", "grpc_method"}), + serverStreamMsgSent: prom.NewCounterVec( + opts.apply(prom.CounterOpts{ + Name: "grpc_server_msg_sent_total", + Help: "Total number of gRPC stream messages sent by the server.", + }), []string{"grpc_type", "grpc_service", "grpc_method"}), + serverHandledHistogramEnabled: false, + serverHandledHistogramOpts: prom.HistogramOpts{ + Name: "grpc_server_handling_seconds", + Help: "Histogram of response latency (seconds) of gRPC that had been application-level handled by the server.", + Buckets: prom.DefBuckets, + }, + serverHandledHistogram: nil, + } +} + +// EnableHandlingTimeHistogram enables histograms being registered when +// registering the ServerMetrics on a Prometheus registry. Histograms can be +// expensive on Prometheus servers. It takes options to configure histogram +// options such as the defined buckets. +func (m *ServerMetrics) EnableHandlingTimeHistogram(opts ...HistogramOption) { + for _, o := range opts { + o(&m.serverHandledHistogramOpts) + } + if !m.serverHandledHistogramEnabled { + m.serverHandledHistogram = prom.NewHistogramVec( + m.serverHandledHistogramOpts, + []string{"grpc_type", "grpc_service", "grpc_method"}, + ) + } + m.serverHandledHistogramEnabled = true +} + +// Describe sends the super-set of all possible descriptors of metrics +// collected by this Collector to the provided channel and returns once +// the last descriptor has been sent. +func (m *ServerMetrics) Describe(ch chan<- *prom.Desc) { + m.serverStartedCounter.Describe(ch) + m.serverHandledCounter.Describe(ch) + m.serverStreamMsgReceived.Describe(ch) + m.serverStreamMsgSent.Describe(ch) + if m.serverHandledHistogramEnabled { + m.serverHandledHistogram.Describe(ch) + } +} + +// Collect is called by the Prometheus registry when collecting +// metrics. The implementation sends each collected metric via the +// provided channel and returns once the last metric has been sent. +func (m *ServerMetrics) Collect(ch chan<- prom.Metric) { + m.serverStartedCounter.Collect(ch) + m.serverHandledCounter.Collect(ch) + m.serverStreamMsgReceived.Collect(ch) + m.serverStreamMsgSent.Collect(ch) + if m.serverHandledHistogramEnabled { + m.serverHandledHistogram.Collect(ch) + } +} + +// UnaryServerInterceptor is a gRPC server-side interceptor that provides Prometheus monitoring for Unary RPCs. +func (m *ServerMetrics) UnaryServerInterceptor() func(ctx context.Context, req interface{}, info *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (interface{}, error) { + return func(ctx context.Context, req interface{}, info *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (interface{}, error) { + monitor := newServerReporter(m, Unary, info.FullMethod) + monitor.ReceivedMessage() + resp, err := handler(ctx, req) + st, _ := status.FromError(err) + monitor.Handled(st.Code()) + if err == nil { + monitor.SentMessage() + } + return resp, err + } +} + +// StreamServerInterceptor is a gRPC server-side interceptor that provides Prometheus monitoring for Streaming RPCs. +func (m *ServerMetrics) StreamServerInterceptor() func(srv interface{}, ss grpc.ServerStream, info *grpc.StreamServerInfo, handler grpc.StreamHandler) error { + return func(srv interface{}, ss grpc.ServerStream, info *grpc.StreamServerInfo, handler grpc.StreamHandler) error { + monitor := newServerReporter(m, streamRPCType(info), info.FullMethod) + err := handler(srv, &monitoredServerStream{ss, monitor}) + st, _ := status.FromError(err) + monitor.Handled(st.Code()) + return err + } +} + +// InitializeMetrics initializes all metrics, with their appropriate null +// value, for all gRPC methods registered on a gRPC server. This is useful, to +// ensure that all metrics exist when collecting and querying. +func (m *ServerMetrics) InitializeMetrics(server *grpc.Server) { + serviceInfo := server.GetServiceInfo() + for serviceName, info := range serviceInfo { + for _, mInfo := range info.Methods { + preRegisterMethod(m, serviceName, &mInfo) + } + } +} + +func streamRPCType(info *grpc.StreamServerInfo) grpcType { + if info.IsClientStream && !info.IsServerStream { + return ClientStream + } else if !info.IsClientStream && info.IsServerStream { + return ServerStream + } + return BidiStream +} + +// monitoredStream wraps grpc.ServerStream allowing each Sent/Recv of message to increment counters. +type monitoredServerStream struct { + grpc.ServerStream + monitor *serverReporter +} + +func (s *monitoredServerStream) SendMsg(m interface{}) error { + err := s.ServerStream.SendMsg(m) + if err == nil { + s.monitor.SentMessage() + } + return err +} + +func (s *monitoredServerStream) RecvMsg(m interface{}) error { + err := s.ServerStream.RecvMsg(m) + if err == nil { + s.monitor.ReceivedMessage() + } + return err +} + +// preRegisterMethod is invoked on Register of a Server, allowing all gRPC services labels to be pre-populated. +func preRegisterMethod(metrics *ServerMetrics, serviceName string, mInfo *grpc.MethodInfo) { + methodName := mInfo.Name + methodType := string(typeFromMethodInfo(mInfo)) + // These are just references (no increments), as just referencing will create the labels but not set values. + metrics.serverStartedCounter.GetMetricWithLabelValues(methodType, serviceName, methodName) + metrics.serverStreamMsgReceived.GetMetricWithLabelValues(methodType, serviceName, methodName) + metrics.serverStreamMsgSent.GetMetricWithLabelValues(methodType, serviceName, methodName) + if metrics.serverHandledHistogramEnabled { + metrics.serverHandledHistogram.GetMetricWithLabelValues(methodType, serviceName, methodName) + } + for _, code := range allCodes { + metrics.serverHandledCounter.GetMetricWithLabelValues(methodType, serviceName, methodName, code.String()) + } +} diff --git a/vendor/github.com/grpc-ecosystem/go-grpc-prometheus/server_reporter.go b/vendor/github.com/grpc-ecosystem/go-grpc-prometheus/server_reporter.go index 628a890560f..aa9db5401a4 100644 --- a/vendor/github.com/grpc-ecosystem/go-grpc-prometheus/server_reporter.go +++ b/vendor/github.com/grpc-ecosystem/go-grpc-prometheus/server_reporter.go @@ -7,151 +7,40 @@ import ( "time" "google.golang.org/grpc/codes" - - prom "github.com/prometheus/client_golang/prometheus" - "google.golang.org/grpc" -) - -type grpcType string - -const ( - Unary grpcType = "unary" - ClientStream grpcType = "client_stream" - ServerStream grpcType = "server_stream" - BidiStream grpcType = "bidi_stream" ) -var ( - serverStartedCounter = prom.NewCounterVec( - prom.CounterOpts{ - Namespace: "grpc", - Subsystem: "server", - Name: "started_total", - Help: "Total number of RPCs started on the server.", - }, []string{"grpc_type", "grpc_service", "grpc_method"}) - - serverHandledCounter = prom.NewCounterVec( - prom.CounterOpts{ - Namespace: "grpc", - Subsystem: "server", - Name: "handled_total", - Help: "Total number of RPCs completed on the server, regardless of success or failure.", - }, []string{"grpc_type", "grpc_service", "grpc_method", "grpc_code"}) - - serverStreamMsgReceived = prom.NewCounterVec( - prom.CounterOpts{ - Namespace: "grpc", - Subsystem: "server", - Name: "msg_received_total", - Help: "Total number of RPC stream messages received on the server.", - }, []string{"grpc_type", "grpc_service", "grpc_method"}) - - serverStreamMsgSent = prom.NewCounterVec( - prom.CounterOpts{ - Namespace: "grpc", - Subsystem: "server", - Name: "msg_sent_total", - Help: "Total number of gRPC stream messages sent by the server.", - }, []string{"grpc_type", "grpc_service", "grpc_method"}) - - serverHandledHistogramEnabled = false - serverHandledHistogramOpts = prom.HistogramOpts{ - Namespace: "grpc", - Subsystem: "server", - Name: "handling_seconds", - Help: "Histogram of response latency (seconds) of gRPC that had been application-level handled by the server.", - Buckets: prom.DefBuckets, - } - serverHandledHistogram *prom.HistogramVec -) - -func init() { - prom.MustRegister(serverStartedCounter) - prom.MustRegister(serverHandledCounter) - prom.MustRegister(serverStreamMsgReceived) - prom.MustRegister(serverStreamMsgSent) -} - -type HistogramOption func(*prom.HistogramOpts) - -// WithHistogramBuckets allows you to specify custom bucket ranges for histograms if EnableHandlingTimeHistogram is on. -func WithHistogramBuckets(buckets []float64) HistogramOption { - return func(o *prom.HistogramOpts) { o.Buckets = buckets } -} - -// EnableHandlingTimeHistogram turns on recording of handling time of RPCs for server-side interceptors. -// Histogram metrics can be very expensive for Prometheus to retain and query. -func EnableHandlingTimeHistogram(opts ...HistogramOption) { - for _, o := range opts { - o(&serverHandledHistogramOpts) - } - if !serverHandledHistogramEnabled { - serverHandledHistogram = prom.NewHistogramVec( - serverHandledHistogramOpts, - []string{"grpc_type", "grpc_service", "grpc_method"}, - ) - prom.Register(serverHandledHistogram) - } - serverHandledHistogramEnabled = true -} - type serverReporter struct { + metrics *ServerMetrics rpcType grpcType serviceName string methodName string startTime time.Time } -func newServerReporter(rpcType grpcType, fullMethod string) *serverReporter { - r := &serverReporter{rpcType: rpcType} - if serverHandledHistogramEnabled { +func newServerReporter(m *ServerMetrics, rpcType grpcType, fullMethod string) *serverReporter { + r := &serverReporter{ + metrics: m, + rpcType: rpcType, + } + if r.metrics.serverHandledHistogramEnabled { r.startTime = time.Now() } r.serviceName, r.methodName = splitMethodName(fullMethod) - serverStartedCounter.WithLabelValues(string(r.rpcType), r.serviceName, r.methodName).Inc() + r.metrics.serverStartedCounter.WithLabelValues(string(r.rpcType), r.serviceName, r.methodName).Inc() return r } func (r *serverReporter) ReceivedMessage() { - serverStreamMsgReceived.WithLabelValues(string(r.rpcType), r.serviceName, r.methodName).Inc() + r.metrics.serverStreamMsgReceived.WithLabelValues(string(r.rpcType), r.serviceName, r.methodName).Inc() } func (r *serverReporter) SentMessage() { - serverStreamMsgSent.WithLabelValues(string(r.rpcType), r.serviceName, r.methodName).Inc() + r.metrics.serverStreamMsgSent.WithLabelValues(string(r.rpcType), r.serviceName, r.methodName).Inc() } func (r *serverReporter) Handled(code codes.Code) { - serverHandledCounter.WithLabelValues(string(r.rpcType), r.serviceName, r.methodName, code.String()).Inc() - if serverHandledHistogramEnabled { - serverHandledHistogram.WithLabelValues(string(r.rpcType), r.serviceName, r.methodName).Observe(time.Since(r.startTime).Seconds()) - } -} - -// preRegisterMethod is invoked on Register of a Server, allowing all gRPC services labels to be pre-populated. -func preRegisterMethod(serviceName string, mInfo *grpc.MethodInfo) { - methodName := mInfo.Name - methodType := string(typeFromMethodInfo(mInfo)) - // These are just references (no increments), as just referencing will create the labels but not set values. - serverStartedCounter.GetMetricWithLabelValues(methodType, serviceName, methodName) - serverStreamMsgReceived.GetMetricWithLabelValues(methodType, serviceName, methodName) - serverStreamMsgSent.GetMetricWithLabelValues(methodType, serviceName, methodName) - if serverHandledHistogramEnabled { - serverHandledHistogram.GetMetricWithLabelValues(methodType, serviceName, methodName) - } - for _, code := range allCodes { - serverHandledCounter.GetMetricWithLabelValues(methodType, serviceName, methodName, code.String()) - } -} - -func typeFromMethodInfo(mInfo *grpc.MethodInfo) grpcType { - if mInfo.IsClientStream == false && mInfo.IsServerStream == false { - return Unary - } - if mInfo.IsClientStream == true && mInfo.IsServerStream == false { - return ClientStream - } - if mInfo.IsClientStream == false && mInfo.IsServerStream == true { - return ServerStream + r.metrics.serverHandledCounter.WithLabelValues(string(r.rpcType), r.serviceName, r.methodName, code.String()).Inc() + if r.metrics.serverHandledHistogramEnabled { + r.metrics.serverHandledHistogram.WithLabelValues(string(r.rpcType), r.serviceName, r.methodName).Observe(time.Since(r.startTime).Seconds()) } - return BidiStream } diff --git a/vendor/github.com/grpc-ecosystem/go-grpc-prometheus/test_all.sh b/vendor/github.com/grpc-ecosystem/go-grpc-prometheus/test_all.sh deleted file mode 100644 index e1e78008062..00000000000 --- a/vendor/github.com/grpc-ecosystem/go-grpc-prometheus/test_all.sh +++ /dev/null @@ -1,14 +0,0 @@ -#!/usr/bin/env bash - -set -e -echo "" > coverage.txt - -for d in $(go list ./... | grep -v vendor); do - echo -e "TESTS FOR: for \033[0;35m${d}\033[0m" - go test -race -v -coverprofile=profile.coverage.out -covermode=atomic $d - if [ -f profile.coverage.out ]; then - cat profile.coverage.out >> coverage.txt - rm profile.coverage.out - fi - echo "" -done diff --git a/vendor/github.com/grpc-ecosystem/go-grpc-prometheus/util.go b/vendor/github.com/grpc-ecosystem/go-grpc-prometheus/util.go index 372460ac497..7987de35f42 100644 --- a/vendor/github.com/grpc-ecosystem/go-grpc-prometheus/util.go +++ b/vendor/github.com/grpc-ecosystem/go-grpc-prometheus/util.go @@ -6,9 +6,19 @@ package grpc_prometheus import ( "strings" + "google.golang.org/grpc" "google.golang.org/grpc/codes" ) +type grpcType string + +const ( + Unary grpcType = "unary" + ClientStream grpcType = "client_stream" + ServerStream grpcType = "server_stream" + BidiStream grpcType = "bidi_stream" +) + var ( allCodes = []codes.Code{ codes.OK, codes.Canceled, codes.Unknown, codes.InvalidArgument, codes.DeadlineExceeded, codes.NotFound, @@ -25,3 +35,16 @@ func splitMethodName(fullMethodName string) (string, string) { } return "unknown", "unknown" } + +func typeFromMethodInfo(mInfo *grpc.MethodInfo) grpcType { + if !mInfo.IsClientStream && !mInfo.IsServerStream { + return Unary + } + if mInfo.IsClientStream && !mInfo.IsServerStream { + return ClientStream + } + if !mInfo.IsClientStream && mInfo.IsServerStream { + return ServerStream + } + return BidiStream +} diff --git a/vendor/modules.txt b/vendor/modules.txt index fcb46edf2ea..53d23f3de25 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -466,7 +466,7 @@ github.com/gregjones/httpcache github.com/gregjones/httpcache/diskcache # github.com/grpc-ecosystem/go-grpc-middleware v1.0.1-0.20190118093823-f849b5445de4 => github.com/grpc-ecosystem/go-grpc-middleware v0.0.0-20190222133341-cfaf5686ec79 github.com/grpc-ecosystem/go-grpc-middleware -# github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0 => github.com/grpc-ecosystem/go-grpc-prometheus v0.0.0-20170330212424-2500245aa611 +# github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0 => github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0 github.com/grpc-ecosystem/go-grpc-prometheus # github.com/grpc-ecosystem/grpc-gateway v1.9.5 => github.com/grpc-ecosystem/grpc-gateway v1.3.0 github.com/grpc-ecosystem/grpc-gateway/runtime @@ -1671,6 +1671,11 @@ k8s.io/component-base/featuregate k8s.io/component-base/featuregate/testing k8s.io/component-base/logs k8s.io/component-base/metrics +k8s.io/component-base/metrics/legacyregistry +k8s.io/component-base/metrics/prometheus/clientgo +k8s.io/component-base/metrics/prometheus/clientgo/leaderelection +k8s.io/component-base/metrics/prometheus/restclient +k8s.io/component-base/metrics/prometheus/workqueue k8s.io/component-base/metrics/testutil k8s.io/component-base/version # k8s.io/cri-api v0.0.0 => ./staging/src/k8s.io/cri-api @@ -1840,7 +1845,7 @@ sigs.k8s.io/kustomize/pkg/transformers sigs.k8s.io/kustomize/pkg/transformers/config sigs.k8s.io/kustomize/pkg/transformers/config/defaultconfig sigs.k8s.io/kustomize/pkg/types -# sigs.k8s.io/structured-merge-diff v0.0.0-20190302045857-e85c7b244fd2 => sigs.k8s.io/structured-merge-diff v0.0.0-20190302045857-e85c7b244fd2 +# sigs.k8s.io/structured-merge-diff v0.0.0-20190719182312-e94e05bfbbe3 => sigs.k8s.io/structured-merge-diff v0.0.0-20190719182312-e94e05bfbbe3 sigs.k8s.io/structured-merge-diff/fieldpath sigs.k8s.io/structured-merge-diff/merge sigs.k8s.io/structured-merge-diff/schema diff --git a/vendor/sigs.k8s.io/structured-merge-diff/fieldpath/element.go b/vendor/sigs.k8s.io/structured-merge-diff/fieldpath/element.go index fb706a662b4..9783c3bac53 100644 --- a/vendor/sigs.k8s.io/structured-merge-diff/fieldpath/element.go +++ b/vendor/sigs.k8s.io/structured-merge-diff/fieldpath/element.go @@ -35,7 +35,7 @@ type PathElement struct { // Key selects the list element which has fields matching those given. // The containing object must be an associative list with map typed // elements. - Key []value.Field + Key *value.Map // Value selects the list element with the given value. The containing // object must be an associative list with a primitive typed element @@ -47,14 +47,62 @@ type PathElement struct { Index *int } +// Less provides an order for path elements. +func (e PathElement) Less(rhs PathElement) bool { + if e.FieldName != nil { + if rhs.FieldName == nil { + return true + } + return *e.FieldName < *rhs.FieldName + } else if rhs.FieldName != nil { + return false + } + + if e.Key != nil { + if rhs.Key == nil { + return true + } + return e.Key.Less(rhs.Key) + } else if rhs.Key != nil { + return false + } + + if e.Value != nil { + if rhs.Value == nil { + return true + } + return e.Value.Less(*rhs.Value) + } else if rhs.Value != nil { + return false + } + + if e.Index != nil { + if rhs.Index == nil { + return true + } + return *e.Index < *rhs.Index + } else if rhs.Index != nil { + // Yes, I know the next statement is the same. But this way + // the obvious way of extending the function wil be bug-free. + return false + } + + return false +} + +// Equals returns true if both path elements are equal. +func (e PathElement) Equals(rhs PathElement) bool { + return !e.Less(rhs) && !rhs.Less(e) +} + // String presents the path element as a human-readable string. func (e PathElement) String() string { switch { case e.FieldName != nil: return "." + *e.FieldName - case len(e.Key) > 0: - strs := make([]string, len(e.Key)) - for i, k := range e.Key { + case e.Key != nil: + strs := make([]string, len(e.Key.Items)) + for i, k := range e.Key.Items { strs[i] = fmt.Sprintf("%v=%v", k.Name, k.Value) } // The order must be canonical, since we use the string value @@ -92,62 +140,100 @@ func KeyByFields(nameValues ...interface{}) []value.Field { // PathElementSet is a set of path elements. // TODO: serialize as a list. type PathElementSet struct { - // The strange construction is because there's no way to test - // PathElements for equality (it can't be used as a key for a map). - members map[string]PathElement + members sortedPathElements } +type sortedPathElements []PathElement + +// Implement the sort interface; this would permit bulk creation, which would +// be faster than doing it one at a time via Insert. +func (spe sortedPathElements) Len() int { return len(spe) } +func (spe sortedPathElements) Less(i, j int) bool { return spe[i].Less(spe[j]) } +func (spe sortedPathElements) Swap(i, j int) { spe[i], spe[j] = spe[j], spe[i] } + // Insert adds pe to the set. func (s *PathElementSet) Insert(pe PathElement) { - serialized := pe.String() - if s.members == nil { - s.members = map[string]PathElement{ - serialized: pe, - } + loc := sort.Search(len(s.members), func(i int) bool { + return !s.members[i].Less(pe) + }) + if loc == len(s.members) { + s.members = append(s.members, pe) return } - if _, ok := s.members[serialized]; !ok { - s.members[serialized] = pe + if s.members[loc].Equals(pe) { + return } + s.members = append(s.members, PathElement{}) + copy(s.members[loc+1:], s.members[loc:]) + s.members[loc] = pe } // Union returns a set containing elements that appear in either s or s2. func (s *PathElementSet) Union(s2 *PathElementSet) *PathElementSet { - out := &PathElementSet{ - members: map[string]PathElement{}, + out := &PathElementSet{} + + i, j := 0, 0 + for i < len(s.members) && j < len(s2.members) { + if s.members[i].Less(s2.members[j]) { + out.members = append(out.members, s.members[i]) + i++ + } else { + out.members = append(out.members, s2.members[j]) + if !s2.members[j].Less(s.members[i]) { + i++ + } + j++ + } } - for k, v := range s.members { - out.members[k] = v + + if i < len(s.members) { + out.members = append(out.members, s.members[i:]...) } - for k, v := range s2.members { - out.members[k] = v + if j < len(s2.members) { + out.members = append(out.members, s2.members[j:]...) } return out } // Intersection returns a set containing elements which appear in both s and s2. func (s *PathElementSet) Intersection(s2 *PathElementSet) *PathElementSet { - out := &PathElementSet{ - members: map[string]PathElement{}, - } - for k, v := range s.members { - if _, ok := s2.members[k]; ok { - out.members[k] = v + out := &PathElementSet{} + + i, j := 0, 0 + for i < len(s.members) && j < len(s2.members) { + if s.members[i].Less(s2.members[j]) { + i++ + } else { + if !s2.members[j].Less(s.members[i]) { + out.members = append(out.members, s.members[i]) + i++ + } + j++ } } + return out } // Difference returns a set containing elements which appear in s but not in s2. func (s *PathElementSet) Difference(s2 *PathElementSet) *PathElementSet { - out := &PathElementSet{ - members: map[string]PathElement{}, - } - for k, v := range s.members { - if _, ok := s2.members[k]; !ok { - out.members[k] = v + out := &PathElementSet{} + + i, j := 0, 0 + for i < len(s.members) && j < len(s2.members) { + if s.members[i].Less(s2.members[j]) { + out.members = append(out.members, s.members[i]) + i++ + } else { + if !s2.members[j].Less(s.members[i]) { + i++ + } + j++ } } + if i < len(s.members) { + out.members = append(out.members, s.members[i:]...) + } return out } @@ -156,11 +242,16 @@ func (s *PathElementSet) Size() int { return len(s.members) } // Has returns true if pe is a member of the set. func (s *PathElementSet) Has(pe PathElement) bool { - if s.members == nil { + loc := sort.Search(len(s.members), func(i int) bool { + return !s.members[i].Less(pe) + }) + if loc == len(s.members) { return false } - _, ok := s.members[pe.String()] - return ok + if s.members[loc].Equals(pe) { + return true + } + return false } // Equals returns true if s and s2 have exactly the same members. @@ -169,14 +260,14 @@ func (s *PathElementSet) Equals(s2 *PathElementSet) bool { return false } for k := range s.members { - if _, ok := s2.members[k]; !ok { + if !s.members[k].Equals(s2.members[k]) { return false } } return true } -// Iterate calls f for each PathElement in the set. +// Iterate calls f for each PathElement in the set. The order is deterministic. func (s *PathElementSet) Iterate(f func(PathElement)) { for _, pe := range s.members { f(pe) diff --git a/vendor/sigs.k8s.io/structured-merge-diff/fieldpath/fromvalue.go b/vendor/sigs.k8s.io/structured-merge-diff/fieldpath/fromvalue.go index a4b054fc7aa..830880fb49d 100644 --- a/vendor/sigs.k8s.io/structured-merge-diff/fieldpath/fromvalue.go +++ b/vendor/sigs.k8s.io/structured-merge-diff/fieldpath/fromvalue.go @@ -117,7 +117,7 @@ func GuessBestListPathElement(index int, item value.Value) PathElement { keys = append(keys, *f) } if len(keys) > 0 { - return PathElement{Key: keys} + return PathElement{Key: &value.Map{Items: keys}} } return PathElement{Index: &index} } diff --git a/vendor/sigs.k8s.io/structured-merge-diff/fieldpath/path.go b/vendor/sigs.k8s.io/structured-merge-diff/fieldpath/path.go index c11c7f28a5b..ca80e7cca79 100644 --- a/vendor/sigs.k8s.io/structured-merge-diff/fieldpath/path.go +++ b/vendor/sigs.k8s.io/structured-merge-diff/fieldpath/path.go @@ -35,6 +35,40 @@ func (fp Path) String() string { return strings.Join(strs, "") } +// Equals returns true if the two paths are equivalent. +func (fp Path) Equals(fp2 Path) bool { + return !fp.Less(fp2) && !fp2.Less(fp) +} + +// Less provides a lexical order for Paths. +func (fp Path) Less(rhs Path) bool { + i := 0 + for { + if i >= len(fp) && i >= len(rhs) { + // Paths are the same length and all items are equal. + return false + } + if i >= len(fp) { + // LHS is shorter. + return true + } + if i >= len(rhs) { + // RHS is shorter. + return false + } + if fp[i].Less(rhs[i]) { + // LHS is less; return + return true + } + if rhs[i].Less(fp[i]) { + // RHS is less; return + return false + } + // The items are equal; continue. + i++ + } +} + func (fp Path) Copy() Path { new := make(Path, len(fp)) copy(new, fp) @@ -58,7 +92,7 @@ func MakePath(parts ...interface{}) (Path, error) { if len(t) == 0 { return nil, fmt.Errorf("associative list key type path elements must have at least one key (got zero)") } - fp = append(fp, PathElement{Key: t}) + fp = append(fp, PathElement{Key: &value.Map{Items: t}}) case value.Value: // TODO: understand schema and verify that this is a set type // TODO: make a copy of t diff --git a/vendor/sigs.k8s.io/structured-merge-diff/fieldpath/set.go b/vendor/sigs.k8s.io/structured-merge-diff/fieldpath/set.go index e561093b6e6..b3aebfefcb0 100644 --- a/vendor/sigs.k8s.io/structured-merge-diff/fieldpath/set.go +++ b/vendor/sigs.k8s.io/structured-merge-diff/fieldpath/set.go @@ -17,6 +17,7 @@ limitations under the License. package fieldpath import ( + "sort" "strings" ) @@ -172,24 +173,25 @@ type setNode struct { // SetNodeMap is a map of PathElement to subset. type SetNodeMap struct { - members map[string]setNode + members []setNode } // Descend adds pe to the set if necessary, returning the associated subset. func (s *SetNodeMap) Descend(pe PathElement) *Set { - serialized := pe.String() - if s.members == nil { - s.members = map[string]setNode{} - } - if n, ok := s.members[serialized]; ok { - return n.set + loc := sort.Search(len(s.members), func(i int) bool { + return !s.members[i].pathElement.Less(pe) + }) + if loc == len(s.members) { + s.members = append(s.members, setNode{pathElement: pe, set: &Set{}}) + return s.members[loc].set } - ss := &Set{} - s.members[serialized] = setNode{ - pathElement: pe, - set: ss, + if s.members[loc].pathElement.Equals(pe) { + return s.members[loc].set } - return ss + s.members = append(s.members, setNode{}) + copy(s.members[loc+1:], s.members[loc:]) + s.members[loc] = setNode{pathElement: pe, set: &Set{}} + return s.members[loc].set } // Size returns the sum of the number of members of all subsets. @@ -213,12 +215,14 @@ func (s *SetNodeMap) Empty() bool { // Get returns (the associated set, true) or (nil, false) if there is none. func (s *SetNodeMap) Get(pe PathElement) (*Set, bool) { - if s.members == nil { + loc := sort.Search(len(s.members), func(i int) bool { + return !s.members[i].pathElement.Less(pe) + }) + if loc == len(s.members) { return nil, false } - serialized := pe.String() - if n, ok := s.members[serialized]; ok { - return n.set, true + if s.members[loc].pathElement.Equals(pe) { + return s.members[loc].set, true } return nil, false } @@ -229,12 +233,11 @@ func (s *SetNodeMap) Equals(s2 *SetNodeMap) bool { if len(s.members) != len(s2.members) { return false } - for k, v := range s.members { - v2, ok := s2.members[k] - if !ok { + for i := range s.members { + if !s.members[i].pathElement.Equals(s2.members[i].pathElement) { return false } - if !v.set.Equals(v2.set) { + if !s.members[i].set.Equals(s2.members[i].set) { return false } } @@ -244,21 +247,28 @@ func (s *SetNodeMap) Equals(s2 *SetNodeMap) bool { // Union returns a SetNodeMap with members that appear in either s or s2. func (s *SetNodeMap) Union(s2 *SetNodeMap) *SetNodeMap { out := &SetNodeMap{} - for k, sn := range s.members { - pe := sn.pathElement - if sn2, ok := s2.members[k]; ok { - *out.Descend(pe) = *sn.set.Union(sn2.set) + + i, j := 0, 0 + for i < len(s.members) && j < len(s2.members) { + if s.members[i].pathElement.Less(s2.members[j].pathElement) { + out.members = append(out.members, s.members[i]) + i++ } else { - *out.Descend(pe) = *sn.set + if !s2.members[j].pathElement.Less(s.members[i].pathElement) { + out.members = append(out.members, setNode{pathElement: s.members[i].pathElement, set: s.members[i].set.Union(s2.members[j].set)}) + i++ + } else { + out.members = append(out.members, s2.members[j]) + } + j++ } } - for k, sn2 := range s2.members { - pe := sn2.pathElement - if _, ok := s.members[k]; ok { - // already handled - continue - } - *out.Descend(pe) = *sn2.set + + if i < len(s.members) { + out.members = append(out.members, s.members[i:]...) + } + if j < len(s2.members) { + out.members = append(out.members, s2.members[j:]...) } return out } @@ -266,13 +276,20 @@ func (s *SetNodeMap) Union(s2 *SetNodeMap) *SetNodeMap { // Intersection returns a SetNodeMap with members that appear in both s and s2. func (s *SetNodeMap) Intersection(s2 *SetNodeMap) *SetNodeMap { out := &SetNodeMap{} - for k, sn := range s.members { - pe := sn.pathElement - if sn2, ok := s2.members[k]; ok { - i := *sn.set.Intersection(sn2.set) - if !i.Empty() { - *out.Descend(pe) = i + + i, j := 0, 0 + for i < len(s.members) && j < len(s2.members) { + if s.members[i].pathElement.Less(s2.members[j].pathElement) { + i++ + } else { + if !s2.members[j].pathElement.Less(s.members[i].pathElement) { + res := s.members[i].set.Intersection(s2.members[j].set) + if !res.Empty() { + out.members = append(out.members, setNode{pathElement: s.members[i].pathElement, set: res}) + } + i++ } + j++ } } return out @@ -281,18 +298,30 @@ func (s *SetNodeMap) Intersection(s2 *SetNodeMap) *SetNodeMap { // Difference returns a SetNodeMap with members that appear in s but not in s2. func (s *SetNodeMap) Difference(s2 *Set) *SetNodeMap { out := &SetNodeMap{} - for k, sn := range s.members { - pe := sn.pathElement - if sn2, ok := s2.Children.members[k]; ok { - diff := *sn.set.Difference(sn2.set) - // We aren't permitted to add nodes with no elements. - if !diff.Empty() { - *out.Descend(pe) = diff - } + + i, j := 0, 0 + for i < len(s.members) && j < len(s2.Children.members) { + if s.members[i].pathElement.Less(s2.Children.members[j].pathElement) { + out.members = append(out.members, setNode{pathElement: s.members[i].pathElement, set: s.members[i].set}) + i++ } else { - *out.Descend(pe) = *sn.set + if !s2.Children.members[j].pathElement.Less(s.members[i].pathElement) { + + diff := s.members[i].set.Difference(s2.Children.members[j].set) + // We aren't permitted to add nodes with no elements. + if !diff.Empty() { + out.members = append(out.members, setNode{pathElement: s.members[i].pathElement, set: diff}) + } + + i++ + } + j++ } } + + if i < len(s.members) { + out.members = append(out.members, s.members[i:]...) + } return out } diff --git a/vendor/sigs.k8s.io/structured-merge-diff/merge/conflict.go b/vendor/sigs.k8s.io/structured-merge-diff/merge/conflict.go index 1056037b83c..c7eea6859f8 100644 --- a/vendor/sigs.k8s.io/structured-merge-diff/merge/conflict.go +++ b/vendor/sigs.k8s.io/structured-merge-diff/merge/conflict.go @@ -40,6 +40,14 @@ func (c Conflict) Error() string { return fmt.Sprintf("conflict with %q: %v", c.Manager, c.Path) } +// Equals returns true if c == c2 +func (c Conflict) Equals(c2 Conflict) bool { + if c.Manager != c2.Manager { + return false + } + return c.Path.Equals(c2.Path) +} + // Conflicts accumulates multiple conflicts and aggregates them by managers. type Conflicts []Conflict @@ -74,6 +82,19 @@ func (conflicts Conflicts) Error() string { return strings.Join(messages, "\n") } +// Equals returns true if the lists of conflicts are the same. +func (c Conflicts) Equals(c2 Conflicts) bool { + if len(c) != len(c2) { + return false + } + for i := range c { + if !c[i].Equals(c2[i]) { + return false + } + } + return true +} + // ConflictsFromManagers creates a list of conflicts given Managers sets. func ConflictsFromManagers(sets fieldpath.ManagedFields) Conflicts { conflicts := []Conflict{} diff --git a/vendor/sigs.k8s.io/structured-merge-diff/typed/helpers.go b/vendor/sigs.k8s.io/structured-merge-diff/typed/helpers.go index e7fadc0182f..fcc5d1c9c96 100644 --- a/vendor/sigs.k8s.io/structured-merge-diff/typed/helpers.go +++ b/vendor/sigs.k8s.io/structured-merge-diff/typed/helpers.go @@ -197,6 +197,7 @@ func keyedAssociativeListItemToPathElement(list schema.List, index int, child va if child.MapValue == nil { return pe, errors.New("associative list with keys may not have non-map elements") } + keyMap := &value.Map{} for _, fieldName := range list.Keys { var fieldValue value.Value field, ok := child.MapValue.Get(fieldName) @@ -206,11 +207,9 @@ func keyedAssociativeListItemToPathElement(list schema.List, index int, child va // Treat keys as required. return pe, fmt.Errorf("associative list with keys has an element that omits key field %q", fieldName) } - pe.Key = append(pe.Key, value.Field{ - Name: fieldName, - Value: fieldValue, - }) + keyMap.Set(fieldName, fieldValue) } + pe.Key = keyMap return pe, nil } diff --git a/vendor/sigs.k8s.io/structured-merge-diff/value/value.go b/vendor/sigs.k8s.io/structured-merge-diff/value/value.go index a5dbc5f4711..a4e0f0b847a 100644 --- a/vendor/sigs.k8s.io/structured-merge-diff/value/value.go +++ b/vendor/sigs.k8s.io/structured-merge-diff/value/value.go @@ -18,6 +18,7 @@ package value import ( "fmt" + "sort" "strings" ) @@ -33,6 +34,85 @@ type Value struct { Null bool // represents an explicit `"foo" = null` } +// Less provides a total ordering for Value (so that they can be sorted, even +// if they are of different types). +func (v Value) Less(rhs Value) bool { + if v.FloatValue != nil { + if rhs.FloatValue == nil { + // Extra: compare floats and ints numerically. + if rhs.IntValue != nil { + return float64(*v.FloatValue) < float64(*rhs.IntValue) + } + return true + } + return *v.FloatValue < *rhs.FloatValue + } else if rhs.FloatValue != nil { + // Extra: compare floats and ints numerically. + if v.IntValue != nil { + return float64(*v.IntValue) < float64(*rhs.FloatValue) + } + return false + } + + if v.IntValue != nil { + if rhs.IntValue == nil { + return true + } + return *v.IntValue < *rhs.IntValue + } else if rhs.IntValue != nil { + return false + } + + if v.StringValue != nil { + if rhs.StringValue == nil { + return true + } + return *v.StringValue < *rhs.StringValue + } else if rhs.StringValue != nil { + return false + } + + if v.BooleanValue != nil { + if rhs.BooleanValue == nil { + return true + } + if *v.BooleanValue == *rhs.BooleanValue { + return false + } + return *v.BooleanValue == false + } else if rhs.BooleanValue != nil { + return false + } + + if v.ListValue != nil { + if rhs.ListValue == nil { + return true + } + return v.ListValue.Less(rhs.ListValue) + } else if rhs.ListValue != nil { + return false + } + if v.MapValue != nil { + if rhs.MapValue == nil { + return true + } + return v.MapValue.Less(rhs.MapValue) + } else if rhs.MapValue != nil { + return false + } + if v.Null { + if !rhs.Null { + return true + } + return false + } else if rhs.Null { + return false + } + + // Invalid Value-- nothing is set. + return false +} + type Int int64 type Float float64 type String string @@ -49,6 +129,35 @@ type List struct { Items []Value } +// Less compares two lists lexically. +func (l *List) Less(rhs *List) bool { + i := 0 + for { + if i >= len(l.Items) && i >= len(rhs.Items) { + // Lists are the same length and all items are equal. + return false + } + if i >= len(l.Items) { + // LHS is shorter. + return true + } + if i >= len(rhs.Items) { + // RHS is shorter. + return false + } + if l.Items[i].Less(rhs.Items[i]) { + // LHS is less; return + return true + } + if rhs.Items[i].Less(l.Items[i]) { + // RHS is less; return + return false + } + // The items are equal; continue. + i++ + } +} + // Map is a map of key-value pairs. It represents both structs and maps. We use // a list and a go-language map to preserve order. // @@ -59,6 +168,58 @@ type Map struct { // may be nil; lazily constructed. // TODO: Direct modifications to Items above will cause serious problems. index map[string]*Field + // may be empty; lazily constructed. + // TODO: Direct modifications to Items above will cause serious problems. + order []int +} + +func (m *Map) computeOrder() { + if len(m.order) != len(m.Items) { + m.order = make([]int, len(m.Items)) + for i := range m.order { + m.order[i] = i + } + sort.SliceStable(m.order, func(i, j int) bool { + return m.Items[m.order[i]].Name < m.Items[m.order[j]].Name + }) + } +} + +// Less compares two maps lexically. +func (m *Map) Less(rhs *Map) bool { + m.computeOrder() + rhs.computeOrder() + + i := 0 + for { + if i >= len(m.order) && i >= len(rhs.order) { + // Maps are the same length and all items are equal. + return false + } + if i >= len(m.order) { + // LHS is shorter. + return true + } + if i >= len(rhs.order) { + // RHS is shorter. + return false + } + fa, fb := &m.Items[m.order[i]], &rhs.Items[rhs.order[i]] + if fa.Name != fb.Name { + // the map having the field name that sorts lexically less is "less" + return fa.Name < fb.Name + } + if fa.Value.Less(fb.Value) { + // LHS is less; return + return true + } + if fb.Value.Less(fa.Value) { + // RHS is less; return + return false + } + // The items are equal; continue. + i++ + } } // Get returns the (Field, true) or (nil, false) if it is not present @@ -82,6 +243,20 @@ func (m *Map) Set(key string, value Value) { } m.Items = append(m.Items, Field{Name: key, Value: value}) m.index = nil // Since the append might have reallocated + m.order = nil +} + +// Delete removes the key from the set. +func (m *Map) Delete(key string) { + items := []Field{} + for i := range m.Items { + if m.Items[i].Name != key { + items = append(items, m.Items[i]) + } + } + m.Items = items + m.index = nil // Since the list has changed + m.order = nil } // StringValue returns s as a scalar string Value.