jobtypes

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Dec 30, 2024 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DeploymentStatusString

func DeploymentStatusString(d DeploymentStatus) string

Types

type AllocationConfig

type AllocationConfig struct {
	Executor    AllocationExecutor        `json:"executor"`              // the executor of the allocation
	Resources   types.Resources           `json:"resources"`             // the HW resources required by the allocation
	Execution   types.SpecConfig          `json:"execution"`             // the allocation execution configuration
	DNSName     string                    `json:"dns_name,omitempty"`    // the internal DNS name of the allocation
	Keys        []string                  `json:"keys,omitempty"`        // names of the authorized ssh keys for the allocation
	Provision   []string                  `json:"provision,omitempty"`   // names of provisioning scripts to run (in order)
	HealthCheck types.HealthCheckManifest `json:"healthcheck,omitempty"` // name of the health check script
}

AllocationConfig is the configuration of an allocation

type AllocationExecutor

type AllocationExecutor string

AllocationExecutor is the executor reoquired for the allocation

const (
	ExecutorFirecracker AllocationExecutor = "firecracker"
	ExecutorDocker      AllocationExecutor = "docker"
	ExecutorNull        AllocationExecutor = "null"
)

type AllocationManifest

type AllocationManifest struct {
	ID          string                    `json:"id"`              // allocation unique id
	NodeID      string                    `json:"node_id"`         // allocation node
	Handle      actor.Handle              `json:"handle"`          // handle of the allocation control actor
	DNSName     string                    `json:"dns_name"`        // (internal) DNS name of the allocation
	PrivAddr    string                    `json:"priv_addr"`       // (VPN) private IP address of the allocation peer
	Ports       map[int]int               `json:"ports,omitempty"` // port mapping, public -> private
	Healthcheck types.HealthCheckManifest `json:"healthcheck"`     // healthcheck configuration
}

type Bid

type Bid struct {
	V1 *BidV1
}

Bid is the version struct for Bids in response to a bid request

func (*Bid) EnsembleID

func (b *Bid) EnsembleID() string

func (*Bid) Handle

func (b *Bid) Handle() actor.Handle

func (*Bid) Location

func (b *Bid) Location() Location

func (*Bid) NodeID

func (b *Bid) NodeID() string

func (*Bid) Peer

func (b *Bid) Peer() string

func (*Bid) Sign

func (b *Bid) Sign(key did.Provider) error

func (*Bid) SignatureData

func (b *Bid) SignatureData() ([]byte, error)

func (*Bid) Validate

func (b *Bid) Validate() error

type BidRequest

type BidRequest struct {
	V1 *BidRequestV1
}

BidRequest is a versioned bid request

type BidRequestV1

type BidRequestV1 struct {
	// NodeID is the unique identifier for a node, within the context of an ensemble
	NodeID string `json:"node_id"`

	// Executors list of required executors to support the allocation(s)
	Executors []AllocationExecutor `json:"executors"`

	// Resources (aggregate) required hardware resources
	Resources types.Resources `json:"resources"`

	// Location is the node location constraints
	Location LocationConstraints `json:"location,omitempty"`

	PublicPorts struct {
		Static  []int `json:"static,omitempty"`  // statically configured public ports
		Dynamic int   `json:"dynamic,omitempty"` // number of dynamic ports
	} `json:"public_ports,omitempty"`

	GeneralRequirements struct {
		PrivilegedDocker bool `json:"privileged_docker,omitempty"`
	} `json:"general_requirements,omitempty"`

	// contract attached to a bid request
	ContractDID did.DID
}

BidRequestV1 is v1 of bid requests for a node to use for deployment

type BidV1

type BidV1 struct {
	EnsembleID string       // unique identifier for the ensemble
	NodeID     string       // unique identifier for a node; matches the id of the BidRequest to which this bid pertains
	Peer       string       // the peer ID of the node
	Location   Location     // the location of the node
	Handle     actor.Handle // the handle of the actor submitting the bid
	Signature  []byte
}

BidV1 is v1 of the bid structure

type DeploymentSnapshot

type DeploymentSnapshot struct {
	// candidates keeps state of candidates while committing.
	Candidates map[string]Bid

	// Expiry is the time passed as an argument when calling Deploy()
	Expiry time.Time
}

type DeploymentStatus

type DeploymentStatus int
const (
	DeploymentStatusPreparing DeploymentStatus = iota
	DeploymentStatusGenerating
	DeploymentStatusCommitting
	DeploymentStatusProvisioning
	DeploymentStatusRunning
	DeploymentStatusFailed
	DeploymentStatusShuttingDown
	DeploymentStatusCompleted
)

type EdgeConstraint

type EdgeConstraint struct {
	S   string `json:"s"`             // source node ID
	T   string `json:"t"`             // target node ID
	RTT uint   `json:"rtt,omitempty"` // round trip time in milliseconds
	BW  uint   `json:"bw,omitempty"`  // bandwidth in bits per second
}

EdgeConstraint is a constraint for a network edge between two nodes

type EnsembleBidRequest

type EnsembleBidRequest struct {
	// ID is the unique identifier of an ensemble (in the context of the orchestrator)
	ID string `json:"id"`

	// Request is the list of node bid requests
	Request []BidRequest `json:"request"`

	// PeerExclusion is the list of peers to exclude from bidding
	PeerExclusion []string `json:"peer_exclusion,omitempty"`
}

EnsembleBidRequest is a request for a bids pertaining to an ensemble

Note: At the moment, we embed a bid request for each node This is fine for small deployments, and a small network, which is what we have. For large deployments however, this won't scale and we will have to create aggregate bid requests for related group of nodes and also handle them with bid request aggregators who control multiple nodes.

func (*EnsembleBidRequest) Validate

func (b *EnsembleBidRequest) Validate() error

type EnsembleConfig

type EnsembleConfig struct {
	V1 *EnsembleConfigV1 `json:"v1"`
}

EnsembleConfig is the versioned structure that contains the ensemble configuration

func (*EnsembleConfig) Allocation

func (e *EnsembleConfig) Allocation(allocID string) (AllocationConfig, bool)

func (*EnsembleConfig) Allocations

func (e *EnsembleConfig) Allocations() map[string]AllocationConfig

func (*EnsembleConfig) Clone

func (e *EnsembleConfig) Clone() EnsembleConfig

func (*EnsembleConfig) EdgeConstraints

func (e *EnsembleConfig) EdgeConstraints() []EdgeConstraint

func (*EnsembleConfig) Node

func (e *EnsembleConfig) Node(nodeID string) (NodeConfig, bool)

func (*EnsembleConfig) Nodes

func (e *EnsembleConfig) Nodes() map[string]NodeConfig

func (*EnsembleConfig) Validate

func (e *EnsembleConfig) Validate() error

config validation

type EnsembleConfigV1

type EnsembleConfigV1 struct {
	Allocations map[string]AllocationConfig `json:"allocations"`          // (named) allocations in the ensemble
	Nodes       map[string]NodeConfig       `json:"nodes"`                // (named) nodes in the ensemble
	Edges       []EdgeConstraint            `json:"edges,omitempty"`      // network edge constraints
	Supervisor  SupervisorConfig            `json:"supervisor,omitempty"` // supervision structure
	Keys        map[string]string           `json:"keys,omitempty"`       // (named) ssh public keys relevant to the allocation
	Scripts     map[string][]byte           `json:"scripts,omitempty"`    // (named) provisioning scripts
}

EnsembleConfigV1 is version 1 of the configuration for an ensemble

type EnsembleManifest

type EnsembleManifest struct {
	ID           string                        // ensemble globally unique id
	Orchestrator actor.Handle                  // orchestrator actor
	Allocations  map[string]AllocationManifest // allocation name -> manifest
	Nodes        map[string]NodeManifest       // node name -> manifest
}

func (*EnsembleManifest) Clone

func (mf *EnsembleManifest) Clone() EnsembleManifest

type Location

type Location struct {
	Region  string `json:"region,omitempty"`  // geographical region
	Country string `json:"country,omitempty"` // country code
	City    string `json:"city,omitempty"`    // city name
	ASN     uint   `json:"asn,omitempty"`     // autonomous system number
	ISP     string `json:"isp,omitempty"`     // internet service provider
}

Location is a geographical location on Planet Earth

func (*Location) Includes

func (l *Location) Includes(other Location) bool

type LocationConstraints

type LocationConstraints struct {
	Accept []Location `json:"accept,omitempty"` // list of accepted locations
	Reject []Location `json:"reject,omitempty"` // list of rejected locations
}

LocationConstraints provides the node location placement constraints

type NodeConfig

type NodeConfig struct {
	Allocations []string            `json:"allocations"`        // list of allocation IDs
	Ports       []PortConfig        `json:"ports,omitempty"`    // list of port mappings
	Location    LocationConstraints `json:"location,omitempty"` // location constraints
	Peer        string              `json:"peer,omitempty"`     // peer ID to use for this node

}

NodeConfig is the configuration of a distinct DMS node

type NodeManifest

type NodeManifest struct {
	ID          string       `json:"id"`             // node unique id
	Peer        string       `json:"peer,omitempty"` // peer where the node is running
	Handle      actor.Handle `json:"handle"`         // handle of the control actor for the node
	PubAddrss   []string     `json:"pub_addrss"`     // public IP4/6 address of the node peer
	Location    Location     `json:"location"`       // location of the peer
	Allocations []string     `json:"allocations"`    // allocations in the nod
}

type OrchestratorView

type OrchestratorView struct {
	types.BaseDBModel
	DeploymentID       string
	Cfg                EnsembleConfig
	Manifest           EnsembleManifest
	Status             DeploymentStatus
	DeploymentSnapshot DeploymentSnapshot
	PrivKey            []byte
}

type PortConfig

type PortConfig struct {
	Public     int    `json:"public"`     // public port number
	Private    int    `json:"private"`    // private port number
	Allocation string `json:"allocation"` // allocation ID
}

PortConfig is the configuration for a port mapping a public port to a private port in an allocation

type SupervisorConfig

type SupervisorConfig struct {
	Strategy    SupervisorStrategy `json:"strategy,omitempty"`    // supervision strategy
	Allocations []string           `json:"allocations,omitempty"` // list of allocation IDs
	Children    []SupervisorConfig `json:"children,omitempty"`    // list of child supervisors
}

SupervisorConfig is the supervisory structure configuration for the ensemble

type SupervisorStrategy

type SupervisorStrategy string

SupervisoryStrategy is the name of a supervision strategy

const (
	StrategyOneForOne  SupervisorStrategy = "OneForOne"
	StrategyAllForOne  SupervisorStrategy = "AllForOne"
	StrategyRestForOne SupervisorStrategy = "RestForOne"
)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
JackTT - Gopher 🇻🇳