bootstrapper: stop join-client earlier (#1268)

Signed-off-by: Daniel Weiße <dw@edgeless.systems>
This commit is contained in:
Daniel Weiße 2023-03-03 16:50:01 +01:00 committed by GitHub
parent 420fecb986
commit 2023edaef0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 2 deletions

View File

@ -113,7 +113,6 @@ func (s *Server) Serve(ip, port string, cleaner cleaner) error {
// Init initializes the cluster.
func (s *Server) Init(ctx context.Context, req *initproto.InitRequest) (*initproto.InitResponse, error) {
defer s.cleaner.Clean()
log := s.log.With(zap.String("peer", grpclog.PeerAddrFromContext(ctx)))
log.Infof("Init called")
@ -146,6 +145,11 @@ func (s *Server) Init(ctx context.Context, req *initproto.InitRequest) (*initpro
return nil, status.Error(codes.FailedPrecondition, "node is already being activated")
}
// Stop the join client -> We no longer expect to join an existing cluster,
// since we are bootstrapping a new one.
// Any errors following this call will result in a failed node that may not join any cluster.
s.cleaner.Clean()
if err := s.setupDisk(ctx, cloudKms); err != nil {
return nil, status.Errorf(codes.Internal, "setting up disk: %s", err)
}

View File

@ -110,6 +110,7 @@ func TestInit(t *testing.T) {
fileHandler: file.NewHandler(afero.NewMemMapFs()),
initSecretHash: initSecretHash,
req: &initproto.InitRequest{InitSecret: initSecret, KmsUri: masterSecret.EncodeToURI(), StorageUri: uri.NoStoreURI},
wantShutdown: true,
},
"node locked": {
nodeLock: lockedLock,
@ -119,7 +120,6 @@ func TestInit(t *testing.T) {
req: &initproto.InitRequest{InitSecret: initSecret, KmsUri: masterSecret.EncodeToURI(), StorageUri: uri.NoStoreURI},
initSecretHash: initSecretHash,
wantErr: true,
wantShutdown: true,
},
"disk open error": {
nodeLock: newFakeLock(),
@ -129,6 +129,7 @@ func TestInit(t *testing.T) {
req: &initproto.InitRequest{InitSecret: initSecret, KmsUri: masterSecret.EncodeToURI(), StorageUri: uri.NoStoreURI},
initSecretHash: initSecretHash,
wantErr: true,
wantShutdown: true,
},
"disk uuid error": {
nodeLock: newFakeLock(),
@ -138,6 +139,7 @@ func TestInit(t *testing.T) {
req: &initproto.InitRequest{InitSecret: initSecret, KmsUri: masterSecret.EncodeToURI(), StorageUri: uri.NoStoreURI},
initSecretHash: initSecretHash,
wantErr: true,
wantShutdown: true,
},
"disk update passphrase error": {
nodeLock: newFakeLock(),
@ -147,6 +149,7 @@ func TestInit(t *testing.T) {
req: &initproto.InitRequest{InitSecret: initSecret, KmsUri: masterSecret.EncodeToURI(), StorageUri: uri.NoStoreURI},
initSecretHash: initSecretHash,
wantErr: true,
wantShutdown: true,
},
"write state file error": {
nodeLock: newFakeLock(),
@ -156,6 +159,7 @@ func TestInit(t *testing.T) {
req: &initproto.InitRequest{InitSecret: initSecret, KmsUri: masterSecret.EncodeToURI(), StorageUri: uri.NoStoreURI},
initSecretHash: initSecretHash,
wantErr: true,
wantShutdown: true,
},
"initialize cluster error": {
nodeLock: newFakeLock(),
@ -165,6 +169,7 @@ func TestInit(t *testing.T) {
req: &initproto.InitRequest{InitSecret: initSecret, KmsUri: masterSecret.EncodeToURI(), StorageUri: uri.NoStoreURI},
initSecretHash: initSecretHash,
wantErr: true,
wantShutdown: true,
},
"wrong initSecret": {
nodeLock: newFakeLock(),