Documentation ¶
Index ¶
- func SortedIPs(ips []string) []string
- type BackoffTimer
- type BenchmarkHasher
- type Config
- type ContainerInfo
- type ContainerMetrics
- type DealExtractor
- type DealInfoSupplier
- type Description
- func (d *Description) Expose() (nat.PortSet, nat.PortMap, error)
- func (d *Description) FormatEnv() []string
- func (d *Description) GpuDeviceIDs() []gpu.GPUID
- func (d *Description) ID() string
- func (d *Description) IsGPURequired() bool
- func (d *Description) Mounts(source string) []volume.Mount
- func (d *Description) Networks() []structs.Network
- func (d *Description) Volumes() map[string]*pb.Volume
- type DevConfig
- type DeviceKeyer
- type ExecConnection
- type Option
- func WithBenchmarkList(list benchmarks.BenchList) Option
- func WithCertRotator(certRotator util.HitlessCertRotator) Option
- func WithConfig(cfg *Config) Option
- func WithContext(ctx context.Context) Option
- func WithCreds(creds credentials.TransportCredentials) Option
- func WithDWH(d sonm.DWHClient) Option
- func WithETH(e blockchain.API) Option
- func WithKey(key *ecdsa.PrivateKey) Option
- func WithMatcher(matcher matcher.Matcher) Option
- func WithOverseer(ovs Overseer) Option
- func WithPlugins(plugins *plugin.Repository) Option
- func WithSSH(ssh SSH) Option
- func WithStateStorage(s *state.Storage) Option
- func WithVersion(v string) Option
- func WithWhitelist(whitelist Whitelist) Option
- type Overseer
- type ResourcesConfig
- type SSH
- type SSHConfig
- type Whitelist
- type WhitelistConfig
- type WhitelistRecord
- type Worker
- func (m *Worker) AskPlanByTaskID(taskID string) (*pb.AskPlan, error)
- func (m *Worker) AskPlans(ctx context.Context, _ *pb.Empty) (*pb.AskPlansReply, error)
- func (m *Worker) Close()
- func (m *Worker) CollectTasksStatuses(statuses ...pb.TaskStatusReply_Status) map[string]*pb.TaskStatusReply
- func (m *Worker) CreateAskPlan(ctx context.Context, request *pb.AskPlan) (*pb.ID, error)
- func (m *Worker) DebugState(ctx context.Context, _ *pb.Empty) (*pb.DebugStateReply, error)
- func (m *Worker) Devices(ctx context.Context, request *pb.Empty) (*pb.DevicesReply, error)
- func (m *Worker) FreeDevices(ctx context.Context, request *pb.Empty) (*pb.DevicesReply, error)
- func (m *Worker) GetContainerInfo(id string) (*ContainerInfo, bool)
- func (m *Worker) GetDealInfo(ctx context.Context, id *pb.ID) (*pb.DealInfoReply, error)
- func (m *Worker) JoinNetwork(ctx context.Context, request *pb.WorkerJoinNetworkRequest) (*pb.NetworkSpec, error)
- func (m *Worker) NextMaintenance(ctx context.Context, _ *pb.Empty) (*pb.Timestamp, error)
- func (m *Worker) PullTask(request *pb.PullTaskRequest, stream pb.Worker_PullTaskServer) error
- func (m *Worker) PurgeAskPlans(ctx context.Context, _ *pb.Empty) (*pb.Empty, error)
- func (m *Worker) PurgeBenchmarks(ctx context.Context, _ *pb.Empty) (*pb.Empty, error)
- func (m *Worker) PushTask(stream pb.Worker_PushTaskServer) error
- func (m *Worker) RemoveAskPlan(ctx context.Context, request *pb.ID) (*pb.Empty, error)
- func (m *Worker) RemoveBenchmark(ctx context.Context, id *pb.NumericID) (*pb.Empty, error)
- func (m *Worker) RunSSH() error
- func (m *Worker) ScheduleMaintenance(ctx context.Context, timestamp *pb.Timestamp) (*pb.Empty, error)
- func (m *Worker) Serve() error
- func (m Worker) SetupDefaults() error
- func (m *Worker) StartTask(ctx context.Context, request *pb.StartTaskRequest) (*pb.StartTaskReply, error)
- func (m *Worker) Status(ctx context.Context, _ *pb.Empty) (*pb.StatusReply, error)
- func (m *Worker) StopTask(ctx context.Context, request *pb.ID) (*pb.Empty, error)
- func (m *Worker) TaskLogs(request *pb.TaskLogsRequest, server pb.Worker_TaskLogsServer) error
- func (m *Worker) TaskStatus(ctx context.Context, req *pb.ID) (*pb.TaskStatusReply, error)
- func (m *Worker) Tasks(ctx context.Context, request *pb.Empty) (*pb.TaskListReply, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type BackoffTimer ¶
type BackoffTimer struct {
// contains filtered or unexported fields
}
BackoffTimer implementation
func NewBackoffTimer ¶
func NewBackoffTimer(sleep, maxsleep time.Duration) *BackoffTimer
NewBackoffTimer implementations one direction backoff policy
func (*BackoffTimer) C ¶
func (b *BackoffTimer) C() <-chan time.Time
C resets Timer and returns Timer.C
type BenchmarkHasher ¶
type BenchmarkHasher interface { // Hash of the hardware, empty string means that we need to rebenchmark everytime HardwareHash() string }
type Config ¶
type Config struct { Endpoint string `yaml:"endpoint" required:"true"` Logging logging.Config `yaml:"logging"` Resources *ResourcesConfig `yaml:"resources" required:"false" ` Blockchain *blockchain.Config `yaml:"blockchain"` NPP npp.Config `yaml:"npp"` SSH *SSHConfig `yaml:"ssh" required:"false" ` PublicIPs []string `yaml:"public_ip_addrs" required:"false" ` Plugins plugin.Config `yaml:"plugins"` Storage state.StorageConfig `yaml:"store"` Benchmarks benchmarks.Config `yaml:"benchmarks"` Whitelist WhitelistConfig `yaml:"whitelist"` MetricsListenAddr string `yaml:"metrics_listen_addr" default:"127.0.0.1:14000"` DWH dwh.YAMLConfig `yaml:"dwh"` Matcher *matcher.YAMLConfig `yaml:"matcher"` Salesman salesman.YAMLConfig `yaml:"salesman"` Master common.Address `yaml:"master" required:"true"` Development *DevConfig `yaml:"development"` Admin *common.Address `yaml:"admin"` Debug *debug.Config `yaml:"debug"` }
type ContainerInfo ¶
type ContainerInfo struct { ID string ImageName string StartAt time.Time Ports nat.PortMap PublicKey ssh.PublicKey Cgroup string CgroupParent string NetworkIDs []string DealID string TaskId string // contains filtered or unexported fields }
ContainerInfo is a brief information about containers
func (*ContainerInfo) IntoProto ¶
func (c *ContainerInfo) IntoProto(ctx context.Context) *pb.TaskStatusReply
type ContainerMetrics ¶
type ContainerMetrics struct {
// contains filtered or unexported fields
}
ContainerMetrics are metrics collected from Docker about running containers
func (*ContainerMetrics) Marshal ¶
func (m *ContainerMetrics) Marshal() *pb.ResourceUsage
type DealExtractor ¶
DealExtractor allows to extract deal id that is used for authorization.
type DealInfoSupplier ¶
type Description ¶
type Description struct { pb.Container Reference reference.Reference Auth string Resources *pb.AskPlanResources CGroupParent string Cmd []string TaskId string DealId string GPUDevices []gpu.GPUID // contains filtered or unexported fields }
Description for a target application.
func (*Description) FormatEnv ¶
func (d *Description) FormatEnv() []string
func (*Description) GpuDeviceIDs ¶
func (d *Description) GpuDeviceIDs() []gpu.GPUID
func (*Description) ID ¶
func (d *Description) ID() string
func (*Description) IsGPURequired ¶
func (d *Description) IsGPURequired() bool
func (*Description) Networks ¶
func (d *Description) Networks() []structs.Network
type DevConfig ¶
type DevConfig struct {
DisableMasterApproval bool `yaml:"disable_master_approval"`
}
type DeviceKeyer ¶
type DeviceKeyer interface {
StorageKey() string
}
type ExecConnection ¶
type ExecConnection types.HijackedResponse
type Option ¶
type Option func(*options)
func WithBenchmarkList ¶
func WithBenchmarkList(list benchmarks.BenchList) Option
func WithCertRotator ¶
func WithCertRotator(certRotator util.HitlessCertRotator) Option
func WithConfig ¶
func WithContext ¶
func WithCreds ¶
func WithCreds(creds credentials.TransportCredentials) Option
func WithETH ¶
func WithETH(e blockchain.API) Option
func WithKey ¶
func WithKey(key *ecdsa.PrivateKey) Option
func WithMatcher ¶
func WithOverseer ¶
func WithPlugins ¶
func WithPlugins(plugins *plugin.Repository) Option
func WithStateStorage ¶
func WithVersion ¶
func WithWhitelist ¶
type Overseer ¶
type Overseer interface { // Load loads an image from the specified reader to the Docker. Load(ctx context.Context, rd io.Reader) (imageLoadStatus, error) // Save saves an image from the Docker into the returned reader. Save(ctx context.Context, imageID string) (types.ImageInspect, io.ReadCloser, error) // Spool prepares an application for its further start. // // For Docker containers this is an equivalent of pulling from the registry. Spool(ctx context.Context, d Description) error // Start attempts to start an application using the specified description. // // After successful starting an application becomes a target for accepting request, but not guarantees // to complete them. Start(ctx context.Context, description Description) (chan pb.TaskStatusReply_Status, ContainerInfo, error) // Exec a given command in running container Exec(ctx context.Context, Id string, cmd []string, env []string, isTty bool, wCh <-chan ssh.Window) (types.HijackedResponse, error) // Stop terminates the container. Stop(ctx context.Context, containerID string) error // Makes all cleanup related to closed deal OnDealFinish(ctx context.Context, containerID string) error // Info returns runtime statistics collected from all running containers. // // Depending on the implementation this can be cached. Info(ctx context.Context) (map[string]ContainerMetrics, error) // Fetch logs of the container Logs(ctx context.Context, id string, opts types.ContainerLogsOptions) (io.ReadCloser, error) // Close terminates all associated asynchronous operations and prepares the Overseer for shutting down. Close() error }
Overseer watches all worker's applications.
func NewOverseer ¶
NewOverseer creates new overseer
type ResourcesConfig ¶
type ResourcesConfig struct { Cgroup string `required:"true" yaml:"cgroup"` Resources *specs.LinuxResources `required:"false" yaml:"resources"` }
type Whitelist ¶
type Whitelist interface {
Allowed(ctx context.Context, ref reference.Reference, auth string) (bool, reference.Reference, error)
}
func NewWhitelist ¶
func NewWhitelist(ctx context.Context, config *WhitelistConfig) Whitelist
type WhitelistConfig ¶
type WhitelistRecord ¶
type WhitelistRecord struct {
AllowedHashes []string `json:"allowed_hashes"`
}
type Worker ¶
type Worker struct {
// contains filtered or unexported fields
}
Worker holds information about jobs, make orders to Observer and communicates with Worker
func (*Worker) AskPlanByTaskID ¶
func (*Worker) CollectTasksStatuses ¶
func (m *Worker) CollectTasksStatuses(statuses ...pb.TaskStatusReply_Status) map[string]*pb.TaskStatusReply
func (*Worker) CreateAskPlan ¶
func (*Worker) DebugState ¶
func (*Worker) FreeDevices ¶
FreeDevice provides information about unallocated resources that can be turned into ask-plans. TODO: Looks like DevicesReply is not really suitable here
func (*Worker) GetContainerInfo ¶
func (m *Worker) GetContainerInfo(id string) (*ContainerInfo, bool)
func (*Worker) GetDealInfo ¶
func (*Worker) JoinNetwork ¶
func (m *Worker) JoinNetwork(ctx context.Context, request *pb.WorkerJoinNetworkRequest) (*pb.NetworkSpec, error)
TODO: proper request
func (*Worker) NextMaintenance ¶
func (*Worker) PullTask ¶
func (m *Worker) PullTask(request *pb.PullTaskRequest, stream pb.Worker_PullTaskServer) error
func (*Worker) PurgeAskPlans ¶
func (*Worker) PurgeBenchmarks ¶
func (*Worker) RemoveAskPlan ¶
func (*Worker) RemoveBenchmark ¶
func (*Worker) ScheduleMaintenance ¶
func (Worker) SetupDefaults ¶
func (m Worker) SetupDefaults() error
func (*Worker) StartTask ¶
func (m *Worker) StartTask(ctx context.Context, request *pb.StartTaskRequest) (*pb.StartTaskReply, error)
func (*Worker) TaskLogs ¶
func (m *Worker) TaskLogs(request *pb.TaskLogsRequest, server pb.Worker_TaskLogsServer) error
TaskLogs returns logs from container