Downstream worker connections are tracked by worker id (#2949)
When possible downstream workers will include their worker id information in the connections they establish with the upstream using the nodeenrollment library. The tracking listener now tracks connections that are connected in this same way instead of just connections of type *tls.Conn.
This commit is contained in:
1 parent
5e3244a2e5
commit
1e89be1b1a
17 files changed
+951
-215
No files matched your search
@@ -10,10 +10,12 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/hashicorp/boundary/internal/daemon/cluster"
|
||||
"github.com/hashicorp/boundary/internal/server/store"
|
||||
|
||||
"github.com/hashicorp/boundary/internal/daemon/common"
|
||||
"github.com/hashicorp/boundary/internal/errors"
|
||||
"github.com/hashicorp/boundary/internal/observability/event"
|
||||
"github.com/hashicorp/boundary/internal/server"
|
||||
"github.com/hashicorp/boundary/internal/server/store"
|
||||
"github.com/hashicorp/boundary/internal/types/scope"
|
||||
)
|
||||
|
||||
// In the future we could make this configurable
|
||||
@@ -190,18 +192,34 @@ func (c *Controller) startWorkerConnectionMaintenanceTicking(cancelCtx context.C
|
||||
return
|
||||
|
||||
case <-timer.C:
|
||||
repo, err := c.WorkerAuthRepoStorageFn()
|
||||
if err != nil {
|
||||
event.WriteError(cancelCtx, op, err, event.WithInfoMsg("error fetching repository for cluster connection maintenance"))
|
||||
break
|
||||
connectionState := m.Connected()
|
||||
if len(connectionState.WorkerIds()) > 0 {
|
||||
serverRepo, err := c.ServersRepoFn()
|
||||
if err != nil {
|
||||
event.WriteError(cancelCtx, op, err, event.WithInfoMsg("error fetching server repository for cluster connection maintenance"))
|
||||
break
|
||||
}
|
||||
knownWorker, err := serverRepo.ListWorkers(cancelCtx, []string{scope.Global.String()}, server.WithWorkerPool(connectionState.WorkerIds()), server.WithLiveness(-1))
|
||||
if err != nil {
|
||||
event.WriteError(cancelCtx, op, err, event.WithInfoMsg("couldn't get known workers from repo"))
|
||||
break
|
||||
}
|
||||
connectionState.DisconnectMissingWorkers(common.WorkerList(knownWorker).PublicIds())
|
||||
}
|
||||
wKeyIds := m.Connected()
|
||||
authorized, err := repo.FilterToAuthorizedWorkerKeyIds(cancelCtx, wKeyIds)
|
||||
if err != nil {
|
||||
event.WriteError(cancelCtx, op, err, event.WithInfoMsg("couldn't get authorized workers from repo"))
|
||||
break
|
||||
|
||||
if len(connectionState.UnmappedKeyIds()) > 0 {
|
||||
repo, err := c.WorkerAuthRepoStorageFn()
|
||||
if err != nil {
|
||||
event.WriteError(cancelCtx, op, err, event.WithInfoMsg("error fetching worker auth repository for cluster connection maintenance"))
|
||||
break
|
||||
}
|
||||
authorized, err := repo.FilterToAuthorizedWorkerKeyIds(cancelCtx, connectionState.UnmappedKeyIds())
|
||||
if err != nil {
|
||||
event.WriteError(cancelCtx, op, err, event.WithInfoMsg("couldn't get authorized workers from repo"))
|
||||
break
|
||||
}
|
||||
connectionState.DisconnectMissingKeyIds(authorized)
|
||||
}
|
||||
cluster.DisconnectUnauthorized(m, wKeyIds, authorized)
|
||||
}
|
||||
|
||||
timer.Reset(getRandomInterval())
|
||||
|
||||
Reference in new issue
Block a user