Documentation ¶
Overview ¶
Package runner contains low-level code for running the machine node via SSH and locally.
Index ¶
- type Factory
- type FromPlanFactory
- type InvocationGetter
- type LocalFactory
- type LocalRunner
- func (r *LocalRunner) Recv(ctx context.Context, _, rp *plan.Plan) (*plan.Plan, error)
- func (r *LocalRunner) Send(ctx context.Context, p *plan.Plan) (*plan.Plan, error)
- func (r *LocalRunner) Start(ctx context.Context, qs quantity.MachNodeSet) (*remote.Pipeset, error)
- func (r *LocalRunner) Wait() error
- type RemoteFactory
- type RemoteRunner
- func (r *RemoteRunner) Recv(ctx context.Context, locp, remp *plan.Plan) (*plan.Plan, error)
- func (r *RemoteRunner) Send(ctx context.Context, p *plan.Plan) (*plan.Plan, error)
- func (r *RemoteRunner) Start(ctx context.Context, qs quantity.MachNodeSet) (*remote.Pipeset, error)
- func (r *RemoteRunner) Wait() error
- type Runner
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Factory ¶
type Factory interface { // MakeRunner creates a new Runner, representing a particular invoker session on a machine, and outputting to ldir. // It takes the plan p in case the factory is waiting to get machine configuration from it. MakeRunner(ldir string, p *plan.Plan, obs ...copier.Observer) (Runner, error) // Closer captures that Runner spawners can be closed once no more runners are needed. // For SSH runner spawners, this will close the SSH connection. io.Closer }
Factory is the interface of factories for machine node runners.
Runner factories can contain disposable state (for example, long-running SSH connections), and so can be closed.
func FactoryFromRemoteConfig ¶
FactoryFromRemoteConfig creates a remote factory using gc and mc, if mc is non-nil; else, it creates a local factory.
type FromPlanFactory ¶
type FromPlanFactory struct { // The global remoting config used for any remote connections initiated by this factory. Config *remote.Config // contains filtered or unexported fields }
FromPlanFactory is a runner factory that instantiates either a SSH or local runner depending on the machine configuration inside the first plan passed to it.
This is useful for single-shot invocation over a plan, where there is no benefit to setting up a connection based on central machine/SSH configuration. In the director, the invoker will set up the machine configuration in advance, and there is no need to consult the plan.
func (*FromPlanFactory) Close ¶
func (p *FromPlanFactory) Close() error
Close closes the runner factory, if it was ever instantiated.
func (*FromPlanFactory) MakeRunner ¶
func (p *FromPlanFactory) MakeRunner(ldir string, pl *plan.Plan, obs ...copier.Observer) (Runner, error)
MakeRunner makes a runner using the machine configuration in pl.
type InvocationGetter ¶
type InvocationGetter interface { // MachBin retrieves the default binary name for the node. MachBin() string // MachArgs computes the argument set for invoking the node binary. MachArgs(dir string) []string }
InvocationGetter is the interface of types that tell the invoker how to invoke the machine node.
type LocalFactory ¶
type LocalFactory struct{}
LocalFactory allows spawning of local runners using said path as the local directory.
func (LocalFactory) MakeRunner ¶
type LocalRunner ¶
type LocalRunner struct {
// contains filtered or unexported fields
}
LocalRunner runs the machine-runner locally.
func NewLocalRunner ¶
func NewLocalRunner(dir string) *LocalRunner
NewLocalRunner creates a new LocalRunner.
func (*LocalRunner) Recv ¶
Recv effectively does nothing but implement the general runner interface obligations and make sure the context is live.
func (*LocalRunner) Send ¶
Send effectively does nothing but implement the general runner interface obligations and make sure the context is live.
func (*LocalRunner) Start ¶
func (r *LocalRunner) Start(ctx context.Context, qs quantity.MachNodeSet) (*remote.Pipeset, error)
Start starts the machine-runner binary locally using ctx, and returns a pipeset for talking to it.
func (*LocalRunner) Wait ¶
func (r *LocalRunner) Wait() error
Wait waits for the running machine-runner binary to terminate.
type RemoteFactory ¶
type RemoteFactory struct {
// contains filtered or unexported fields
}
RemoteFactory is a factory that produces runners in the form of SSH sessions.
func NewRemoteFactory ¶
func NewRemoteFactory(gc *remote.Config, mc *remote.MachineConfig) (*RemoteFactory, error)
NewRemoteFactory opens a SSH connection using Config and mc. If successful, it creates a runner factory over it.
func (*RemoteFactory) Close ¶
func (s *RemoteFactory) Close() error
Close closes the underlying SSH connection being used for runners created by this factory.
func (*RemoteFactory) MakeRunner ¶
func (s *RemoteFactory) MakeRunner(ldir string, _ *plan.Plan, obs ...copier.Observer) (Runner, error)
MakeRunner constructs a runner using this factory's open SSH connection.
type RemoteRunner ¶
type RemoteRunner struct {
// contains filtered or unexported fields
}
RemoteRunner runs the machine-runner via SSH.
func NewRemoteRunner ¶
func NewRemoteRunner(r *remote.MachineRunner, localRoot string, o ...copier.Observer) (*RemoteRunner, error)
NewRemoteRunner creates a new RemoteRunner.
func (*RemoteRunner) Recv ¶
Recv copies bits of remp into locp, including run information and any compiler failures. It uses SFTP to transfer back any compile logs.
func (*RemoteRunner) Send ¶
Send translates p to the remote host, using SFTP to copy over any recipe files.
func (*RemoteRunner) Start ¶
func (r *RemoteRunner) Start(ctx context.Context, qs quantity.MachNodeSet) (*remote.Pipeset, error)
Start starts a SSH session connected to a machine node with the quantities specified in qs.
func (*RemoteRunner) Wait ¶
func (r *RemoteRunner) Wait() error
Wait waits for either the SSH session to finish, or the context supplied to Start to close.
type Runner ¶
type Runner interface { // Send performs any copying and transformation needed for p to run. // It returns a pointer to the plan to send to the machine node, which may or may not be p. Send(ctx context.Context, p *plan.Plan) (*plan.Plan, error) // Start starts the machine binary, returning a set of pipe readers and writers to use for communication with it. Start(ctx context.Context, qs quantity.MachNodeSet) (*remote.Pipeset, error) // Wait blocks waiting for the command to finish (or the context passed into Start to cancel). Wait() error // Recv merges the post-run plan runp into the original plan origp, copying back any files needed. // It returns a pointer to the final 'merged', which may or may not be origp and runp. // It may modify origp in place. Recv(ctx context.Context, origp, runp *plan.Plan) (*plan.Plan, error) }
Runner is the interface of types that know how to run the machine node.