Documentation ¶
Index ¶
- Constants
- Variables
- type Bridge
- type Bridges
- type Cluster
- func (c *Cluster) CreateContainerSchedulerOpts(opts client.Container) (string, *client.Container, error)
- func (c *Cluster) GetContainerById(id string) (*client.Container, error)
- func (c *Cluster) IpNode(contIp, nodeIp, CartonId, email string) error
- func (c *Cluster) Nodes() ([]Node, error)
- func (c *Cluster) NodesForMetadata(metadata map[string]string) ([]Node, error)
- func (c *Cluster) Register(node Node) error
- func (c *Cluster) RemoveContainer(opts *client.Container) error
- func (c *Cluster) SetNetworkinNode(hostId, IpAddress, cartonId, email string) error
- func (c *Cluster) StartContainer(id string) error
- func (c *Cluster) StopContainer(id string) error
- func (c *Cluster) UnfilteredNodes() ([]Node, error)
- func (c *Cluster) Unregister(address string) error
- func (c *Cluster) UpdateNode(node Node) (Node, error)
- type Container
- type ContainerStorage
- type DefaultHealer
- type DockerClient
- type Gulp
- type Healer
- type HealingData
- type IPIndex
- type ImageStorage
- type MapStorage
- func (s *MapStorage) ExtendNodeLock(address string, timeout time.Duration) error
- func (s *MapStorage) LockNodeForHealing(address string, isFailure bool, timeout time.Duration) (bool, error)
- func (s *MapStorage) RemoveContainer(containerID string) error
- func (s *MapStorage) RemoveNode(addr string) error
- func (s *MapStorage) RetrieveContainer(containerID string) (string, error)
- func (s *MapStorage) RetrieveContainerByName(Name string) (string, error)
- func (s *MapStorage) RetrieveContainers() ([]Container, error)
- func (s *MapStorage) RetrieveNode(address string) (Node, error)
- func (s *MapStorage) RetrieveNodes() ([]Node, error)
- func (s *MapStorage) RetrieveNodesByMetadata(metadata map[string]string) ([]Node, error)
- func (s *MapStorage) StoreContainer(containerID, hostID string) error
- func (s *MapStorage) StoreContainerByName(containerID, Name string) error
- func (s *MapStorage) StoreNode(node Node) error
- func (s *MapStorage) UnlockNode(address string) error
- func (s *MapStorage) UpdateNode(node Node) error
- type Node
- type NodeList
- type NodeStorage
- type RancherNodeError
- type Storage
Constants ¶
const ( DOCKER_NETWORK = "/docker/networks" DOCKER_LOGS = "/docker/logs" HTTP = "http://" )
const ( RANCHER_REGISTRY = "registry" RANCHER_ZONE = "region" RANCHER_SERVER = "rancher" RANCHER_MEMSIZE = "mem" RANCHER_SWAPSIZE = "swap" RANCHER_CPUPERIOD = "cpuperiod" RANCHER_CPUQUOTA = "cpuquota" ADMIN_ID = "admin_id" ACCESSKEY = "access_key" SECRETKEY = "secret_key" BRIDGE_NAME = "name" BRIDGE_NETWORK = "network" BRIDGE_GATEWAY = "gateway" BRIDGE_CLUSTER = "cluster_id" )
const ( NodeStatusWaiting = "waiting" NodeStatusReady = "ready" NodeStatusRetry = "ready for retry" NodeStatusDisabled = "disabled" NodeStatusHealing = "healing" NodeCreationStatusCreated = "created" NodeCreationStatusError = "error" NodeCreationStatusPending = "pending" )
Variables ¶
Functions ¶
This section is empty.
Types ¶
type Cluster ¶
type Cluster struct { Healer Healer VNets map[string]string Region string // contains filtered or unexported fields }
Cluster is the basic type of the package. It manages internal nodes, and provide methods for interaction with those nodes, like CreateContainer, which creates a container in one node of the cluster.
func (*Cluster) CreateContainerSchedulerOpts ¶
func (c *Cluster) CreateContainerSchedulerOpts(opts client.Container) (string, *client.Container, error)
CreateContainer creates a container in the specified node. If no node is specified, it will create the container in a node selected by the scheduler.
It returns the container, or an error, in case of failures.
func (c *Cluster) CreateContainer(opts docker.CreateContainerOptions) (string, *docker.Container, error) { return c.CreateContainerSchedulerOpts(opts) }
Similar to CreateContainer but allows arbritary options to be passed to the scheduler.
func (*Cluster) GetContainerById ¶
func (*Cluster) NodesForMetadata ¶
func (*Cluster) RemoveContainer ¶
RemoveContainer removes a container from the cluster.
func (*Cluster) SetNetworkinNode ¶
func (*Cluster) StartContainer ¶
func (*Cluster) StopContainer ¶
func (*Cluster) UnfilteredNodes ¶
func (*Cluster) Unregister ¶
Unregister removes nodes from the cluster.
type ContainerStorage ¶
type ContainerStorage interface { StoreContainer(container, host string) error RetrieveContainer(container string) (host string, err error) RemoveContainer(container string) error RetrieveContainers() ([]Container, error) StoreContainerByName(container, host string) error RetrieveContainerByName(name string) (container string, err error) }
type DefaultHealer ¶
type DefaultHealer struct{}
func (DefaultHealer) HandleError ¶
func (DefaultHealer) HandleError(node *Node) time.Duration
type DockerClient ¶
type DockerClient struct { ContainerName string ContainerId string Bridge string IpAddr string Gateway string CartonId string AccountId string }
func (*DockerClient) LogsRequest ¶
func (d *DockerClient) LogsRequest(url string, port string) error
func (*DockerClient) NetworkRequest ¶
func (d *DockerClient) NetworkRequest(url, port string) error
type HealingData ¶
type IPIndex ¶
func (s *MapStorage) StoreImage(repo, id, host string) error { s.iMut.Lock() defer s.iMut.Unlock() if s.iMap == nil { s.iMap = make(map[string]*Image) } img, _ := s.iMap[repo] if img == nil { img = &Image{Repository: repo, History: []ImageHistory{}} s.iMap[repo] = img } hasId := false for _, entry := range img.History { if entry.ImageId == id && entry.Node == host { hasId = true break } } if !hasId { img.History = append(img.History, ImageHistory{Node: host, ImageId: id}) } img.LastNode = host img.LastId = id return nil }
func (s *MapStorage) RetrieveImage(repo string) (Image, error) { s.iMut.Lock() defer s.iMut.Unlock() image, ok := s.iMap[repo] if !ok { return Image{}, ErrNoSuchImage } if len(image.History) == 0 { return Image{}, ErrNoSuchImage } return *image, nil }
func (s *MapStorage) RemoveImage(repo, id, host string) error { s.iMut.Lock() defer s.iMut.Unlock() image, ok := s.iMap[repo] if !ok { return ErrNoSuchImage } newHistory := []ImageHistory{} for _, entry := range image.History { if entry.ImageId != id || entry.Node != host { newHistory = append(newHistory, entry) } } image.History = newHistory return nil }
func (s *MapStorage) RetrieveImages() ([]Image, error) { s.iMut.Lock() defer s.iMut.Unlock() images := make([]Image, 0, len(s.iMap)) for _, img := range s.iMap { images = append(images, *img) } return images, nil }
type ImageStorage ¶
type ImageStorage interface { }
type MapStorage ¶
type MapStorage struct {
// contains filtered or unexported fields
}
func (*MapStorage) ExtendNodeLock ¶
func (s *MapStorage) ExtendNodeLock(address string, timeout time.Duration) error
func (*MapStorage) LockNodeForHealing ¶
func (*MapStorage) RemoveContainer ¶
func (s *MapStorage) RemoveContainer(containerID string) error
func (*MapStorage) RemoveNode ¶
func (s *MapStorage) RemoveNode(addr string) error
func (*MapStorage) RetrieveContainer ¶
func (s *MapStorage) RetrieveContainer(containerID string) (string, error)
func (*MapStorage) RetrieveContainerByName ¶
func (s *MapStorage) RetrieveContainerByName(Name string) (string, error)
func (*MapStorage) RetrieveContainers ¶
func (s *MapStorage) RetrieveContainers() ([]Container, error)
func (*MapStorage) RetrieveNode ¶
func (s *MapStorage) RetrieveNode(address string) (Node, error)
func (*MapStorage) RetrieveNodes ¶
func (s *MapStorage) RetrieveNodes() ([]Node, error)
func (*MapStorage) RetrieveNodesByMetadata ¶
func (s *MapStorage) RetrieveNodesByMetadata(metadata map[string]string) ([]Node, error)
func (*MapStorage) StoreContainer ¶
func (s *MapStorage) StoreContainer(containerID, hostID string) error
func (*MapStorage) StoreContainerByName ¶
func (s *MapStorage) StoreContainerByName(containerID, Name string) error
func (*MapStorage) StoreNode ¶
func (s *MapStorage) StoreNode(node Node) error
func (*MapStorage) UnlockNode ¶
func (s *MapStorage) UnlockNode(address string) error
func (*MapStorage) UpdateNode ¶
func (s *MapStorage) UpdateNode(node Node) error
type Node ¶
type Node struct { Address string Healing HealingData Metadata map[string]string Bridges map[string]map[string]string CreationStatus string }
Node represents a host running Docker. Each node has an Address (in the form <scheme>://<host>:<port>/) and map with arbritary metadata.
func (*Node) CleanMetadata ¶
func (*Node) FailureCount ¶
func (*Node) HasSuccess ¶
func (Node) MarshalJSON ¶
func (*Node) ResetFailures ¶
func (n *Node) ResetFailures()
type NodeStorage ¶
type NodeStorage interface { StoreNode(node Node) error RetrieveNodesByMetadata(metadata map[string]string) ([]Node, error) RetrieveNodes() ([]Node, error) RetrieveNode(address string) (Node, error) UpdateNode(node Node) error RemoveNode(address string) error LockNodeForHealing(address string, isFailure bool, timeout time.Duration) (bool, error) ExtendNodeLock(address string, timeout time.Duration) error UnlockNode(address string) error }
type RancherNodeError ¶
type RancherNodeError struct {
// contains filtered or unexported fields
}
func (RancherNodeError) BaseError ¶
func (n RancherNodeError) BaseError() error
func (RancherNodeError) Error ¶
func (n RancherNodeError) Error() string
type Storage ¶
type Storage interface { ContainerStorage ImageStorage NodeStorage }