mirror of
https://github.com/edgelesssys/constellation.git
synced 2025-01-12 07:59:29 -05:00
bootstrapper: stop join-client earlier (#1268)
Signed-off-by: Daniel Weiße <dw@edgeless.systems>
This commit is contained in:
parent
420fecb986
commit
2023edaef0
@ -113,7 +113,6 @@ func (s *Server) Serve(ip, port string, cleaner cleaner) error {
|
|||||||
|
|
||||||
// Init initializes the cluster.
|
// Init initializes the cluster.
|
||||||
func (s *Server) Init(ctx context.Context, req *initproto.InitRequest) (*initproto.InitResponse, error) {
|
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 := s.log.With(zap.String("peer", grpclog.PeerAddrFromContext(ctx)))
|
||||||
log.Infof("Init called")
|
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")
|
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 {
|
if err := s.setupDisk(ctx, cloudKms); err != nil {
|
||||||
return nil, status.Errorf(codes.Internal, "setting up disk: %s", err)
|
return nil, status.Errorf(codes.Internal, "setting up disk: %s", err)
|
||||||
}
|
}
|
||||||
|
@ -110,6 +110,7 @@ func TestInit(t *testing.T) {
|
|||||||
fileHandler: file.NewHandler(afero.NewMemMapFs()),
|
fileHandler: file.NewHandler(afero.NewMemMapFs()),
|
||||||
initSecretHash: initSecretHash,
|
initSecretHash: initSecretHash,
|
||||||
req: &initproto.InitRequest{InitSecret: initSecret, KmsUri: masterSecret.EncodeToURI(), StorageUri: uri.NoStoreURI},
|
req: &initproto.InitRequest{InitSecret: initSecret, KmsUri: masterSecret.EncodeToURI(), StorageUri: uri.NoStoreURI},
|
||||||
|
wantShutdown: true,
|
||||||
},
|
},
|
||||||
"node locked": {
|
"node locked": {
|
||||||
nodeLock: lockedLock,
|
nodeLock: lockedLock,
|
||||||
@ -119,7 +120,6 @@ func TestInit(t *testing.T) {
|
|||||||
req: &initproto.InitRequest{InitSecret: initSecret, KmsUri: masterSecret.EncodeToURI(), StorageUri: uri.NoStoreURI},
|
req: &initproto.InitRequest{InitSecret: initSecret, KmsUri: masterSecret.EncodeToURI(), StorageUri: uri.NoStoreURI},
|
||||||
initSecretHash: initSecretHash,
|
initSecretHash: initSecretHash,
|
||||||
wantErr: true,
|
wantErr: true,
|
||||||
wantShutdown: true,
|
|
||||||
},
|
},
|
||||||
"disk open error": {
|
"disk open error": {
|
||||||
nodeLock: newFakeLock(),
|
nodeLock: newFakeLock(),
|
||||||
@ -129,6 +129,7 @@ func TestInit(t *testing.T) {
|
|||||||
req: &initproto.InitRequest{InitSecret: initSecret, KmsUri: masterSecret.EncodeToURI(), StorageUri: uri.NoStoreURI},
|
req: &initproto.InitRequest{InitSecret: initSecret, KmsUri: masterSecret.EncodeToURI(), StorageUri: uri.NoStoreURI},
|
||||||
initSecretHash: initSecretHash,
|
initSecretHash: initSecretHash,
|
||||||
wantErr: true,
|
wantErr: true,
|
||||||
|
wantShutdown: true,
|
||||||
},
|
},
|
||||||
"disk uuid error": {
|
"disk uuid error": {
|
||||||
nodeLock: newFakeLock(),
|
nodeLock: newFakeLock(),
|
||||||
@ -138,6 +139,7 @@ func TestInit(t *testing.T) {
|
|||||||
req: &initproto.InitRequest{InitSecret: initSecret, KmsUri: masterSecret.EncodeToURI(), StorageUri: uri.NoStoreURI},
|
req: &initproto.InitRequest{InitSecret: initSecret, KmsUri: masterSecret.EncodeToURI(), StorageUri: uri.NoStoreURI},
|
||||||
initSecretHash: initSecretHash,
|
initSecretHash: initSecretHash,
|
||||||
wantErr: true,
|
wantErr: true,
|
||||||
|
wantShutdown: true,
|
||||||
},
|
},
|
||||||
"disk update passphrase error": {
|
"disk update passphrase error": {
|
||||||
nodeLock: newFakeLock(),
|
nodeLock: newFakeLock(),
|
||||||
@ -147,6 +149,7 @@ func TestInit(t *testing.T) {
|
|||||||
req: &initproto.InitRequest{InitSecret: initSecret, KmsUri: masterSecret.EncodeToURI(), StorageUri: uri.NoStoreURI},
|
req: &initproto.InitRequest{InitSecret: initSecret, KmsUri: masterSecret.EncodeToURI(), StorageUri: uri.NoStoreURI},
|
||||||
initSecretHash: initSecretHash,
|
initSecretHash: initSecretHash,
|
||||||
wantErr: true,
|
wantErr: true,
|
||||||
|
wantShutdown: true,
|
||||||
},
|
},
|
||||||
"write state file error": {
|
"write state file error": {
|
||||||
nodeLock: newFakeLock(),
|
nodeLock: newFakeLock(),
|
||||||
@ -156,6 +159,7 @@ func TestInit(t *testing.T) {
|
|||||||
req: &initproto.InitRequest{InitSecret: initSecret, KmsUri: masterSecret.EncodeToURI(), StorageUri: uri.NoStoreURI},
|
req: &initproto.InitRequest{InitSecret: initSecret, KmsUri: masterSecret.EncodeToURI(), StorageUri: uri.NoStoreURI},
|
||||||
initSecretHash: initSecretHash,
|
initSecretHash: initSecretHash,
|
||||||
wantErr: true,
|
wantErr: true,
|
||||||
|
wantShutdown: true,
|
||||||
},
|
},
|
||||||
"initialize cluster error": {
|
"initialize cluster error": {
|
||||||
nodeLock: newFakeLock(),
|
nodeLock: newFakeLock(),
|
||||||
@ -165,6 +169,7 @@ func TestInit(t *testing.T) {
|
|||||||
req: &initproto.InitRequest{InitSecret: initSecret, KmsUri: masterSecret.EncodeToURI(), StorageUri: uri.NoStoreURI},
|
req: &initproto.InitRequest{InitSecret: initSecret, KmsUri: masterSecret.EncodeToURI(), StorageUri: uri.NoStoreURI},
|
||||||
initSecretHash: initSecretHash,
|
initSecretHash: initSecretHash,
|
||||||
wantErr: true,
|
wantErr: true,
|
||||||
|
wantShutdown: true,
|
||||||
},
|
},
|
||||||
"wrong initSecret": {
|
"wrong initSecret": {
|
||||||
nodeLock: newFakeLock(),
|
nodeLock: newFakeLock(),
|
||||||
|
Loading…
Reference in New Issue
Block a user