informant

package
v0.1.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 6, 2023 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	PrometheusPort uint16 = 9100

	CheckDeadlockDelay   time.Duration = 1 * time.Second
	CheckDeadlockTimeout time.Duration = 250 * time.Millisecond

	AgentBackgroundCheckDelay   time.Duration = 10 * time.Second
	AgentBackgroundCheckTimeout time.Duration = 250 * time.Millisecond

	AgentResumeTimeout  time.Duration = 100 * time.Millisecond
	AgentSuspendTimeout time.Duration = 200 * time.Millisecond
)
View Source
const ProtocolVersion uint32 = 1

ProtocolVersion is the current version of the agent<->informant protocol in use by this informant

Currently, each VM informant supports only one version at a time. In the future, this may change.

Variables

This section is empty.

Functions

This section is empty.

Types

type Agent

type Agent struct {
	// contains filtered or unexported fields
}

func (*Agent) CheckID

func (a *Agent) CheckID(timeout time.Duration) error

CheckID checks that the Agent's ID matches what's expected

If the agent has already been registered, then a failure in this method will unregister the agent.

If the Agent is unregistered before the call to CheckID() completes, the request will be cancelled and this method will return context.Canceled.

func (*Agent) EnsureUnregistered

func (a *Agent) EnsureUnregistered() (wasCurrent bool)

EnsureUnregistered unregisters the Agent if it is currently registered, signalling the AgentSet to use a new Agent if it isn't already

Returns whether the agent was the current Agent in use.

func (*Agent) Resume

func (a *Agent) Resume(timeout time.Duration) error

Resume attempts to restore the Agent as the current one in use, sending a request to its /resume endpoint

If the Agent is unregistered before the call to Resume() completes, the request will be cancelled and this method will return context.Canceled.

If the request fails, the Agent will be unregistered.

func (*Agent) SpawnSuspend

func (a *Agent) SpawnSuspend(timeout time.Duration, handleError func(error))

SpawnSuspend signals to the Agent that it is not *currently* in use, sending a request to its /suspend endpoint

Unlike other similar methods on Agent, SpawnSuspend will only wait for the request to be picked up by the request executor. Handling the result of the request is done in a separate goroutine.

If the Agent is unregistered before the call to Suspend() completes, the request will be cancelled and this method will return context.Canceled.

If the request fails, the Agent will be unregistered.

type AgentSet

type AgentSet struct {
	// contains filtered or unexported fields
}

AgentSet is the global state handling various autoscaler-agents that we could connect to

func NewAgentSet

func NewAgentSet() *AgentSet

NewAgentSet creates a new AgentSet and starts the necessary background tasks

On completion, the background tasks should be ended with the Stop method.

func (*AgentSet) Get

func (s *AgentSet) Get(id uuid.UUID) (_ *Agent, ok bool)

Get returns the requested Agent, if it exists

func (*AgentSet) RegisterNewAgent

func (s *AgentSet) RegisterNewAgent(info *api.AgentDesc) (uint32, int, error)

RegisterNewAgent instantiates our local information about the autsocaler-agent

Returns: protocol version, status code, error (if unsuccessful)

type State

type State struct {
	// contains filtered or unexported fields
}

State is the global state of the informant

func NewState

func NewState(agents *AgentSet) *State

NewState instantiates a new State object

func (*State) NotifyUpscale

func (s *State) NotifyUpscale(newResources *api.RawResources) (*struct{}, int, error)

NotifyUpscale signals that the VM's resource usage has been increased to the new amount

Returns: body (if successful), status code and error (if unsuccessful)

func (*State) RegisterAgent

func (s *State) RegisterAgent(info *api.AgentDesc) (*api.InformantDesc, int, error)

RegisterAgent registers a new or updated autoscaler-agent

Returns: body (if successful), status code, error (if unsuccessful)

func (*State) TryDownscale

func (s *State) TryDownscale(target *api.RawResources) (*api.DownscaleResult, int, error)

TryDownscale tries to downscale the VM's current resource usage, returning whether the proposed amount is ok

Returns: body (if successful), status code and error (if unsuccessful)

func (*State) UnregisterAgent

func (s *State) UnregisterAgent(info *api.AgentDesc) (*api.UnregisterAgent, int, error)

UnregisterAgent unregisters the autoscaler-agent given by info, if it is currently registered

If a different autoscaler-agent is currently registered, this method will do nothing.

Returns: body (if successful), status code and error (if unsuccessful)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL