bootstrapper: fix GracefulStop of InitServer

Let joinclient stop initserver only when itself initializes the node.
This commit is contained in:
Leonard Cohnen 2022-11-21 15:44:51 +01:00 committed by 3u13r
parent 1362e40f53
commit 0232c835ca
2 changed files with 8 additions and 1 deletions

View File

@ -148,7 +148,11 @@ func (s *Server) Init(ctx context.Context, req *initproto.InitRequest) (*initpro
// Stop stops the initialization server gracefully.
func (s *Server) Stop() {
s.log.Infof("Stopping")
s.grpcServer.GracefulStop()
s.log.Infof("Stopped")
}
func (s *Server) setupDisk(masterSecret, salt []byte) error {

View File

@ -58,6 +58,7 @@ type JoinClient struct {
dialer grpcDialer
joiner ClusterJoiner
cleaner cleaner
metadataAPI MetadataAPI
log *logger.Logger
@ -100,13 +101,13 @@ func (c *JoinClient) Start(cleaner cleaner) {
c.log.Infof("Starting")
c.stopC = make(chan struct{}, 1)
c.stopDone = make(chan struct{}, 1)
c.cleaner = cleaner
ticker := c.clock.NewTicker(c.interval)
go func() {
defer ticker.Stop()
defer func() { c.stopDone <- struct{}{} }()
defer c.log.Infof("Client stopped")
defer cleaner.Clean()
diskUUID, err := c.getDiskUUID()
if err != nil {
@ -254,6 +255,8 @@ func (c *JoinClient) startNodeAndJoin(ticket *joinproto.IssueJoinTicketResponse,
return errors.New("node is already being initialized")
}
c.cleaner.Clean()
if err := c.updateDiskPassphrase(string(ticket.StateDiskKey)); err != nil {
return fmt.Errorf("updating disk passphrase: %w", err)
}