Skip to content

Common method for command execution #291

Open
@0x2b3bfa0

Description

@0x2b3bfa0

It would be nice1 to have an Execute method to run commands in any of the active instances.

type Task interface {
Read(ctx context.Context) error
Create(ctx context.Context) error
Delete(ctx context.Context) error
Start(ctx context.Context) error
Stop(ctx context.Context) error
Push(ctx context.Context, source string) error
Pull(ctx context.Context, destination string) error

Loose ends

  • How to deal with parallelism?
    • Run the command on every instance and return a slice of results.
    • Allow users to specify an index in the range [0, parallelism[ and return an error if there aren't enough instances running to satisfy the requested index.
    • Allow users to list the running instances for a given task and select one of them to run the command on.
    • Pick a random instance every time. I had to include it. 😂

Draft proposal

  • Execute(instance uint16, input string, command ...string) (Result, error)

    • instance represents the instance index in the range [0, parallelism[; maybe we can use a string identifier instead.
    • input optionally, the standard input to feed the remote command with; "" will disable this function.
    • command is the slice of exec–like arguments; “no arguments” can default to sh or bash if appropriate.
    • Result is a struct containing
      • Standard output
      • Standard error
      • Exit code
  • ExecuteTTY(instance uint16, streams Streams, command ...string) error
    Same as above but with TTY and interactive streams, so it behaves like an ordinary SSH session. See kubectl exec for an example implementation.

Footnotes

  1. Not necessary because Integrate task resource #237 eliminates the need of SSH by implementing Standardize on logs and storage for communication #126

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions