Update go dependencies
This commit is contained in:
parent
a858c549d9
commit
f3bde94d68
643 changed files with 14296 additions and 19354 deletions
2
vendor/k8s.io/apiserver/pkg/server/BUILD
generated
vendored
2
vendor/k8s.io/apiserver/pkg/server/BUILD
generated
vendored
|
|
@ -77,6 +77,7 @@ go_library(
|
|||
"//vendor/k8s.io/apimachinery/pkg/runtime:go_default_library",
|
||||
"//vendor/k8s.io/apimachinery/pkg/runtime/schema:go_default_library",
|
||||
"//vendor/k8s.io/apimachinery/pkg/runtime/serializer:go_default_library",
|
||||
"//vendor/k8s.io/apimachinery/pkg/util/errors:go_default_library",
|
||||
"//vendor/k8s.io/apimachinery/pkg/util/runtime:go_default_library",
|
||||
"//vendor/k8s.io/apimachinery/pkg/util/sets:go_default_library",
|
||||
"//vendor/k8s.io/apimachinery/pkg/util/validation:go_default_library",
|
||||
|
|
@ -84,6 +85,7 @@ go_library(
|
|||
"//vendor/k8s.io/apiserver/pkg/admission:go_default_library",
|
||||
"//vendor/k8s.io/apiserver/pkg/admission/plugin/initialization:go_default_library",
|
||||
"//vendor/k8s.io/apiserver/pkg/admission/plugin/namespace/lifecycle:go_default_library",
|
||||
"//vendor/k8s.io/apiserver/pkg/admission/plugin/webhook/webhook:go_default_library",
|
||||
"//vendor/k8s.io/apiserver/pkg/apis/apiserver/install:go_default_library",
|
||||
"//vendor/k8s.io/apiserver/pkg/audit:go_default_library",
|
||||
"//vendor/k8s.io/apiserver/pkg/audit/policy:go_default_library",
|
||||
|
|
|
|||
9
vendor/k8s.io/apiserver/pkg/server/config.go
generated
vendored
9
vendor/k8s.io/apiserver/pkg/server/config.go
generated
vendored
|
|
@ -67,7 +67,7 @@ import (
|
|||
)
|
||||
|
||||
const (
|
||||
// DefaultLegacyAPIPrefix is where the the legacy APIs will be located.
|
||||
// DefaultLegacyAPIPrefix is where the legacy APIs will be located.
|
||||
DefaultLegacyAPIPrefix = "/api"
|
||||
|
||||
// APIGroupPrefix is where non-legacy API group will be located.
|
||||
|
|
@ -460,6 +460,7 @@ func (c completedConfig) New(name string, delegationTarget DelegationTarget) (*G
|
|||
openAPIConfig: c.OpenAPIConfig,
|
||||
|
||||
postStartHooks: map[string]postStartHookEntry{},
|
||||
preShutdownHooks: map[string]preShutdownHookEntry{},
|
||||
disabledPostStartHooks: c.DisabledPostStartHooks,
|
||||
|
||||
healthzChecks: c.HealthzChecks,
|
||||
|
|
@ -473,8 +474,12 @@ func (c completedConfig) New(name string, delegationTarget DelegationTarget) (*G
|
|||
s.postStartHooks[k] = v
|
||||
}
|
||||
|
||||
for k, v := range delegationTarget.PreShutdownHooks() {
|
||||
s.preShutdownHooks[k] = v
|
||||
}
|
||||
|
||||
genericApiServerHookName := "generic-apiserver-start-informers"
|
||||
if c.SharedInformerFactory != nil && !s.isHookRegistered(genericApiServerHookName) {
|
||||
if c.SharedInformerFactory != nil && !s.isPostStartHookRegistered(genericApiServerHookName) {
|
||||
err := s.AddPostStartHook(genericApiServerHookName, func(context PostStartHookContext) error {
|
||||
c.SharedInformerFactory.Start(context.StopCh)
|
||||
return nil
|
||||
|
|
|
|||
43
vendor/k8s.io/apiserver/pkg/server/genericapiserver.go
generated
vendored
43
vendor/k8s.io/apiserver/pkg/server/genericapiserver.go
generated
vendored
|
|
@ -134,6 +134,10 @@ type GenericAPIServer struct {
|
|||
postStartHooksCalled bool
|
||||
disabledPostStartHooks sets.String
|
||||
|
||||
preShutdownHookLock sync.Mutex
|
||||
preShutdownHooks map[string]preShutdownHookEntry
|
||||
preShutdownHooksCalled bool
|
||||
|
||||
// healthz checks
|
||||
healthzLock sync.Mutex
|
||||
healthzChecks []healthz.HealthzChecker
|
||||
|
|
@ -163,6 +167,9 @@ type DelegationTarget interface {
|
|||
// PostStartHooks returns the post-start hooks that need to be combined
|
||||
PostStartHooks() map[string]postStartHookEntry
|
||||
|
||||
// PreShutdownHooks returns the pre-stop hooks that need to be combined
|
||||
PreShutdownHooks() map[string]preShutdownHookEntry
|
||||
|
||||
// HealthzChecks returns the healthz checks that need to be combined
|
||||
HealthzChecks() []healthz.HealthzChecker
|
||||
|
||||
|
|
@ -180,6 +187,9 @@ func (s *GenericAPIServer) UnprotectedHandler() http.Handler {
|
|||
func (s *GenericAPIServer) PostStartHooks() map[string]postStartHookEntry {
|
||||
return s.postStartHooks
|
||||
}
|
||||
func (s *GenericAPIServer) PreShutdownHooks() map[string]preShutdownHookEntry {
|
||||
return s.preShutdownHooks
|
||||
}
|
||||
func (s *GenericAPIServer) HealthzChecks() []healthz.HealthzChecker {
|
||||
return s.healthzChecks
|
||||
}
|
||||
|
|
@ -205,6 +215,9 @@ func (s emptyDelegate) UnprotectedHandler() http.Handler {
|
|||
func (s emptyDelegate) PostStartHooks() map[string]postStartHookEntry {
|
||||
return map[string]postStartHookEntry{}
|
||||
}
|
||||
func (s emptyDelegate) PreShutdownHooks() map[string]preShutdownHookEntry {
|
||||
return map[string]preShutdownHookEntry{}
|
||||
}
|
||||
func (s emptyDelegate) HealthzChecks() []healthz.HealthzChecker {
|
||||
return []healthz.HealthzChecker{}
|
||||
}
|
||||
|
|
@ -253,6 +266,14 @@ func (s *GenericAPIServer) PrepareRun() preparedGenericAPIServer {
|
|||
// Run spawns the secure http server. It only returns if stopCh is closed
|
||||
// or the secure port cannot be listened on initially.
|
||||
func (s preparedGenericAPIServer) Run(stopCh <-chan struct{}) error {
|
||||
// Register audit backend preShutdownHook.
|
||||
if s.AuditBackend != nil {
|
||||
s.AddPreShutdownHook("audit-backend", func() error {
|
||||
s.AuditBackend.Shutdown()
|
||||
return nil
|
||||
})
|
||||
}
|
||||
|
||||
err := s.NonBlockingRun(stopCh)
|
||||
if err != nil {
|
||||
return err
|
||||
|
|
@ -260,16 +281,20 @@ func (s preparedGenericAPIServer) Run(stopCh <-chan struct{}) error {
|
|||
|
||||
<-stopCh
|
||||
|
||||
if s.GenericAPIServer.AuditBackend != nil {
|
||||
s.GenericAPIServer.AuditBackend.Shutdown()
|
||||
}
|
||||
|
||||
return nil
|
||||
return s.RunPreShutdownHooks()
|
||||
}
|
||||
|
||||
// NonBlockingRun spawns the secure http server. An error is
|
||||
// returned if the secure port cannot be listened on.
|
||||
func (s preparedGenericAPIServer) NonBlockingRun(stopCh <-chan struct{}) error {
|
||||
// Start the audit backend before any request comes in. This means we must call Backend.Run
|
||||
// before http server start serving. Otherwise the Backend.ProcessEvents call might block.
|
||||
if s.AuditBackend != nil {
|
||||
if err := s.AuditBackend.Run(stopCh); err != nil {
|
||||
return fmt.Errorf("failed to run the audit backend: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
// Use an internal stop channel to allow cleanup of the listeners on error.
|
||||
internalStopCh := make(chan struct{})
|
||||
|
||||
|
|
@ -288,14 +313,6 @@ func (s preparedGenericAPIServer) NonBlockingRun(stopCh <-chan struct{}) error {
|
|||
close(internalStopCh)
|
||||
}()
|
||||
|
||||
// Start the audit backend before any request comes in. This means we cannot turn it into a
|
||||
// post start hook because without calling Backend.Run the Backend.ProcessEvents call might block.
|
||||
if s.AuditBackend != nil {
|
||||
if err := s.AuditBackend.Run(stopCh); err != nil {
|
||||
return fmt.Errorf("failed to run the audit backend: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
s.RunPostStartHooks(stopCh)
|
||||
|
||||
if _, err := systemd.SdNotify(true, "READY=1\n"); err != nil {
|
||||
|
|
|
|||
2
vendor/k8s.io/apiserver/pkg/server/handler.go
generated
vendored
2
vendor/k8s.io/apiserver/pkg/server/handler.go
generated
vendored
|
|
@ -62,7 +62,7 @@ type APIServerHandler struct {
|
|||
// which we don't fit into and it still muddies up swagger. Trying to switch the webservices into a route doesn't work because the
|
||||
// containing webservice faces all the same problems listed above.
|
||||
// This leads to the crazy thing done here. Our mux does what we need, so we'll place it in front of gorestful. It will introspect to
|
||||
// decide if the the route is likely to be handled by goresful and route there if needed. Otherwise, it goes to PostGoRestful mux in
|
||||
// decide if the route is likely to be handled by goresful and route there if needed. Otherwise, it goes to PostGoRestful mux in
|
||||
// order to handle "normal" paths and delegation. Hopefully no API consumers will ever have to deal with this level of detail. I think
|
||||
// we should consider completely removing gorestful.
|
||||
// Other servers should only use this opaquely to delegate to an API server.
|
||||
|
|
|
|||
72
vendor/k8s.io/apiserver/pkg/server/hooks.go
generated
vendored
72
vendor/k8s.io/apiserver/pkg/server/hooks.go
generated
vendored
|
|
@ -23,6 +23,7 @@ import (
|
|||
|
||||
"github.com/golang/glog"
|
||||
|
||||
utilerrors "k8s.io/apimachinery/pkg/util/errors"
|
||||
utilruntime "k8s.io/apimachinery/pkg/util/runtime"
|
||||
"k8s.io/apiserver/pkg/server/healthz"
|
||||
restclient "k8s.io/client-go/rest"
|
||||
|
|
@ -39,6 +40,9 @@ import (
|
|||
// until it becomes easier to use.
|
||||
type PostStartHookFunc func(context PostStartHookContext) error
|
||||
|
||||
// PreShutdownHookFunc is a function that can be added to the shutdown logic.
|
||||
type PreShutdownHookFunc func() error
|
||||
|
||||
// PostStartHookContext provides information about this API server to a PostStartHookFunc
|
||||
type PostStartHookContext struct {
|
||||
// LoopbackClientConfig is a config for a privileged loopback connection to the API server
|
||||
|
|
@ -59,6 +63,10 @@ type postStartHookEntry struct {
|
|||
done chan struct{}
|
||||
}
|
||||
|
||||
type preShutdownHookEntry struct {
|
||||
hook PreShutdownHookFunc
|
||||
}
|
||||
|
||||
// AddPostStartHook allows you to add a PostStartHook.
|
||||
func (s *GenericAPIServer) AddPostStartHook(name string, hook PostStartHookFunc) error {
|
||||
if len(name) == 0 {
|
||||
|
|
@ -97,6 +105,37 @@ func (s *GenericAPIServer) AddPostStartHookOrDie(name string, hook PostStartHook
|
|||
}
|
||||
}
|
||||
|
||||
// AddPreShutdownHook allows you to add a PreShutdownHook.
|
||||
func (s *GenericAPIServer) AddPreShutdownHook(name string, hook PreShutdownHookFunc) error {
|
||||
if len(name) == 0 {
|
||||
return fmt.Errorf("missing name")
|
||||
}
|
||||
if hook == nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
s.preShutdownHookLock.Lock()
|
||||
defer s.preShutdownHookLock.Unlock()
|
||||
|
||||
if s.preShutdownHooksCalled {
|
||||
return fmt.Errorf("unable to add %q because PreShutdownHooks have already been called", name)
|
||||
}
|
||||
if _, exists := s.preShutdownHooks[name]; exists {
|
||||
return fmt.Errorf("unable to add %q because it is already registered", name)
|
||||
}
|
||||
|
||||
s.preShutdownHooks[name] = preShutdownHookEntry{hook: hook}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// AddPreShutdownHookOrDie allows you to add a PostStartHook, but dies on failure
|
||||
func (s *GenericAPIServer) AddPreShutdownHookOrDie(name string, hook PreShutdownHookFunc) {
|
||||
if err := s.AddPreShutdownHook(name, hook); err != nil {
|
||||
glog.Fatalf("Error registering PreShutdownHook %q: %v", name, err)
|
||||
}
|
||||
}
|
||||
|
||||
// RunPostStartHooks runs the PostStartHooks for the server
|
||||
func (s *GenericAPIServer) RunPostStartHooks(stopCh <-chan struct{}) {
|
||||
s.postStartHookLock.Lock()
|
||||
|
|
@ -113,8 +152,24 @@ func (s *GenericAPIServer) RunPostStartHooks(stopCh <-chan struct{}) {
|
|||
}
|
||||
}
|
||||
|
||||
// isHookRegistered checks whether a given hook is registered
|
||||
func (s *GenericAPIServer) isHookRegistered(name string) bool {
|
||||
// RunPreShutdownHooks runs the PreShutdownHooks for the server
|
||||
func (s *GenericAPIServer) RunPreShutdownHooks() error {
|
||||
var errorList []error
|
||||
|
||||
s.preShutdownHookLock.Lock()
|
||||
defer s.preShutdownHookLock.Unlock()
|
||||
s.preShutdownHooksCalled = true
|
||||
|
||||
for hookName, hookEntry := range s.preShutdownHooks {
|
||||
if err := runPreShutdownHook(hookName, hookEntry); err != nil {
|
||||
errorList = append(errorList, err)
|
||||
}
|
||||
}
|
||||
return utilerrors.NewAggregate(errorList)
|
||||
}
|
||||
|
||||
// isPostStartHookRegistered checks whether a given PostStartHook is registered
|
||||
func (s *GenericAPIServer) isPostStartHookRegistered(name string) bool {
|
||||
s.postStartHookLock.Lock()
|
||||
defer s.postStartHookLock.Unlock()
|
||||
_, exists := s.postStartHooks[name]
|
||||
|
|
@ -135,6 +190,19 @@ func runPostStartHook(name string, entry postStartHookEntry, context PostStartHo
|
|||
close(entry.done)
|
||||
}
|
||||
|
||||
func runPreShutdownHook(name string, entry preShutdownHookEntry) error {
|
||||
var err error
|
||||
func() {
|
||||
// don't let the hook *accidentally* panic and kill the server
|
||||
defer utilruntime.HandleCrash()
|
||||
err = entry.hook()
|
||||
}()
|
||||
if err != nil {
|
||||
return fmt.Errorf("PreShutdownHook %q failed: %v", name, err)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// postStartHookHealthz implements a healthz check for poststarthooks. It will return a "hookNotFinished"
|
||||
// error until the poststarthook is finished.
|
||||
type postStartHookHealthz struct {
|
||||
|
|
|
|||
2
vendor/k8s.io/apiserver/pkg/server/plugins.go
generated
vendored
2
vendor/k8s.io/apiserver/pkg/server/plugins.go
generated
vendored
|
|
@ -21,10 +21,12 @@ import (
|
|||
"k8s.io/apiserver/pkg/admission"
|
||||
"k8s.io/apiserver/pkg/admission/plugin/initialization"
|
||||
"k8s.io/apiserver/pkg/admission/plugin/namespace/lifecycle"
|
||||
"k8s.io/apiserver/pkg/admission/plugin/webhook/webhook"
|
||||
)
|
||||
|
||||
// RegisterAllAdmissionPlugins registers all admission plugins
|
||||
func RegisterAllAdmissionPlugins(plugins *admission.Plugins) {
|
||||
lifecycle.Register(plugins)
|
||||
initialization.Register(plugins)
|
||||
webhook.Register(plugins)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue