mirror of https://github.com/knative/caching.git
upgrade to latest dependencies (#385)
Signed-off-by: Knative Automation <automation@knative.team>
This commit is contained in:
parent
b4514d8249
commit
ee88f74454
5
go.mod
5
go.mod
|
@ -11,13 +11,14 @@ require (
|
|||
github.com/sergi/go-diff v1.1.0 // indirect
|
||||
github.com/tsenart/go-tsz v0.0.0-20180814235614-0bd30b3df1c3 // indirect
|
||||
github.com/tsenart/vegeta v12.7.1-0.20190725001342-b5f4fca92137+incompatible
|
||||
go.uber.org/multierr v1.6.0 // indirect
|
||||
k8s.io/api v0.18.8
|
||||
k8s.io/apimachinery v0.18.8
|
||||
k8s.io/client-go v11.0.1-0.20190805182717-6502b5e7b1b5+incompatible
|
||||
k8s.io/code-generator v0.18.8
|
||||
k8s.io/kube-openapi v0.0.0-20200410145947-bcb3869e6f29
|
||||
knative.dev/hack v0.0.0-20201103151104-3d5abc3a0075
|
||||
knative.dev/pkg v0.0.0-20201103150904-7f1970af5b6f
|
||||
knative.dev/hack v0.0.0-20201112185459-01a34c573bd8
|
||||
knative.dev/pkg v0.0.0-20201112201059-93fedf141385
|
||||
)
|
||||
|
||||
replace (
|
||||
|
|
8
go.sum
8
go.sum
|
@ -1129,12 +1129,12 @@ k8s.io/kube-openapi v0.0.0-20200410145947-61e04a5be9a6/go.mod h1:GRQhZsXIAJ1xR0C
|
|||
k8s.io/utils v0.0.0-20200324210504-a9aa75ae1b89/go.mod h1:sZAwmy6armz5eXlNoLmJcl4F1QuKu7sr+mFQ0byX7Ew=
|
||||
k8s.io/utils v0.0.0-20200603063816-c1c6865ac451 h1:v8ud2Up6QK1lNOKFgiIVrZdMg7MpmSnvtrOieolJKoE=
|
||||
k8s.io/utils v0.0.0-20200603063816-c1c6865ac451/go.mod h1:jPW/WVKK9YHAvNhRxK0md/EJ228hCsBRufyofKtW8HA=
|
||||
knative.dev/hack v0.0.0-20201102193445-9349aeeb6701 h1:at6mUfi8gHWlBRd/qNM66JvUQ4C964cOpsy9hzac+7c=
|
||||
knative.dev/hack v0.0.0-20201102193445-9349aeeb6701/go.mod h1:PHt8x8yX5Z9pPquBEfIj0X66f8iWkWfR0S/sarACJrI=
|
||||
knative.dev/hack v0.0.0-20201103151104-3d5abc3a0075 h1:YAgWplKIy4O5e3F5vUUECmXAAyZ0M5ymo6fCt1jeZhs=
|
||||
knative.dev/hack v0.0.0-20201103151104-3d5abc3a0075/go.mod h1:PHt8x8yX5Z9pPquBEfIj0X66f8iWkWfR0S/sarACJrI=
|
||||
knative.dev/pkg v0.0.0-20201103150904-7f1970af5b6f h1:Ezruo8zcoA6RA8KiP8JH4K7RSjkddjlhvP9CcooWO4Q=
|
||||
knative.dev/pkg v0.0.0-20201103150904-7f1970af5b6f/go.mod h1:2hMxAUviPH2nl3BuODx5L6shYCdzA+7SPzQpdkcg9wc=
|
||||
knative.dev/hack v0.0.0-20201112185459-01a34c573bd8 h1:RNbZsAjhswBPtl4C5C5gEFX5/GfWIOZQxfYD9DhkHdY=
|
||||
knative.dev/hack v0.0.0-20201112185459-01a34c573bd8/go.mod h1:PHt8x8yX5Z9pPquBEfIj0X66f8iWkWfR0S/sarACJrI=
|
||||
knative.dev/pkg v0.0.0-20201112201059-93fedf141385 h1:DcYWVnDpcvKZR/Rh+8X2Qkq89jbBo6yLNV1qBifovBk=
|
||||
knative.dev/pkg v0.0.0-20201112201059-93fedf141385/go.mod h1:5vNHKNtZtzlNeNrcDoUtZIn+dma/8DjmpjfdHiwoQyM=
|
||||
pgregory.net/rapid v0.3.3/go.mod h1:UYpPVyjFHzYBGHIxLFoupi8vwk6rXNzRY9OMvVxFIOU=
|
||||
rsc.io/binaryregexp v0.2.0/go.mod h1:qTv7/COck+e2FymRvadv62gMdZztPaShugOCi3I+8D8=
|
||||
rsc.io/quote/v3 v3.1.0/go.mod h1:yEA65RcK8LyAZtP9Kv3t0HmxON59tX3rD+tICJqUlj0=
|
||||
|
|
|
@ -220,7 +220,7 @@ benchmarking jobs for each repo. To use it:
|
|||
- `SERVICE_ACCOUNT_NAME`: Service account name for controlling GKE clusters
|
||||
and interacting with [Mako](https://github.com/google/mako) server. It MUST
|
||||
have `Kubernetes Engine Admin` and `Storage Admin` role, and be
|
||||
[whitelisted](https://github.com/google/mako/blob/master/docs/ACCESS.md) by
|
||||
[allowed](https://github.com/google/mako/blob/master/docs/ACCESS.md) by
|
||||
Mako admin. Defaults to `mako-job`.
|
||||
|
||||
1. [optional] Customize root path of the benchmarks. This root folder should
|
||||
|
|
|
@ -353,13 +353,10 @@ function report_go_test() {
|
|||
report="$(mktemp)"
|
||||
local xml
|
||||
xml="$(mktemp_with_extension "${ARTIFACTS}"/junit_XXXXXXXX xml)"
|
||||
local json
|
||||
json="$(mktemp_with_extension "${ARTIFACTS}"/json_XXXXXXXX json)"
|
||||
echo "Running go test with args: ${go_test_args[*]}"
|
||||
# TODO(chizhg): change to `--format testname`?
|
||||
capture_output "${report}" gotestsum --format "${GO_TEST_VERBOSITY:-standard-verbose}" \
|
||||
--junitfile "${xml}" --junitfile-testsuite-name relative --junitfile-testcase-classname relative \
|
||||
--jsonfile "${json}" \
|
||||
-- "${go_test_args[@]}"
|
||||
local failed=$?
|
||||
echo "Finished run, return code is ${failed}"
|
||||
|
@ -517,7 +514,7 @@ function go_update_deps() {
|
|||
echo "=== Update Deps for Golang"
|
||||
|
||||
local UPGRADE=0
|
||||
local VERSION="master"
|
||||
local VERSION="v9000.1" # release v9000 is so far in the future, it will always pick the default branch.
|
||||
local DOMAIN="knative.dev"
|
||||
while [[ $# -ne 0 ]]; do
|
||||
parameter=$1
|
||||
|
|
|
@ -65,7 +65,10 @@ func NewLogger(configJSON string, levelOverride string, opts ...zap.Option) (*za
|
|||
if err2 != nil {
|
||||
panic(err2)
|
||||
}
|
||||
return enrichLoggerWithCommitID(logger.Named(fallbackLoggerName)), loggingCfg.Level
|
||||
|
||||
slogger := enrichLoggerWithCommitID(logger.Named(fallbackLoggerName))
|
||||
slogger.Warnw("Failed to parse logging config - using default zap production config", zap.Error(err))
|
||||
return slogger, loggingCfg.Level
|
||||
}
|
||||
|
||||
func enrichLoggerWithCommitID(logger *zap.Logger) *zap.SugaredLogger {
|
||||
|
|
|
@ -60,7 +60,9 @@ const (
|
|||
defaultPrometheusPort = 9090
|
||||
maxPrometheusPort = 65535
|
||||
minPrometheusPort = 1024
|
||||
defaultPrometheusHost = "0.0.0.0"
|
||||
prometheusPortEnvName = "METRICS_PROMETHEUS_PORT"
|
||||
prometheusHostEnvName = "METRICS_PROMETHEUS_HOST"
|
||||
)
|
||||
|
||||
// Metrics backend "enum".
|
||||
|
@ -105,6 +107,10 @@ type metricsConfig struct {
|
|||
// format. It defaults to 9090.
|
||||
prometheusPort int
|
||||
|
||||
// prometheusHost is the host where the metrics are exposed in Prometheus
|
||||
// format. It defaults to "0.0.0.0"
|
||||
prometheusHost string
|
||||
|
||||
// ---- Stackdriver specific below ----
|
||||
// True if backendDestination equals to "stackdriver". Store this in a variable
|
||||
// to reduce string comparison operations.
|
||||
|
@ -240,6 +246,7 @@ func createMetricsConfig(ctx context.Context, ops ExporterOptions) (*metricsConf
|
|||
}
|
||||
|
||||
mc.prometheusPort = pp
|
||||
mc.prometheusHost = prometheusHost()
|
||||
case stackdriver:
|
||||
// If stackdriverClientConfig is not provided for stackdriver backend destination, OpenCensus will try to
|
||||
// use the application default credentials. If that is not available, Opencensus would fail to create the
|
||||
|
@ -341,6 +348,17 @@ func prometheusPort() (int, error) {
|
|||
return int(pp), nil
|
||||
}
|
||||
|
||||
// prometheusHost returns the host configured via the environment
|
||||
// for the Prometheus metrics exporter if it's set, a default value otherwise.
|
||||
// No validation is done here.
|
||||
func prometheusHost() string {
|
||||
phStr := os.Getenv(prometheusHostEnvName)
|
||||
if phStr == "" {
|
||||
return defaultPrometheusHost
|
||||
}
|
||||
return phStr
|
||||
}
|
||||
|
||||
// JSONToOptions converts a json string to ExporterOptions.
|
||||
func JSONToOptions(jsonOpts string) (*ExporterOptions, error) {
|
||||
var opts ExporterOptions
|
||||
|
|
|
@ -66,10 +66,15 @@ type ExporterOptions struct {
|
|||
|
||||
// PrometheusPort is the port to expose metrics if metrics backend is Prometheus.
|
||||
// It should be between maxPrometheusPort and maxPrometheusPort. 0 value means
|
||||
// using the default 9090 value. If is ignored if metrics backend is not
|
||||
// using the default 9090 value. It is ignored if metrics backend is not
|
||||
// Prometheus.
|
||||
PrometheusPort int
|
||||
|
||||
// PrometheusHost is the host to expose metrics on if metrics backend is Prometheus.
|
||||
// The default value is "0.0.0.0". It is ignored if metrics backend is not
|
||||
// Prometheus.
|
||||
PrometheusHost string
|
||||
|
||||
// ConfigMap is the data from config map config-observability. Must be present.
|
||||
// See https://github.com/knative/serving/blob/master/config/config-observability.yaml
|
||||
// for details.
|
||||
|
|
|
@ -17,8 +17,8 @@ limitations under the License.
|
|||
package metrics
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"net/http"
|
||||
"strconv"
|
||||
"sync"
|
||||
|
||||
prom "contrib.go.opencensus.io/exporter/prometheus"
|
||||
|
@ -41,6 +41,7 @@ func (emptyPromExporter) ExportView(viewData *view.Data) {
|
|||
// a signal to enrich the internal Meters with Resource information.
|
||||
}
|
||||
|
||||
//nolint: unparam // False positive of flagging the second result of this function unused.
|
||||
func newPrometheusExporter(config *metricsConfig, logger *zap.SugaredLogger) (view.Exporter, ResourceExporterFactory, error) {
|
||||
e, err := prom.NewExporter(prom.Options{Namespace: config.component})
|
||||
if err != nil {
|
||||
|
@ -50,7 +51,7 @@ func newPrometheusExporter(config *metricsConfig, logger *zap.SugaredLogger) (vi
|
|||
logger.Infof("Created Opencensus Prometheus exporter with config: %v. Start the server for Prometheus exporter.", config)
|
||||
// Start the server for Prometheus scraping
|
||||
go func() {
|
||||
srv := startNewPromSrv(e, config.prometheusPort)
|
||||
srv := startNewPromSrv(e, config.prometheusHost, config.prometheusPort)
|
||||
srv.ListenAndServe()
|
||||
}()
|
||||
return e,
|
||||
|
@ -73,7 +74,7 @@ func resetCurPromSrv() {
|
|||
}
|
||||
}
|
||||
|
||||
func startNewPromSrv(e *prom.Exporter, port int) *http.Server {
|
||||
func startNewPromSrv(e *prom.Exporter, host string, port int) *http.Server {
|
||||
sm := http.NewServeMux()
|
||||
sm.Handle("/metrics", e)
|
||||
curPromSrvMux.Lock()
|
||||
|
@ -82,7 +83,7 @@ func startNewPromSrv(e *prom.Exporter, port int) *http.Server {
|
|||
curPromSrv.Close()
|
||||
}
|
||||
curPromSrv = &http.Server{
|
||||
Addr: fmt.Sprint(":", port),
|
||||
Addr: host + ":" + strconv.Itoa(port),
|
||||
Handler: sm,
|
||||
}
|
||||
return curPromSrv
|
||||
|
|
|
@ -216,9 +216,18 @@ func isExpired(expiry time.Time) bool {
|
|||
|
||||
// OnChanged implements Interface.
|
||||
func (i *impl) OnChanged(obj interface{}) {
|
||||
observers := i.GetObservers(obj)
|
||||
|
||||
for _, observer := range observers {
|
||||
i.cb(observer)
|
||||
}
|
||||
}
|
||||
|
||||
// GetObservers implements Interface.
|
||||
func (i *impl) GetObservers(obj interface{}) []types.NamespacedName {
|
||||
item, err := kmeta.DeletionHandlingAccessor(obj)
|
||||
if err != nil {
|
||||
return
|
||||
return nil
|
||||
}
|
||||
|
||||
or := kmeta.ObjectReference(item)
|
||||
|
@ -229,14 +238,9 @@ func (i *impl) OnChanged(obj interface{}) {
|
|||
Name: or.Name,
|
||||
}
|
||||
|
||||
i.m.Lock()
|
||||
// Call the callbacks without the lock held.
|
||||
var keys []types.NamespacedName
|
||||
defer func(cb func(types.NamespacedName)) {
|
||||
for _, key := range keys {
|
||||
cb(key)
|
||||
}
|
||||
}(i.cb) // read i.cb with the lock held
|
||||
|
||||
i.m.Lock()
|
||||
defer i.m.Unlock()
|
||||
|
||||
// Handle exact matches.
|
||||
|
@ -274,6 +278,8 @@ func (i *impl) OnChanged(obj interface{}) {
|
|||
delete(i.exact, ref)
|
||||
}
|
||||
}
|
||||
|
||||
return keys
|
||||
}
|
||||
|
||||
// OnChanged implements Interface.
|
||||
|
|
|
@ -23,6 +23,7 @@ import (
|
|||
corev1 "k8s.io/api/core/v1"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/apimachinery/pkg/runtime/schema"
|
||||
"k8s.io/apimachinery/pkg/types"
|
||||
"k8s.io/apimachinery/pkg/util/validation"
|
||||
|
||||
"knative.dev/pkg/apis"
|
||||
|
@ -71,6 +72,10 @@ type Interface interface {
|
|||
// so that we are notified for appropriate object changes.
|
||||
OnChanged(obj interface{})
|
||||
|
||||
// GetObservers returns the names of all observers for the given
|
||||
// object.
|
||||
GetObservers(obj interface{}) []types.NamespacedName
|
||||
|
||||
// OnDeletedObserver is a callback to register with the InformerFactory
|
||||
// so that we are notified for deletions of a watching parent to
|
||||
// remove the respective tracking.
|
||||
|
|
|
@ -221,6 +221,7 @@ go.opencensus.io/trace/tracestate
|
|||
# go.uber.org/atomic v1.7.0
|
||||
go.uber.org/atomic
|
||||
# go.uber.org/multierr v1.6.0
|
||||
## explicit
|
||||
go.uber.org/multierr
|
||||
# go.uber.org/zap v1.16.0
|
||||
go.uber.org/zap
|
||||
|
@ -738,10 +739,10 @@ k8s.io/kube-openapi/pkg/util/sets
|
|||
k8s.io/utils/buffer
|
||||
k8s.io/utils/integer
|
||||
k8s.io/utils/trace
|
||||
# knative.dev/hack v0.0.0-20201103151104-3d5abc3a0075
|
||||
# knative.dev/hack v0.0.0-20201112185459-01a34c573bd8
|
||||
## explicit
|
||||
knative.dev/hack
|
||||
# knative.dev/pkg v0.0.0-20201103150904-7f1970af5b6f
|
||||
# knative.dev/pkg v0.0.0-20201112201059-93fedf141385
|
||||
## explicit
|
||||
knative.dev/pkg/apis
|
||||
knative.dev/pkg/apis/duck
|
||||
|
|
Loading…
Reference in New Issue