feat(worker): set storage bucket states for worker status
Co-authored-by: Damian Debkowski <damian.debkowski@hashicorp.com>
This commit is contained in:
1 parent
162a857a29
commit
670a43ca22
1 file changed
+20
-13
@@ -16,6 +16,7 @@ import (
|
||||
pb "github.com/hashicorp/boundary/internal/gen/controller/servers"
|
||||
pbs "github.com/hashicorp/boundary/internal/gen/controller/servers/services"
|
||||
"github.com/hashicorp/boundary/internal/server"
|
||||
"github.com/hashicorp/boundary/sdk/pbs/plugin"
|
||||
"github.com/hashicorp/boundary/version"
|
||||
"github.com/hashicorp/go-secure-stdlib/parseutil"
|
||||
"github.com/hashicorp/go-secure-stdlib/strutil"
|
||||
@@ -197,25 +198,31 @@ func (w *Worker) sendWorkerStatus(cancelCtx context.Context, sessionManager sess
|
||||
event.WriteError(cancelCtx, op, errors.New("worker name and keyId are both empty; at least one is needed to identify a worker"),
|
||||
event.WithInfoMsg("error making status request to controller"))
|
||||
}
|
||||
// If the local storage state is unknown, and we have recording storage set, get the state from the recording storage
|
||||
// and set it on the worker. This is done once to ensure that the worker has the correct state for the first status
|
||||
// call.
|
||||
if w.localStorageState.Load() == server.UnknownLocalStorageState && w.RecordingStorage != nil {
|
||||
w.localStorageState.Store(w.RecordingStorage.GetLocalStorageState(cancelCtx))
|
||||
|
||||
var storageBucketCredentialStates map[string]*plugin.StorageBucketCredentialState
|
||||
if w.RecordingStorage != nil {
|
||||
storageBucketCredentialStates = w.RecordingStorage.GetStorageBucketCredentialStates()
|
||||
// If the local storage state is unknown, and we have recording storage set, get the state from the recording storage
|
||||
// and set it on the worker. This is done once to ensure that the worker has the correct state for the first status
|
||||
// call.
|
||||
if w.localStorageState.Load() == server.UnknownLocalStorageState {
|
||||
w.localStorageState.Store(w.RecordingStorage.GetLocalStorageState(cancelCtx))
|
||||
}
|
||||
}
|
||||
versionInfo := version.Get()
|
||||
connectionState := w.downstreamConnManager.Connected()
|
||||
result, err := client.Status(statusCtx, &pbs.StatusRequest{
|
||||
Jobs: activeJobs,
|
||||
WorkerStatus: &pb.ServerWorkerStatus{
|
||||
Name: w.conf.RawConfig.Worker.Name,
|
||||
Description: w.conf.RawConfig.Worker.Description,
|
||||
Address: w.conf.RawConfig.Worker.PublicAddr,
|
||||
Tags: tags,
|
||||
KeyId: keyId,
|
||||
ReleaseVersion: versionInfo.FullVersionNumber(false),
|
||||
OperationalState: w.operationalState.Load().(server.OperationalState).String(),
|
||||
LocalStorageState: w.localStorageState.Load().(server.LocalStorageState).String(),
|
||||
Name: w.conf.RawConfig.Worker.Name,
|
||||
Description: w.conf.RawConfig.Worker.Description,
|
||||
Address: w.conf.RawConfig.Worker.PublicAddr,
|
||||
Tags: tags,
|
||||
KeyId: keyId,
|
||||
ReleaseVersion: versionInfo.FullVersionNumber(false),
|
||||
OperationalState: w.operationalState.Load().(server.OperationalState).String(),
|
||||
LocalStorageState: w.localStorageState.Load().(server.LocalStorageState).String(),
|
||||
StorageBucketCredentialStates: storageBucketCredentialStates,
|
||||
},
|
||||
ConnectedWorkerKeyIdentifiers: connectionState.AllKeyIds(),
|
||||
ConnectedUnmappedWorkerKeyIdentifiers: connectionState.UnmappedKeyIds(),
|
||||
|
||||
Reference in new issue
Block a user