mirror of https://github.com/k3s-io/k3s
Allow disabling specific post-start hooks
parent
ac8b985b4a
commit
2c89ff59e2
|
@ -96,6 +96,8 @@ type Config struct {
|
||||||
EnableContentionProfiling bool
|
EnableContentionProfiling bool
|
||||||
EnableMetrics bool
|
EnableMetrics bool
|
||||||
|
|
||||||
|
DisabledPostStartHooks sets.String
|
||||||
|
|
||||||
// Version will enable the /version endpoint if non-nil
|
// Version will enable the /version endpoint if non-nil
|
||||||
Version *version.Info
|
Version *version.Info
|
||||||
// AuditWriter is the destination for audit logs. If nil, they will not be written.
|
// AuditWriter is the destination for audit logs. If nil, they will not be written.
|
||||||
|
@ -203,6 +205,7 @@ func NewConfig(codecs serializer.CodecFactory) *Config {
|
||||||
RequestContextMapper: apirequest.NewRequestContextMapper(),
|
RequestContextMapper: apirequest.NewRequestContextMapper(),
|
||||||
BuildHandlerChainFunc: DefaultBuildHandlerChain,
|
BuildHandlerChainFunc: DefaultBuildHandlerChain,
|
||||||
LegacyAPIGroupPrefixes: sets.NewString(DefaultLegacyAPIPrefix),
|
LegacyAPIGroupPrefixes: sets.NewString(DefaultLegacyAPIPrefix),
|
||||||
|
DisabledPostStartHooks: sets.NewString(),
|
||||||
HealthzChecks: []healthz.HealthzChecker{healthz.PingHealthz},
|
HealthzChecks: []healthz.HealthzChecker{healthz.PingHealthz},
|
||||||
EnableIndex: true,
|
EnableIndex: true,
|
||||||
EnableDiscovery: true,
|
EnableDiscovery: true,
|
||||||
|
@ -415,8 +418,10 @@ func (c completedConfig) constructServer() (*GenericAPIServer, error) {
|
||||||
swaggerConfig: c.SwaggerConfig,
|
swaggerConfig: c.SwaggerConfig,
|
||||||
openAPIConfig: c.OpenAPIConfig,
|
openAPIConfig: c.OpenAPIConfig,
|
||||||
|
|
||||||
postStartHooks: map[string]postStartHookEntry{},
|
postStartHooks: map[string]postStartHookEntry{},
|
||||||
healthzChecks: c.HealthzChecks,
|
disabledPostStartHooks: c.DisabledPostStartHooks,
|
||||||
|
|
||||||
|
healthzChecks: c.HealthzChecks,
|
||||||
}
|
}
|
||||||
|
|
||||||
return s, nil
|
return s, nil
|
||||||
|
|
|
@ -143,10 +143,11 @@ type GenericAPIServer struct {
|
||||||
|
|
||||||
// PostStartHooks are each called after the server has started listening, in a separate go func for each
|
// PostStartHooks are each called after the server has started listening, in a separate go func for each
|
||||||
// with no guarantee of ordering between them. The map key is a name used for error reporting.
|
// with no guarantee of ordering between them. The map key is a name used for error reporting.
|
||||||
// It may kill the process with a panic if it wishes to by returning an error
|
// It may kill the process with a panic if it wishes to by returning an error.
|
||||||
postStartHookLock sync.Mutex
|
postStartHookLock sync.Mutex
|
||||||
postStartHooks map[string]postStartHookEntry
|
postStartHooks map[string]postStartHookEntry
|
||||||
postStartHooksCalled bool
|
postStartHooksCalled bool
|
||||||
|
disabledPostStartHooks sets.String
|
||||||
|
|
||||||
// healthz checks
|
// healthz checks
|
||||||
healthzLock sync.Mutex
|
healthzLock sync.Mutex
|
||||||
|
|
|
@ -65,6 +65,9 @@ func (s *GenericAPIServer) AddPostStartHook(name string, hook PostStartHookFunc)
|
||||||
if hook == nil {
|
if hook == nil {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
if s.disabledPostStartHooks.Has(name) {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
s.postStartHookLock.Lock()
|
s.postStartHookLock.Lock()
|
||||||
defer s.postStartHookLock.Unlock()
|
defer s.postStartHookLock.Unlock()
|
||||||
|
|
Loading…
Reference in New Issue