* checkpoint.
* Tried a new way.
* Some more slimplifying based on feedback.
* use bang vs == false.
* not sure why I did not use go style on this forloop, fixed.
* update dep golang.org/x/net
* Add stackdriver exporter support in pkg
* fix race and tests
* Use thread safe newMetricsExporter in tests
* address cr comments
* minor fix
* checkpoint
* Address cr comments
* add test for UpdateExporterFromConfigMap
* Move lock position
* add a test case for stackdriver error check
* minor change
* removing one test case since it seems app default creds exists for presubmit tests
* replace promSrvChan with promSrv as cr suggsted
* use a local var server for ListenAndServe
* add getter and setter for shared variables
* add func isMetricsConfigChanged and test
* address cr comments
* Update opencensus-go-exporter-stackdriver to v0.7.0
* Revert "Update opencensus-go-exporter-stackdriver to v0.7.0"
This reverts commit 9825f641f8.
* run update-deps.sh
* merge conflict
* run update-deps.sh
* Update Gopkg.toml so it doesn't have stackdriver exporter
* remove regex for metrics domain at pkg repo per cr comments
* merge conflict
This enables us to make additive changes without breaking downgrades.
Unfortunate side effect is that we don't get a nice typo checker in the
webhook :(
* Prepare for global resync on ConfigMap changes
- Add GlobalResync(cache.SharedInformer) method to *controller.Impl
- Move UntypedStore from serving/pkg/config to pkg/configmap
- Add onAfterStore callbacks to UntypedStore
- Add TypeFilter to enable composable construction of such callbacks
* Address review
- Unit test GlobalResync()
- Reimpl GlobalResync() using ListKeys()
* Update comments
* Add test for onAfterStore
* Update godoc comment for Logger
Unlike `ResourceVersion`, which changes whenever the resource changes at all (including `/status` which can be high churn), `Generation` only changes when the `/spec` of a CRD changes (for CRDs starting in 1.11, right now they are locked at `generation: 1`).
These methods are useful for interacting with K8s resource now, and will be useful for CRDs soon.
Fixes: https://github.com/knative/pkg/issues/116
There are a number of notable differences:
* Selector is part of Spec not Status,
* Selector is structured vs. `string`,
* The Replicas in Spec is a pointer.
* Move docs from knative/serving to knative/pkg
While working on knative/build-pipeline#16
I started trying to build some integration tests, and I wanted to use
the code which had been moved to knative/pkg, but it turned out the docs
hadn't been ported with the code, so I am moving the docs relevant to
knative/pkg/test to that repo.
Removing docs from knative/serving in https://github.com/knative/serving/pull/2097.
* Fix knative/serving specific docs
Fixed copy-pasted references to `knative/serving/test` which should be
`knative/pkg/test`.
Fixed examples which were specific to `knative/serving`; in the case of
the command arg examples, removed the parts which are specific to those
e2e tests (though this would make them harder to use by copy and paste,
but since the libs are in a common repo now anyway that's probably
okay).
Tried to make the metric legend easier to read.
Some systems may not have `/bin/bash` (NixOS for example)… Using
`/usr/bin/env bash` has the benefit of looking for whatever the
default version of the program is in your current environment.
Signed-off-by: Vincent Demeester <vdemeest@redhat.com>
* Change VerifyType to return an error instead of panicking
Signed-off-by: Vincent Demeester <vdemeest@redhat.com>
* Move the use of `VerifyType` in tests
Those calls to `duck.VerifyType` are done at runtime and thus could be
costly at program startup. Putting them under tests ensure we still
assert those types but during unit testing.
Signed-off-by: Vincent Demeester <vdemeest@redhat.com>
To use this with a typical informer, e.g. the way `Route` would monitor `Configurations` and `Revisions`, you'd do something like:
```go
c := &Reconciler{
Base: reconciler.NewBase(opt, controllerAgentName),
...
}
impl := controller.NewImpl(c, c.Logger, "Routes")
t := New(impl.EnqueueKey, 30*time.Minute)
configInformer.Informer().AddEventHandler(cache.ResourceEventHandlerFuncs{
AddFunc: t.OnChanged,
UpdateFunc: controller.PassNew(t.OnChanged),
})
revisionInformer.Informer().AddEventHandler(cache.ResourceEventHandlerFuncs{
AddFunc: t.OnChanged,
UpdateFunc: controller.PassNew(t.OnChanged),
})
// Now use c.tracker.Track(revisionRef, route) or c.tracker.Track(configRef, route)
// each Reconcile(route) to refresh the cross-object leases.
c.tracker = t
```
To use this with a `duck.InformerFactory`, e.g. the way `Revision` will monitor `BuildRef`s you'd do something like:
```go
c := &Reconciler{
Base: reconciler.NewBase(opt, controllerAgentName),
...
}
impl := controller.NewImpl(c, c.Logger, "Revisions")
t := New(impl.EnqueueKey, 30*time.Minute)
cif := &duck.CachedInformerFactory{
Delegate: &duck.EnqueueInformerFactory{
Delegate: buildInformerFactory,
EventHandler: cache.ResourceEventHandlerFuncs{
AddFunc: t.OnChanged,
UpdateFunc: controller.PassNew(t.OnChanged),
},
},
}
// Now use: `c.buildInformerFactory.Get()` to access ObjectReferences.
c.buildInformerFactory = buildInformerFactory
// Now use: `c.tracker.Track(rev.Spec.BuildRef, rev)` to queue `rev`
// each time `rev.Spec.BuildRef` changes (expires 30 minutes after BuildRef
// points to something else).
c.tracker = t
```
Fixes: https://github.com/knative/pkg/issues/94
* Use reflection to get and set conditions.
* Update comment.
* limiting the object on the way in, no need to double check it is a struct.
* Reorder the class, and add a comment for getConditions
* Adding relection and duck type checking.
* Fix typos.
This defines a simple test duck type called PodSpecable, which has the same shape for embedding a corev1.PodTemplateSpec as numerous core Kubernetes resource: ReplicaSet, Deployment, StatefulSet, DaemonSet, and Job.
This starts to sketch common libraries for instantiating informers/listers for a particular GroupVersionResource as one of our duck types.
You can instantiate a duck.InformerFactory like so:
```go
dynaClient, err := dynamic.NewForConfig(cfg)
if err != nil {
logger.Fatalf("Error building dynamic clientset: %v", err)
}
// Cache as the outermost layer so we only register the EventHandler once.
dif := &duck.CachedInformerFactory{
Delegate: &duck.EnqueueInformerFactory{
Delegate: &duck.TypedInformerFactory{
Client: dynaClient,
Type: &duckv1alpha1.Target{},
ResyncPeriod: 30 * time.Second,
StopChannel: stopCh,
},
EventHandler: cache.ResourceEventHandlerFuncs{
AddFunc: func(obj interface{}) {
// Enqueue, obj is: *duckerv1alpha1.Target
},
UpdateFunc: func(old, new interface{}) {
// Enqueue, old and new are: *duckerv1alpha1.Target
},
},
},
}
```
Then, as you come across new GroupVersionResources that you want to handle:
```go
informer, lister, err := dif.Get(gvr)
if err != nil {
logger.Fatalf("Error starting shared index informer: %v", err)
}
```
With the `duck.TypedInformerFactory` the objects will be returned as the provided `Type:`, so in this example, you could safely write:
```go
elt, err := lister.ByNamespace(ns).Get(name)
if err != nil { ... }
target := elt.(*duckv1alpha1.Target)
// Stuff involving target.
```
The rate limiting queue makes the sleep necessary. Locally I see 0-2 failures when this is run with -count=10000. This bumps the sleep slightly to reduce this further.
Fixes: https://github.com/knative/pkg/issues/56
* first cut of defining Subscribable and Channelable
* address pr feedback
* remove now unnecessary From*Unstructured conversions
* address pr comments, add util_test
* Introduce LegacyTarget and make Target more structured
* add extra level of structure in Sinkable
* move util* to duck/util, change Sinkable string to SinkableDomain as per pr comments
* add callableDomain
* oops
* address PR feedback
* clarify comments
* Move util to pkg/duck
* Normalize the names of Status structs.