Add stopCh to apiserver & context to kublet commands
Remove SetupSignalContext call from the apiserver Signed-off-by: galal-hussein <hussein.galal.ahmed.11@gmail.com>
This commit is contained in:
committed by
rafaelbreno[commit]
parent
1d6158557c
commit
4e407fa5b5
@@ -47,6 +47,7 @@ AwEHoUQDQgAEH6cuzP8XuD5wal6wf9M6xDljTOPLX2i8uIp/C/ASqiIGUeeKQtX0
|
||||
// APIServer is a server which manages apiserver.
|
||||
type APIServer struct {
|
||||
storageConfig storagebackend.Config
|
||||
stopCh chan struct{}
|
||||
cancel func(error)
|
||||
}
|
||||
|
||||
@@ -54,6 +55,7 @@ type APIServer struct {
|
||||
func NewAPIServer(storageConfig storagebackend.Config) *APIServer {
|
||||
return &APIServer{
|
||||
storageConfig: storageConfig,
|
||||
stopCh: make(chan struct{}),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -112,7 +114,7 @@ func (a *APIServer) Start(ctx context.Context) error {
|
||||
return
|
||||
}
|
||||
|
||||
err = apiserver.Run(ctx, completedOptions)
|
||||
err = apiserver.Run(ctx, completedOptions, a.stopCh)
|
||||
if err != nil {
|
||||
errCh <- fmt.Errorf("run apiserver error: %w", err)
|
||||
return
|
||||
@@ -132,6 +134,10 @@ func (a *APIServer) Stop() error {
|
||||
if a.cancel != nil {
|
||||
a.cancel(errors.New("stopping API server"))
|
||||
}
|
||||
if a.stopCh != nil {
|
||||
close(a.stopCh)
|
||||
a.stopCh = nil
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user