Documentation ¶
Index ¶
- Constants
- Variables
- func NewTestMultihopWorkers(t testing.TB, logger hclog.Logger, controllerContext context.Context, ...) (kmsWorker *TestWorker, pkiWorker *TestWorker, childPkiWorker *TestWorker)
- func NewWorkerProxyServiceServer(cc *grpc.ClientConn, scsClient *atomic.Value) *workerProxyServiceServer
- type Config
- type HandlerProperties
- type LastStatusInformation
- type TestConnectionInfo
- type TestSessionInfo
- type TestWorker
- func (tw *TestWorker) AddClusterWorkerMember(t testing.TB, opts *TestWorkerOpts) *TestWorker
- func (tw *TestWorker) Cancel()
- func (tw *TestWorker) Config() *Config
- func (tw *TestWorker) Context() context.Context
- func (tw *TestWorker) LookupSession(id string) (TestSessionInfo, bool)
- func (tw *TestWorker) Name() string
- func (tw *TestWorker) ProxyAddrs() []string
- func (tw *TestWorker) Shutdown()
- func (tw *TestWorker) UpstreamAddrs() []string
- func (tw *TestWorker) Worker() *Worker
- type TestWorkerOpts
- type Worker
- func (w *Worker) GetHealthHandler() (http.Handler, error)
- func (w *Worker) GracefulShutdown() error
- func (w *Worker) HealthInformation() *pbhealth.HealthInfo
- func (w *Worker) LastStatusSuccess() *LastStatusInformation
- func (w *Worker) Reload(ctx context.Context, newConf *config.Config)
- func (w *Worker) Shutdown() error
- func (w *Worker) Start() error
- func (w *Worker) StartControllerConnections() error
- func (w *Worker) WaitForNextSuccessfulStatusUpdate() error
Constants ¶
const (
UnknownReceiverType receiverType = iota
)
Variables ¶
var GetProtocolContext = nilProtocolContext
var HandleHcpbClusterId func(s string) string
Functions ¶
func NewTestMultihopWorkers ¶ added in v0.11.1
func NewTestMultihopWorkers(t testing.TB, logger hclog.Logger, controllerContext context.Context, clusterAddrs []string, workerAuthKms wrapping.Wrapper, serversRepoFn common.ServersRepoFactory, pkiTags, childPkiTags map[string][]string, ) (kmsWorker *TestWorker, pkiWorker *TestWorker, childPkiWorker *TestWorker)
NewTestMultihopWorkers creates a KMS and PKI worker with the controller as an upstream, and a child PKI worker as a downstream of the PKI worker connected to the controller. Tags for the PKI and child PKI worker can be passed in, if desired
func NewWorkerProxyServiceServer ¶
func NewWorkerProxyServiceServer( cc *grpc.ClientConn, scsClient *atomic.Value, ) *workerProxyServiceServer
Types ¶
type HandlerProperties ¶
type HandlerProperties struct {
ListenerConfig *listenerutil.ListenerConfig
}
type LastStatusInformation ¶
type LastStatusInformation struct { *pbs.StatusResponse StatusTime time.Time LastCalculatedUpstreams []string }
type TestConnectionInfo ¶
type TestConnectionInfo struct { Id string Status pbs.CONNECTIONSTATUS CloseTime time.Time }
TestConnectionInfo provides detail about a particular connection as a part of TestSessionInfo. See that struct for details about the purpose of this data and how it's gathered.
type TestSessionInfo ¶
type TestSessionInfo struct { Id string Status pbs.SESSIONSTATUS // Connections is indexed by connection ID, which is also included // within TestConnectionInfo for convenience. Connections map[string]TestConnectionInfo }
TestSessionInfo provides detail about a particular session from the worker's local session state. This detail is a point-in-time snapshot of what's in sessionInfoMap for a particular session, and may not contain all of the information that is contained within it, or the underlying ConnInfoMap. Only details that are really important to testing are passed along.
type TestWorker ¶
type TestWorker struct {
// contains filtered or unexported fields
}
TestWorker wraps a base.Server and Worker to provide a fully-programmatic worker for tests. Error checking (for instance, for valid config) is not stringent at the moment.
func NewAuthorizedPkiTestWorker ¶ added in v0.12.0
func NewAuthorizedPkiTestWorker(t *testing.T, repo *server.Repository, name string, upstreams []string) (*TestWorker, string)
NewAuthorizedPkiTestWorker creates a new test worker with the provided upstreams and creates it in the provided repo as an authroized worker. It returns The TestWorker and it's boundary id.
func NewTestWorker ¶
func NewTestWorker(t testing.TB, opts *TestWorkerOpts) *TestWorker
func (*TestWorker) AddClusterWorkerMember ¶
func (tw *TestWorker) AddClusterWorkerMember(t testing.TB, opts *TestWorkerOpts) *TestWorker
func (*TestWorker) Cancel ¶
func (tw *TestWorker) Cancel()
func (*TestWorker) Config ¶
func (tw *TestWorker) Config() *Config
func (*TestWorker) Context ¶
func (tw *TestWorker) Context() context.Context
func (*TestWorker) LookupSession ¶
func (tw *TestWorker) LookupSession(id string) (TestSessionInfo, bool)
LookupSession returns session info from the worker's local session state.
The return boolean will be true if the session was found, false if it wasn't.
See TestSessionInfo for details on how to use this info.
func (*TestWorker) Name ¶
func (tw *TestWorker) Name() string
func (*TestWorker) ProxyAddrs ¶
func (tw *TestWorker) ProxyAddrs() []string
func (*TestWorker) Shutdown ¶
func (tw *TestWorker) Shutdown()
Shutdown runs any cleanup functions; be sure to run this after your test is done
func (*TestWorker) UpstreamAddrs ¶
func (tw *TestWorker) UpstreamAddrs() []string
func (*TestWorker) Worker ¶
func (tw *TestWorker) Worker() *Worker
Worker returns the underlying worker
type TestWorkerOpts ¶
type TestWorkerOpts struct { // Config; if not provided a dev one will be created Config *config.Config // Sets initial upstream addresses InitialUpstreams []string // If true, the worker will not be started DisableAutoStart bool // The worker auth KMS to use, or one will be created WorkerAuthKms wrapping.Wrapper // The worker credential storage KMS to use, or one will be created WorkerAuthStorageKms wrapping.Wrapper // The location of the worker's auth storage WorkerAuthStoragePath string // The name to use for the worker, otherwise one will be randomly // generated, unless provided in a non-nil Config Name string // The logger to use, or one will be created Logger hclog.Logger // The registerer to use for registering all the collectors. Nil means // no metrics are registered. PrometheusRegisterer prometheus.Registerer // The amount of time to wait before marking connections as closed when a // connection cannot be made back to the controller SuccessfulStatusGracePeriodDuration time.Duration // Overrides worker's nonceFn, for cases where we want to have control // over the nonce we send to the Controller NonceFn randFn // If set, override the normal auth rotation period AuthRotationPeriod time.Duration }
type Worker ¶
type Worker struct { // grpc.ClientConns are thread safe. // See https://github.com/grpc/grpc-go/blob/master/Documentation/concurrency.md#clients // This is exported for tests. GrpcClientConn *grpc.ClientConn // The storage for node enrollment WorkerAuthStorage *nodeefile.Storage WorkerAuthCurrentKeyId *ua.String WorkerAuthRegistrationRequest string // Test-specific options (and possibly hidden dev-mode flags) TestOverrideX509VerifyDnsName string TestOverrideX509VerifyCertPool *x509.CertPool TestOverrideAuthRotationPeriod time.Duration // contains filtered or unexported fields }
func (*Worker) GetHealthHandler ¶ added in v0.11.0
GetHealthHandler returns an http.Handler that can be used for handling health check requests for just the worker.
func (*Worker) GracefulShutdown ¶ added in v0.11.0
GracefulShutdownm sets the worker state to "shutdown" and will wait to return until there are no longer any active connections.
func (*Worker) HealthInformation ¶ added in v0.11.0
func (w *Worker) HealthInformation() *pbhealth.HealthInfo
HealthInformation returns the current worker process health information.
func (*Worker) LastStatusSuccess ¶
func (w *Worker) LastStatusSuccess() *LastStatusInformation
LastStatusSuccess reports the last time we sent a successful status request.
func (*Worker) Reload ¶ added in v0.10.4
Reload will update a worker with a new Config. The worker will only use relevant parts of the new config, specifically: - Worker Tags - Initial Upstream addresses
func (*Worker) Shutdown ¶
Shutdown shuts down the workers. skipListeners can be used to not stop listeners, useful for tests if we want to stop and start a worker. In order to create new listeners we'd have to migrate listener setup logic here -- doable, but work for later.
func (*Worker) StartControllerConnections ¶
StartControllerConnections starts up the resolver and initiates controller connection client creation
func (*Worker) WaitForNextSuccessfulStatusUpdate ¶
WaitForNextSuccessfulStatusUpdate waits for the next successful status. It's used by testing (and in the future, shutdown) in place of a more opaque and possibly unnecessarily long sleep for things like initial controller check-in, etc.
The timeout is aligned with the worker's status grace period. A nil error means the status was sent successfully.
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
Package common contains types and helper functions that are used across the different packages under internal/server/worker.
|
Package common contains types and helper functions that are used across the different packages under internal/server/worker. |
internal
|
|
metric
Package metric provides functions to initialize the worker specific collectors and hooks to measure metrics and update the relevant collectors.
|
Package metric provides functions to initialize the worker specific collectors and hooks to measure metrics and update the relevant collectors. |
Package proxy contains a collection of proxy handlers for the worker to call once a connection has been authorized.
|
Package proxy contains a collection of proxy handlers for the worker to call once a connection has been authorized. |