mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-30 15:05:27 +00:00
Merge pull request #63667 from hzxuzhonghu/wait-informer-synced
Automatic merge from submit-queue. If you want to cherry-pick this change to another branch, please follow the instructions <a href="https://github.com/kubernetes/community/blob/master/contributors/devel/cherry-picks.md">here</a>. sample-apiserver admission wait for informer sync before serving **What this PR does / why we need it**: sample-apiserver admission wait for informer sync before serving **Release note**: ```release-note NONE ```
This commit is contained in:
commit
233b267392
@ -53,6 +53,10 @@ func (d *DisallowFlunder) Admit(a admission.Attributes) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if !d.WaitForReady() {
|
||||||
|
return admission.NewForbidden(a, fmt.Errorf("not yet ready to handle request"))
|
||||||
|
}
|
||||||
|
|
||||||
metaAccessor, err := meta.Accessor(a.GetObject())
|
metaAccessor, err := meta.Accessor(a.GetObject())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
@ -82,6 +86,7 @@ func (d *DisallowFlunder) Admit(a admission.Attributes) error {
|
|||||||
// The lister knows how to lists Fischers.
|
// The lister knows how to lists Fischers.
|
||||||
func (d *DisallowFlunder) SetInternalWardleInformerFactory(f informers.SharedInformerFactory) {
|
func (d *DisallowFlunder) SetInternalWardleInformerFactory(f informers.SharedInformerFactory) {
|
||||||
d.lister = f.Wardle().InternalVersion().Fischers().Lister()
|
d.lister = f.Wardle().InternalVersion().Fischers().Lister()
|
||||||
|
d.SetReadyFunc(f.Wardle().InternalVersion().Fischers().Informer().HasSynced)
|
||||||
}
|
}
|
||||||
|
|
||||||
// ValidaValidateInitializationte checks whether the plugin was correctly initialized.
|
// ValidaValidateInitializationte checks whether the plugin was correctly initialized.
|
||||||
|
@ -137,6 +137,7 @@ func (o WardleServerOptions) RunWardleServer(stopCh <-chan struct{}) error {
|
|||||||
|
|
||||||
server.GenericAPIServer.AddPostStartHook("start-sample-server-informers", func(context genericapiserver.PostStartHookContext) error {
|
server.GenericAPIServer.AddPostStartHook("start-sample-server-informers", func(context genericapiserver.PostStartHookContext) error {
|
||||||
config.GenericConfig.SharedInformerFactory.Start(context.StopCh)
|
config.GenericConfig.SharedInformerFactory.Start(context.StopCh)
|
||||||
|
o.SharedInformerFactory.Start(context.StopCh)
|
||||||
return nil
|
return nil
|
||||||
})
|
})
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user