Commit Graph

756 Commits

Author SHA1 Message Date
JUN JIE NAN 27b3dc39ad Fixed knative activator handshake timeout issue (#836)
The original handshake timeout is too short to dial connection
successfully under some situation. So the activator pod can not be
active. And the log message just say "Failed to send ping message to
ws://autoscaler.knative-serving.svc.cluster.local:8080", not easy to
figure out what's the problem underneeth.

The fix switch to websocket default dial, so the default handle shake
time is 45 seconds, and once dial error found, the error will be
reported as error.
2019-11-18 23:19:07 -08:00
Matt Moore d752898438 Make PodSpeccable a real thing (#884) 2019-11-18 08:02:08 -08:00
coryrc d9e3e244a6 Allow glog to coexist with klog (#881)
* Allow glog to coexist with klog

glog isn't used in our repos with good reason, but performance tests
use it, for now. This commit removes the ability to set klog flags
that aren't shared with glog, in return for the ability of glog to be imported.

* update-codegen
2019-11-15 10:57:02 -08:00
Matt Moore 4836f680bb Split the resource semantic webhooks into separate AdmissionControllers (#848)
By combining our validation logic into our mutating webhook we were previously allowing for mutating webhooks evaluated after our own to modify our resources into invalid shapes.  There are no guarantees around ordering of mutating webhooks (that I could find), so the only way to remedy this properly is to split apart the two into separate webhook configurations:
 - `defaulting`: which runs during the mutating admission webhook phase
 - `validation`: which runs during the validating admission webhook phase.

The diagram in [this post](https://kubernetes.io/blog/2019/03/21/a-guide-to-kubernetes-admission-controllers/) is very helpful in illustrating the flow of webhooks.

Fixes: https://github.com/knative/pkg/issues/847
2019-11-14 16:51:02 -08:00
coryrc 3525756c2a Address serving#5949 by putting flag initialization into pkg. (#870)
Created a unit test for flag setup.
Use Subtests for table-driven tests.

Moved from https://github.com/knative/serving/pull/5984
2019-11-14 16:33:02 -08:00
Matt Moore 80da64a31c golang format tools (#879)
Produced via:
  `gofmt -s -w $(find -path './vendor' -prune -o -type f -name '*.go' -print))`
  `goimports -w $(find -name '*.go' | grep -v vendor)`
/assign n3wscott
2019-11-14 11:06:31 -08:00
coryrc d3841ea2c3 Remove ugly constant string being printed in every log. (#878)
In every log we get the ugly string printed:
2019-11-13T08:44:42.421-0800    info    logging/config.go:50
Successfully created the logger.    {"knative.dev/jsonconfig": "{\n\t
\"level\": \"debug\",\n\t  \"encoding\": \"console\",\n\t
\"outputPaths\": [\"stdout\"],\n\t  \"errorOutputPaths\":
[\"stderr\"],\n\t  \"encoderConfig\": {\n\t    \"timeKey\":
\"ts\",\n\t    \"messageKey\": \"message\",\n\t    \"levelKey\":
\"level\",\n\t    \"nameKey\": \"logger\",\n\t    \"callerKey\":
\"caller\",\n\t    \"messageKey\": \"msg\",\n\t    \"stacktraceKey\":
\"stacktrace\",\n\t    \"lineEnding\": \"\",\n\t    \"levelEncoder\":
\"\",\n\t    \"timeEncoder\": \"iso8601\",\n\t    \"durationEncoder\":
\"\",\n\t    \"callerEncoder\": \"\"\n\t  }\n\t}"}

It's all a constant (see test/logging/logging.go:newLogger), except
"level", which is then printed immediately afterward. So just remove
printing this string.
2019-11-13 19:30:28 -08:00
Matt Moore 0b70cd6820 Auto-update dependencies (#877)
Produced via:
  `dep ensure -update knative.dev/test-infra`
/assign n3wscott
2019-11-13 17:22:28 -08:00
Matt Moore e96196e347 golang format tools (#876)
Produced via:
  `gofmt -s -w $(find -path './vendor' -prune -o -type f -name '*.go' -print))`
  `goimports -w $(find -name '*.go' | grep -v vendor)`
/assign n3wscott
2019-11-13 15:49:28 -08:00
Vincent 94911510c3 Skip watching the ConfigMaps if they are missing (#872)
* Skip watching the ConfigMaps if they are missing

* Log the error message
2019-11-13 15:17:29 -08:00
Matt Moore 9283d2c32c Format markdown (#875)
Produced via:
  `prettier --write --prose-wrap=always $(find -name '*.md' | grep -v vendor | grep -v .github)`
/assign n3wscott
2019-11-13 15:08:28 -08:00
Nima Kaviani 4deb5d83d2 move metrics config to pkg (#786)
the observability config is used in other packages including
the sample controller. This commit pulls observability config
into knative.dev/pkg similar to logging config for better reusability.
2019-11-13 06:52:28 -08:00
Adriano Cunha 6335100d29 Allow passing options to NewSDKClient() (#864) 2019-11-11 15:00:22 -08:00
Matt Moore 6d806b9983 Add support for Selector in tracker.Reference. (#861)
* Add support for Selector in tracker.Reference.

`tracker.Reference` may now optionally replace `Name` with `Selector` to track zero or multiple resources of a particular `apiVersion`, `kind` and `namespace`.

Fixes: https://github.com/knative/pkg/issues/859

* Address code review comments
2019-11-11 07:05:21 -08:00
Matt Moore a805b647f3 Expand the tracker interface to include a variant with its own type. (#860)
`TrackReference` is the same as `Track`, but takes a `tracker.Reference` instead.  This type has been seeded with the subset of `corev1.ObjectReference` that the tracker currently consumes / supports, but the intention is to expand this type to allow inexact references that (optionally) use label selectors in place of name to reference objects.

See also: https://github.com/knative/pkg/issues/859
2019-11-10 09:04:12 -08:00
Victor Agababov e4e8788a2c Fix the race in the webhook test. (#858)
The usual stuff: logger after test terminated.

/assign mattmoor
2019-11-08 10:24:56 -08:00
Markus Thömmes 9bdf8c1c8f Add Namespace index to listers in tests. (#857)
Not having this causes the listers to log an annoying log message like

W1108 02:48:54.848573  211995 listers.go:77] can not retrieve list of objects using index : Index with name namespace does not exist

That message doesn't cause the tests to fail because the cache logic works around by doing a "slow indexing". I was very confused by this log though and sunk a bit of time into debugging it, so here we go.
2019-11-08 04:23:56 -08:00
Francesco Guardiani f0da42d387 Made ReadProfilingKey method public and more generic (#852)
* Made ReadProfilingKey method public and more generic

* Removed old readProfilingFlag
2019-11-07 06:31:55 -08:00
Matt Moore 285df36be4 Move Destination under knative.dev/pkg/apis/duck/v1. (#851)
Destination sits in a strange versioned directory without a group under APIs.  Destination is in fact part of our duck type space, so it belongs under the `duck` group.  This moves the definition (previously v1alpha1) to `v1` because it is referenced from source types that have been designated `v1`.
2019-11-06 15:59:02 -08:00
Ignacio (Nacho) Cano 93838817ef Eventing StackDriver internal metrics (#846)
* marking the metrics as internal as we need to pre-process them to include
pod_name and container_name...

* removing eventSource

* updates

* rollbacking changes to source

* updating changes to source

* minimizing change

* minimizing change
2019-11-06 10:38:03 -08:00
Yanwei Guo 7d0779c71d Add fake functions for GCP metadata and Stackdriver back (#850)
* add fack back

* rename
2019-11-05 15:51:02 -08:00
Antoine Cotten 1cc9641c28 Remove openapi-gen annotations (#775) 2019-11-05 13:03:27 -08:00
Ville Aikas 6fbbb282a0 remove vaikas-google since was replaced with vaikas (#849) 2019-11-05 10:31:27 -08:00
Scott Nichols cdc2959956 adding note about undoing release staging. (#845) 2019-11-04 18:32:22 -08:00
Matt Moore 32c3cb1914 Remove cloudevents in favor of the upstream SDK. (#844) 2019-11-04 16:48:21 -08:00
Maisem Ali 64ed9fcf84 add EnqueueSentinel to pkg/controller (#841)
* add EnqueueSentinel to pkg/controller

* address comments
2019-11-04 16:22:20 -08:00
Evan Anderson a9bdd123b7 Start moving Stackdriver and Prometheus-specific code to a strategy pattern (#812)
* Start moving Stackdriver and Prometheus-specific code to a strategy pattern.

* Respond to review feedback, add test.

* gofmt
2019-11-04 16:05:21 -08:00
Annie Fu 4d39b058e2 Restrict metric pkg Stackdriver Secret to controlled name & namespace (#824)
* Restrict Stackdriver Secret to controlled name & namespace

* Address PR comments

* Lock when reading secret name & namespace

* Export StackdriverClientConfig struct so consumers don't have to
redefine it

* Ensure metrics pkg consumers call SetStackdriverSecretLocation to set
Secret name and namespace

* Export StackdriverClientConfig consts & helper function

* Add TODO for secret watcher
2019-11-04 11:57:19 -08:00
Markus Thömmes 56c2594e4f Assorted linting fixes. (#840)
* Remove unused code.

* Remove unneeded loops.

* Remove unneeded Printf calls.

* Use time.Since instead of time.Now().Sub.

* Remove unused values.

* Rename error variable according to conventions.

* Return error last.

* Simplify array allocations.

* Remove leaky ticker.

* Remove Yoda conditions.

* Remove deprecated function to talk to GKE.

* Remove dot import.

* Remove empty critical section and replace with a channel operation.

* Add linter directives to explicitly state wanted weirdness.

* Update deps.

* Fix broken line.
2019-11-01 12:49:12 -07:00
Matt Moore d4ce001394 This refactors our core webhook logic to be reconciler-based. (#833)
This is the culmination of a large number of changes to refactor our webhook logic, and adopt a reconciler-based approach to make it resilient to unexected system events (e.g. rogue GCs!).

For more details on how this is consumed, see the new `webhook/README.md`.

Fixes: https://github.com/knative/pkg/issues/782
Closes: https://github.com/knative/pkg/issues/529
Fixes: https://github.com/knative/pkg/issues/450
Related: https://github.com/knative/pkg/issues/141
2019-10-31 10:17:13 -07:00
mattmoor-sockpuppet 0d45f1cc9d Auto-update dependencies (#837)
Produced via:
  `dep ensure -update knative.dev/test-infra`
/assign mattmoor
2019-10-31 08:15:12 -07:00
Matt Moore 340e3aefcd Add vaikas to OWNERS via new account (#835) 2019-10-30 20:48:12 -07:00
Joyce Liu bbe1367911 Moved junit from test-infra to pkg (#834) 2019-10-30 11:44:12 -07:00
Matt Moore 0442aed564 Create a new singleton Reconciler for the webhook secret. (#832)
* Create a new singleton Reconciler for the webhook secret.

This change creates a new Reconciler (not yet hooked up) that ensures that the
webhook secret has the appropriate shape.  I call this a "singleton Reconciler"
because this reconciler exists to effectively reconcile a single resource, which
will be a pattern for the webhook's reconcilers.

* Address linter problems
2019-10-30 08:23:13 -07:00
Matt Moore 3732de5802 Split secret creation into our reconciler resources style. (#830) 2019-10-29 23:08:11 -07:00
Matt Moore 50398a29a7 Factor out test helpers to prepare for webhook package split. (#829) 2019-10-29 14:13:11 -07:00
Matt Moore cc1ba8e560 Expand sharedmain to support launching our webhook. (#828)
With the simplified `webhook.New` signature, this supports detecting when one or more of the controllers we have launched has a `Reconciler` that implements `webhook.AdmissionController` and launching the webhook with this admission controllers registered.

There is still work that needs to be done to refactor the webhooks to follow this shape, but this hopefully starts to paint the picture of where things are headed.
2019-10-29 13:29:11 -07:00
Matt Moore 7772e2f583 Drive GetCertificate from the lister cache of a secret informer. (#825) 2019-10-29 07:11:12 -07:00
Matt Moore 349698bdf8 Remove vestigial createDeployment (#827)
This is no longer necessary now that we have eliminated our usage of OwnerReferences in the webhook.
2019-10-28 22:07:11 -07:00
Matt Moore e7f80de1ce Avoid registering webhook metrics with init() (#826)
With this change folks will need to call `webhook.RegisterMetrics()` to register the opencensus view with the metrics for the webhook's StatsReporter.  This is needed to avoid having `sharedmain` crashloop the activator due to linking multiple on-`init()` views that register metrics named `request_latencies`.

In general, I believe that we should move away from registering these views via `init()` and more towards the broader K8s MetricsProvider pattern.
2019-10-28 22:02:11 -07:00
Chi Zhang 392d931b4b Slack MessageHistory only returns messages sent by the current user (#814)
* MessageHistory only returns messages sent by the current user

* check message history for each test

* address comments
2019-10-28 19:55:11 -07:00
Matt Moore bfff3b7d72 Switch to using GetCertificate in tls.Config. (#823)
GetCertificate allows us to start in TLS mode and dynamically fetch new certificates as they change.  This will eventually allow us to decouple the cert creation process from the core webhook logic, and in a subsequent change service this from a secret lister cache.
2019-10-28 17:32:11 -07:00
Matt Moore da49e89aa8 Remove options to specify ClientAuth. (#822)
We don't use this anywhere in Knative downstream and it adds a bunch of complexity.
2019-10-28 16:50:11 -07:00
Matt Moore 763c642d3c Streamline `webhook.New`. (#821)
This now pulls most of its configuration from context, which brings it a step closer to aligning with our `sharedmain` package.
2019-10-28 16:12:11 -07:00
Matt Moore 3f2100ca91 Move WithContext into the resource admission controller. (#820) 2019-10-28 15:05:11 -07:00
Matt Moore aaf36e26c7 Accept a list of AdmissionControllers instead of a map (#819) 2019-10-28 14:09:11 -07:00
Matt Moore de53b8f09f Move hook-specific configuration options out of shared options. (#818)
This builds on https://github.com/knative/pkg/pull/817 and makes further
breaking changes. The options pertinent to each admission controller are
now passed to their respective constructors, which leads to a cleaner
options struct, and better prepares for greater webhook diversity.
2019-10-28 13:31:11 -07:00
Matt Moore 070396a075 Eliminate the Namespace config option in favor of system.Namespace. (#817) 2019-10-28 11:41:43 -07:00
Matt Moore 809ce573e4 Add FilterByName for cluster-scoped resources. (#816)
This is a precursor to reconciling named webhook configurations, and largely a copy of `FilterByNameAndNamespace`.
2019-10-28 10:41:42 -07:00
mattmoor-sockpuppet ba704ad664 Auto-update dependencies (#815)
Produced via:
  `dep ensure -update knative.dev/test-infra`
/assign mattmoor
2019-10-28 07:23:12 -07:00