mirror of
https://github.com/edgelesssys/constellation.git
synced 2025-08-03 20:44:14 -04:00
AB#2200 Merge Owner and Cluster ID (#282)
* Merge Owner and Cluster ID into single value * Remove aTLS from KMS, as it is no longer used for cluster external communication * Update verify command to use cluster-id instead of unique-id flag * Remove owner ID from init output Signed-off-by: Daniel Weiße <dw@edgeless.systems>
This commit is contained in:
parent
48d614c959
commit
db79784045
57 changed files with 746 additions and 585 deletions
|
@ -14,6 +14,7 @@ import (
|
|||
"github.com/edgelesssys/constellation/bootstrapper/internal/kubelet"
|
||||
"github.com/edgelesssys/constellation/bootstrapper/nodestate"
|
||||
"github.com/edgelesssys/constellation/bootstrapper/role"
|
||||
"github.com/edgelesssys/constellation/internal/attestation"
|
||||
"github.com/edgelesssys/constellation/internal/cloud/metadata"
|
||||
"github.com/edgelesssys/constellation/internal/constants"
|
||||
"github.com/edgelesssys/constellation/internal/file"
|
||||
|
@ -230,7 +231,12 @@ func (c *JoinClient) startNodeAndJoin(ticket *joinproto.IssueJoinTicketResponse,
|
|||
}
|
||||
}()
|
||||
|
||||
nodeLockAcquired, err := c.nodeLock.TryLockOnce(ticket.OwnerId, ticket.ClusterId)
|
||||
clusterID, err := attestation.DeriveClusterID(ticket.MeasurementSalt, ticket.MeasurementSecret)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
nodeLockAcquired, err := c.nodeLock.TryLockOnce(clusterID)
|
||||
if err != nil {
|
||||
c.log.With(zap.Error(err)).Errorf("Acquiring node lock failed")
|
||||
return fmt.Errorf("acquiring node lock: %w", err)
|
||||
|
@ -259,9 +265,8 @@ func (c *JoinClient) startNodeAndJoin(ticket *joinproto.IssueJoinTicketResponse,
|
|||
}
|
||||
|
||||
state := nodestate.NodeState{
|
||||
Role: c.role,
|
||||
OwnerID: ticket.OwnerId,
|
||||
ClusterID: ticket.ClusterId,
|
||||
Role: c.role,
|
||||
MeasurementSalt: ticket.MeasurementSalt,
|
||||
}
|
||||
if err := state.ToFile(c.fileHandler); err != nil {
|
||||
return fmt.Errorf("persisting node state: %w", err)
|
||||
|
@ -417,5 +422,5 @@ type cleaner interface {
|
|||
type locker interface {
|
||||
// TryLockOnce tries to lock the node. If the node is already locked, it
|
||||
// returns false. If the node is unlocked, it locks it and returns true.
|
||||
TryLockOnce(ownerID, clusterID []byte) (bool, error)
|
||||
TryLockOnce(clusterID []byte) (bool, error)
|
||||
}
|
||||
|
|
|
@ -34,7 +34,7 @@ func TestMain(m *testing.M) {
|
|||
func TestClient(t *testing.T) {
|
||||
someErr := errors.New("failed")
|
||||
lockedLock := newFakeLock()
|
||||
aqcuiredLock, lockErr := lockedLock.TryLockOnce(nil, nil)
|
||||
aqcuiredLock, lockErr := lockedLock.TryLockOnce(nil)
|
||||
require.True(t, aqcuiredLock)
|
||||
require.Nil(t, lockErr)
|
||||
workerSelf := metadata.InstanceMetadata{Role: role.Worker, Name: "node-1"}
|
||||
|
@ -246,9 +246,9 @@ func TestClient(t *testing.T) {
|
|||
assert.False(tc.clusterJoiner.joinClusterCalled)
|
||||
}
|
||||
if tc.wantLock {
|
||||
assert.False(client.nodeLock.TryLockOnce(nil, nil)) // lock should be locked
|
||||
assert.False(client.nodeLock.TryLockOnce(nil)) // lock should be locked
|
||||
} else {
|
||||
assert.True(client.nodeLock.TryLockOnce(nil, nil))
|
||||
assert.True(client.nodeLock.TryLockOnce(nil))
|
||||
}
|
||||
})
|
||||
}
|
||||
|
@ -430,6 +430,6 @@ func newFakeLock() *fakeLock {
|
|||
}
|
||||
}
|
||||
|
||||
func (l *fakeLock) TryLockOnce(_, _ []byte) (bool, error) {
|
||||
func (l *fakeLock) TryLockOnce(_ []byte) (bool, error) {
|
||||
return l.state.TryLock(), nil
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue