mirror of https://github.com/knative/caching.git
[master] Auto-update dependencies (#239)
Produced via: `./hack/update-deps.sh --upgrade && ./hack/update-codegen.sh` /assign n3wscott vagababov /cc n3wscott vagababov
This commit is contained in:
parent
76bf917613
commit
f9a94908b8
|
@ -966,7 +966,7 @@
|
||||||
|
|
||||||
[[projects]]
|
[[projects]]
|
||||||
branch = "master"
|
branch = "master"
|
||||||
digest = "1:664207d75dbcaeab206d93b3dcd8098c59e3b6b21378af02d686579e491fc859"
|
digest = "1:18f4c5453f19fef868e3da19f815840517c4bfa28e15fb2cccd504a9b96ce68d"
|
||||||
name = "knative.dev/pkg"
|
name = "knative.dev/pkg"
|
||||||
packages = [
|
packages = [
|
||||||
"apis",
|
"apis",
|
||||||
|
@ -986,18 +986,18 @@
|
||||||
"reconciler",
|
"reconciler",
|
||||||
]
|
]
|
||||||
pruneopts = "T"
|
pruneopts = "T"
|
||||||
revision = "8a6d25b30970038d1e24ddf5f6e0cec129c9564c"
|
revision = "e2ee5bed78d74604ed87dcb761a6f6e10a2e355c"
|
||||||
|
|
||||||
[[projects]]
|
[[projects]]
|
||||||
branch = "master"
|
branch = "master"
|
||||||
digest = "1:2987a1db00b983af9e5d5281639a754fb6449eef01e6a375894829eaec17cb2a"
|
digest = "1:41da78d06d64a1eb47a1d3f8209d33af386fa8f22d1b04b25825ae5cd187be1d"
|
||||||
name = "knative.dev/test-infra"
|
name = "knative.dev/test-infra"
|
||||||
packages = [
|
packages = [
|
||||||
"scripts",
|
"scripts",
|
||||||
"tools/dep-collector",
|
"tools/dep-collector",
|
||||||
]
|
]
|
||||||
pruneopts = "UT"
|
pruneopts = "UT"
|
||||||
revision = "9a6c4b1d41ce980537cebe2b34c4b8c92fbd2b47"
|
revision = "030e4e29cb8ba9502a06b667b1450f6a725371b1"
|
||||||
|
|
||||||
[[projects]]
|
[[projects]]
|
||||||
digest = "1:8730e0150dfb2b7e173890c8b9868e7a273082ef8e39f4940e3506a481cf895c"
|
digest = "1:8730e0150dfb2b7e173890c8b9868e7a273082ef8e39f4940e3506a481cf895c"
|
||||||
|
|
|
@ -918,12 +918,12 @@
|
||||||
version = "v0.9.1"
|
version = "v0.9.1"
|
||||||
|
|
||||||
[[projects]]
|
[[projects]]
|
||||||
digest = "1:accc3bfe4e404aa53ac3621470e7cf9fce1efe48f0fabcfe6d12a72579d9d91f"
|
digest = "1:d9b9ac6943a512737f76bf3d61b08d97121c66686bc02ffc231313563230b468"
|
||||||
name = "gopkg.in/yaml.v2"
|
name = "gopkg.in/yaml.v2"
|
||||||
packages = ["."]
|
packages = ["."]
|
||||||
pruneopts = "NUT"
|
pruneopts = "NUT"
|
||||||
revision = "f221b8435cfb71e54062f6c6e99e9ade30b124d5"
|
revision = "53403b58ad1b561927d19068c655246f2db79d48"
|
||||||
version = "v2.2.4"
|
version = "v2.2.8"
|
||||||
|
|
||||||
[[projects]]
|
[[projects]]
|
||||||
digest = "1:d77b48cc0ea74f3edbc8e0515a0ce2fa2154eb414137dd4fb5a642a73296d403"
|
digest = "1:d77b48cc0ea74f3edbc8e0515a0ce2fa2154eb414137dd4fb5a642a73296d403"
|
||||||
|
|
|
@ -50,7 +50,7 @@ required = [
|
||||||
|
|
||||||
[[override]]
|
[[override]]
|
||||||
name = "gopkg.in/yaml.v2"
|
name = "gopkg.in/yaml.v2"
|
||||||
version = "v2.2.4"
|
version = "v2.2.8"
|
||||||
|
|
||||||
[[override]]
|
[[override]]
|
||||||
name = "github.com/json-iterator/go"
|
name = "github.com/json-iterator/go"
|
||||||
|
|
|
@ -232,6 +232,26 @@ func WebhookMainWithConfig(ctx context.Context, component string, cfg *rest.Conf
|
||||||
WatchLoggingConfigOrDie(ctx, cmw, logger, atomicLevel, component)
|
WatchLoggingConfigOrDie(ctx, cmw, logger, atomicLevel, component)
|
||||||
WatchObservabilityConfigOrDie(ctx, cmw, profilingHandler, logger, component)
|
WatchObservabilityConfigOrDie(ctx, cmw, profilingHandler, logger, component)
|
||||||
|
|
||||||
|
eg, egCtx := errgroup.WithContext(ctx)
|
||||||
|
eg.Go(profilingServer.ListenAndServe)
|
||||||
|
|
||||||
|
// If we have one or more admission controllers, then start the webhook
|
||||||
|
// and pass them in.
|
||||||
|
var wh *webhook.Webhook
|
||||||
|
var err error
|
||||||
|
if len(webhooks) > 0 {
|
||||||
|
// Register webhook metrics
|
||||||
|
webhook.RegisterMetrics()
|
||||||
|
|
||||||
|
wh, err = webhook.New(ctx, webhooks)
|
||||||
|
if err != nil {
|
||||||
|
logger.Fatalw("Failed to create webhook", zap.Error(err))
|
||||||
|
}
|
||||||
|
eg.Go(func() error {
|
||||||
|
return wh.Run(ctx.Done())
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
logger.Info("Starting configuration manager...")
|
logger.Info("Starting configuration manager...")
|
||||||
if err := cmw.Start(ctx.Done()); err != nil {
|
if err := cmw.Start(ctx.Done()); err != nil {
|
||||||
logger.Fatalw("Failed to start configuration manager", zap.Error(err))
|
logger.Fatalw("Failed to start configuration manager", zap.Error(err))
|
||||||
|
@ -240,27 +260,12 @@ func WebhookMainWithConfig(ctx context.Context, component string, cfg *rest.Conf
|
||||||
if err := controller.StartInformers(ctx.Done(), informers...); err != nil {
|
if err := controller.StartInformers(ctx.Done(), informers...); err != nil {
|
||||||
logger.Fatalw("Failed to start informers", zap.Error(err))
|
logger.Fatalw("Failed to start informers", zap.Error(err))
|
||||||
}
|
}
|
||||||
|
if wh != nil {
|
||||||
|
wh.InformersHaveSynced()
|
||||||
|
}
|
||||||
logger.Info("Starting controllers...")
|
logger.Info("Starting controllers...")
|
||||||
go controller.StartAll(ctx.Done(), controllers...)
|
go controller.StartAll(ctx.Done(), controllers...)
|
||||||
|
|
||||||
eg, egCtx := errgroup.WithContext(ctx)
|
|
||||||
eg.Go(profilingServer.ListenAndServe)
|
|
||||||
|
|
||||||
// If we have one or more admission controllers, then start the webhook
|
|
||||||
// and pass them in.
|
|
||||||
if len(webhooks) > 0 {
|
|
||||||
// Register webhook metrics
|
|
||||||
webhook.RegisterMetrics()
|
|
||||||
|
|
||||||
wh, err := webhook.New(ctx, webhooks)
|
|
||||||
if err != nil {
|
|
||||||
logger.Fatalw("Failed to create webhook", zap.Error(err))
|
|
||||||
}
|
|
||||||
eg.Go(func() error {
|
|
||||||
return wh.Run(ctx.Done())
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
// This will block until either a signal arrives or one of the grouped functions
|
// This will block until either a signal arrives or one of the grouped functions
|
||||||
// returns an error.
|
// returns an error.
|
||||||
<-egCtx.Done()
|
<-egCtx.Done()
|
||||||
|
|
|
@ -39,6 +39,14 @@ type AdmissionController interface {
|
||||||
Admit(context.Context, *admissionv1beta1.AdmissionRequest) *admissionv1beta1.AdmissionResponse
|
Admit(context.Context, *admissionv1beta1.AdmissionRequest) *admissionv1beta1.AdmissionResponse
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// StatelessAdmissionController is implemented by AdmissionControllers where Admit may be safely
|
||||||
|
// called before informers have finished syncing. This is implemented by inlining
|
||||||
|
// StatelessAdmissionImpl in your Go type.
|
||||||
|
type StatelessAdmissionController interface {
|
||||||
|
// A silly name that should avoid collisions.
|
||||||
|
ThisTypeDoesNotDependOnInformerState()
|
||||||
|
}
|
||||||
|
|
||||||
// MakeErrorStatus creates an 'BadRequest' error AdmissionResponse
|
// MakeErrorStatus creates an 'BadRequest' error AdmissionResponse
|
||||||
func MakeErrorStatus(reason string, args ...interface{}) *admissionv1beta1.AdmissionResponse {
|
func MakeErrorStatus(reason string, args ...interface{}) *admissionv1beta1.AdmissionResponse {
|
||||||
result := apierrors.NewBadRequest(fmt.Sprintf(reason, args...)).Status()
|
result := apierrors.NewBadRequest(fmt.Sprintf(reason, args...)).Status()
|
||||||
|
@ -48,8 +56,17 @@ func MakeErrorStatus(reason string, args ...interface{}) *admissionv1beta1.Admis
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func admissionHandler(rootLogger *zap.SugaredLogger, stats StatsReporter, c AdmissionController) http.HandlerFunc {
|
func admissionHandler(rootLogger *zap.SugaredLogger, stats StatsReporter, c AdmissionController, synced <-chan struct{}) http.HandlerFunc {
|
||||||
return func(w http.ResponseWriter, r *http.Request) {
|
return func(w http.ResponseWriter, r *http.Request) {
|
||||||
|
if _, ok := c.(StatelessAdmissionController); ok {
|
||||||
|
// Stateless admission controllers do not require Informers to have
|
||||||
|
// finished syncing before Admit is called.
|
||||||
|
} else {
|
||||||
|
// Don't allow admission control requests through until we have been
|
||||||
|
// notified that informers have been synchronized.
|
||||||
|
<-synced
|
||||||
|
}
|
||||||
|
|
||||||
var ttStart = time.Now()
|
var ttStart = time.Now()
|
||||||
logger := rootLogger
|
logger := rootLogger
|
||||||
logger.Infof("Webhook ServeHTTP request=%#v", r)
|
logger.Infof("Webhook ServeHTTP request=%#v", r)
|
||||||
|
@ -92,3 +109,8 @@ func admissionHandler(rootLogger *zap.SugaredLogger, stats StatsReporter, c Admi
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Inline this type to implement StatelessAdmissionController.
|
||||||
|
type StatelessAdmissionImpl struct{}
|
||||||
|
|
||||||
|
func (sai StatelessAdmissionImpl) ThisTypeDoesNotDependOnInformerState() {}
|
||||||
|
|
|
@ -43,6 +43,8 @@ import (
|
||||||
|
|
||||||
// reconciler implements the AdmissionController for ConfigMaps
|
// reconciler implements the AdmissionController for ConfigMaps
|
||||||
type reconciler struct {
|
type reconciler struct {
|
||||||
|
webhook.StatelessAdmissionImpl
|
||||||
|
|
||||||
name string
|
name string
|
||||||
path string
|
path string
|
||||||
constructors map[string]reflect.Value
|
constructors map[string]reflect.Value
|
||||||
|
@ -56,6 +58,7 @@ type reconciler struct {
|
||||||
|
|
||||||
var _ controller.Reconciler = (*reconciler)(nil)
|
var _ controller.Reconciler = (*reconciler)(nil)
|
||||||
var _ webhook.AdmissionController = (*reconciler)(nil)
|
var _ webhook.AdmissionController = (*reconciler)(nil)
|
||||||
|
var _ webhook.StatelessAdmissionController = (*reconciler)(nil)
|
||||||
|
|
||||||
// Reconcile implements controller.Reconciler
|
// Reconcile implements controller.Reconciler
|
||||||
func (ac *reconciler) Reconcile(ctx context.Context, key string) error {
|
func (ac *reconciler) Reconcile(ctx context.Context, key string) error {
|
||||||
|
|
|
@ -50,6 +50,8 @@ var errMissingNewObject = errors.New("the new object may not be nil")
|
||||||
|
|
||||||
// reconciler implements the AdmissionController for resources
|
// reconciler implements the AdmissionController for resources
|
||||||
type reconciler struct {
|
type reconciler struct {
|
||||||
|
webhook.StatelessAdmissionImpl
|
||||||
|
|
||||||
name string
|
name string
|
||||||
path string
|
path string
|
||||||
handlers map[schema.GroupVersionKind]resourcesemantics.GenericCRD
|
handlers map[schema.GroupVersionKind]resourcesemantics.GenericCRD
|
||||||
|
@ -66,6 +68,7 @@ type reconciler struct {
|
||||||
|
|
||||||
var _ controller.Reconciler = (*reconciler)(nil)
|
var _ controller.Reconciler = (*reconciler)(nil)
|
||||||
var _ webhook.AdmissionController = (*reconciler)(nil)
|
var _ webhook.AdmissionController = (*reconciler)(nil)
|
||||||
|
var _ webhook.StatelessAdmissionController = (*reconciler)(nil)
|
||||||
|
|
||||||
// Reconcile implements controller.Reconciler
|
// Reconcile implements controller.Reconciler
|
||||||
func (ac *reconciler) Reconcile(ctx context.Context, key string) error {
|
func (ac *reconciler) Reconcile(ctx context.Context, key string) error {
|
||||||
|
|
|
@ -48,6 +48,8 @@ var errMissingNewObject = errors.New("the new object may not be nil")
|
||||||
|
|
||||||
// reconciler implements the AdmissionController for resources
|
// reconciler implements the AdmissionController for resources
|
||||||
type reconciler struct {
|
type reconciler struct {
|
||||||
|
webhook.StatelessAdmissionImpl
|
||||||
|
|
||||||
name string
|
name string
|
||||||
path string
|
path string
|
||||||
handlers map[schema.GroupVersionKind]resourcesemantics.GenericCRD
|
handlers map[schema.GroupVersionKind]resourcesemantics.GenericCRD
|
||||||
|
@ -64,6 +66,7 @@ type reconciler struct {
|
||||||
|
|
||||||
var _ controller.Reconciler = (*reconciler)(nil)
|
var _ controller.Reconciler = (*reconciler)(nil)
|
||||||
var _ webhook.AdmissionController = (*reconciler)(nil)
|
var _ webhook.AdmissionController = (*reconciler)(nil)
|
||||||
|
var _ webhook.StatelessAdmissionController = (*reconciler)(nil)
|
||||||
|
|
||||||
// Reconcile implements controller.Reconciler
|
// Reconcile implements controller.Reconciler
|
||||||
func (ac *reconciler) Reconcile(ctx context.Context, key string) error {
|
func (ac *reconciler) Reconcile(ctx context.Context, key string) error {
|
||||||
|
|
|
@ -65,6 +65,9 @@ type Webhook struct {
|
||||||
Options Options
|
Options Options
|
||||||
Logger *zap.SugaredLogger
|
Logger *zap.SugaredLogger
|
||||||
|
|
||||||
|
// synced is function that is called when the informers have been synced.
|
||||||
|
synced context.CancelFunc
|
||||||
|
|
||||||
mux http.ServeMux
|
mux http.ServeMux
|
||||||
secretlister corelisters.SecretLister
|
secretlister corelisters.SecretLister
|
||||||
}
|
}
|
||||||
|
@ -105,11 +108,14 @@ func New(
|
||||||
opts.StatsReporter = reporter
|
opts.StatsReporter = reporter
|
||||||
}
|
}
|
||||||
|
|
||||||
|
syncCtx, cancel := context.WithCancel(context.Background())
|
||||||
|
|
||||||
webhook = &Webhook{
|
webhook = &Webhook{
|
||||||
Client: client,
|
Client: client,
|
||||||
Options: *opts,
|
Options: *opts,
|
||||||
secretlister: secretInformer.Lister(),
|
secretlister: secretInformer.Lister(),
|
||||||
Logger: logger,
|
Logger: logger,
|
||||||
|
synced: cancel,
|
||||||
}
|
}
|
||||||
|
|
||||||
webhook.mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
|
webhook.mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
|
||||||
|
@ -117,26 +123,31 @@ func New(
|
||||||
})
|
})
|
||||||
|
|
||||||
for _, controller := range controllers {
|
for _, controller := range controllers {
|
||||||
var handler http.Handler
|
|
||||||
var path string
|
|
||||||
|
|
||||||
switch c := controller.(type) {
|
switch c := controller.(type) {
|
||||||
case AdmissionController:
|
case AdmissionController:
|
||||||
handler = admissionHandler(logger, opts.StatsReporter, c)
|
handler := admissionHandler(logger, opts.StatsReporter, c, syncCtx.Done())
|
||||||
path = c.Path()
|
webhook.mux.Handle(c.Path(), handler)
|
||||||
|
|
||||||
case ConversionController:
|
case ConversionController:
|
||||||
handler = conversionHandler(logger, opts.StatsReporter, c)
|
handler := conversionHandler(logger, opts.StatsReporter, c)
|
||||||
path = c.Path()
|
webhook.mux.Handle(c.Path(), handler)
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return nil, fmt.Errorf("unknown webhook controller type: %T", controller)
|
return nil, fmt.Errorf("unknown webhook controller type: %T", controller)
|
||||||
}
|
}
|
||||||
|
|
||||||
webhook.mux.Handle(path, handler)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// InformersHaveSynced is called when the informers have all been synced, which allows any outstanding
|
||||||
|
// admission webhooks through.
|
||||||
|
func (wh *Webhook) InformersHaveSynced() {
|
||||||
|
wh.synced()
|
||||||
|
wh.Logger.Info("Informers have been synced, unblocking admission webhooks.")
|
||||||
|
}
|
||||||
|
|
||||||
// Run implements the admission controller run loop.
|
// Run implements the admission controller run loop.
|
||||||
func (wh *Webhook) Run(stop <-chan struct{}) error {
|
func (wh *Webhook) Run(stop <-chan struct{}) error {
|
||||||
logger := wh.Logger
|
logger := wh.Logger
|
||||||
|
|
|
@ -28,7 +28,7 @@ readonly PRESUBMIT_TEST_FAIL_FAST=${PRESUBMIT_TEST_FAIL_FAST:-0}
|
||||||
readonly NO_PRESUBMIT_FILES=(\.png \.gitignore \.gitattributes ^OWNERS ^OWNERS_ALIASES ^AUTHORS)
|
readonly NO_PRESUBMIT_FILES=(\.png \.gitignore \.gitattributes ^OWNERS ^OWNERS_ALIASES ^AUTHORS)
|
||||||
|
|
||||||
# Flag if this is a presubmit run or not.
|
# Flag if this is a presubmit run or not.
|
||||||
[[ IS_PROW && -n "${PULL_PULL_SHA}" ]] && IS_PRESUBMIT=1 || IS_PRESUBMIT=0
|
(( IS_PROW )) && [[ -n "${PULL_PULL_SHA}" ]] && IS_PRESUBMIT=1 || IS_PRESUBMIT=0
|
||||||
readonly IS_PRESUBMIT
|
readonly IS_PRESUBMIT
|
||||||
|
|
||||||
# List of changed files on presubmit, LF separated.
|
# List of changed files on presubmit, LF separated.
|
||||||
|
@ -362,7 +362,7 @@ function main() {
|
||||||
|
|
||||||
local failed=0
|
local failed=0
|
||||||
|
|
||||||
if [[ ${#TESTS_TO_RUN[@]} > 0 ]]; then
|
if [[ ${#TESTS_TO_RUN[@]} -gt 0 ]]; then
|
||||||
if (( RUN_BUILD_TESTS || RUN_UNIT_TESTS || RUN_INTEGRATION_TESTS )); then
|
if (( RUN_BUILD_TESTS || RUN_UNIT_TESTS || RUN_INTEGRATION_TESTS )); then
|
||||||
abort "--run-test must be used alone"
|
abort "--run-test must be used alone"
|
||||||
fi
|
fi
|
||||||
|
|
Loading…
Reference in New Issue