node

package
v0.0.0-...-88aa921 Latest Latest
Warning

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

Go to latest
Published: Feb 20, 2015 License: Apache-2.0 Imports: 45 Imported by: 0

Documentation

Overview

Package serviced - agent implements a service that runs on a serviced node. It is responsible for ensuring that a particular node is running the correct services and reporting the state and health of those services back to the master serviced.

This file implements the LoadBalancer interface aspect of the host agent.

Serviced is a PaaS runtime based on docker. The serviced package exposes the interfaces for the key parts of this runtime.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddToEtcHosts

func AddToEtcHosts(host, ip string) error

In the container

func CreateDirectory

func CreateDirectory(path, username string, perm os.FileMode) error

CreateDirectory creates a directory using the given username as the owner and the given perm as the directory permission.

func ExecPath

func ExecPath() (string, string, error)

ExecPath returns the path to the currently running executable.

func GetInterfaceIPAddress

func GetInterfaceIPAddress(_interface string) (string, error)

GetInterfaceIPAddress attempts to find the IP address based on interface name

func NewReverseProxy

func NewReverseProxy(path string, targeturl *url.URL) *httputil.ReverseProxy

NewReverseProxy differs from httputil.NewSingleHostReverseProxy in that it rewrites the path so that it does /not/ include the incoming path. e.g. request for "/mysvc/thing" when proxy is served from "/mysvc" means target is targeturl.Path + "/thing"; vs. httputil.NewSingleHostReverseProxy, in which it would be targeturl.Path + "/mysvc/thing".

Types

type AgentClient

type AgentClient struct {
	// contains filtered or unexported fields
}

AgentClient is an interface that the serviced agent implements to provide information about the host it is running on.

func NewAgentClient

func NewAgentClient(addr string) (s *AgentClient, err error)

Create a new AgentClient.

type AgentOptions

type AgentOptions struct {
	PoolID               string
	Master               string
	UIPort               string
	DockerDNS            []string
	VarPath              string
	Mount                []string
	FSType               string
	Zookeepers           []string
	Mux                  *proxy.TCPMux
	UseTLS               bool
	DockerRegistry       string
	MaxContainerAge      time.Duration // Maximum container age for a stopped container before being removed
	VirtualAddressSubnet string
}

type ApplicationType

type ApplicationType string

A user defined string that describes an exposed application endpoint.

type ContainerState

type ContainerState struct {
	ID      string
	Created time.Time
	Path    string
	Args    []string
	Config  struct {
		Hostname        string
		User            string
		Memory          uint64
		MemorySwap      uint64
		CpuShares       int
		AttachStdin     bool
		AttachStdout    bool
		AttachStderr    bool
		PortSpecs       []string
		Tty             bool
		OpenStdin       bool
		StdinOnce       bool
		Env             []string
		Cmd             []string
		Dns             []string
		Image           string
		Volumes         map[string]struct{}
		VolumesFrom     string
		WorkingDir      string
		Entrypoint      []string
		NetworkDisabled bool
		Privileged      bool
	}
	State struct {
		Running   bool
		Pid       int
		ExitCode  int
		StartedAt string
		Ghost     bool
	}
	Image           string
	NetworkSettings struct {
		IPAddress   string
		IPPrefixLen int
		Gateway     string
		Bridge      string
		PortMapping map[string]map[string]string
		Ports       map[string][]domain.HostIPAndPort
	}
	SysInitPath    string
	ResolvConfPath string
	Volumes        map[string]string
	VolumesRW      map[string]bool
}

The state of a container as reported by Docker.

type ControlClient

type ControlClient struct {
	// contains filtered or unexported fields
}

A serviced client.

func NewControlClient

func NewControlClient(addr string) (s *ControlClient, err error)

Create a new ControlClient.

func (*ControlClient) Action

func (s *ControlClient) Action(req dao.AttachRequest, unused *int) error

func (*ControlClient) AddService

func (s *ControlClient) AddService(service service.Service, serviceId *string) (err error)

func (*ControlClient) AddServiceTemplate

func (s *ControlClient) AddServiceTemplate(serviceTemplate servicetemplate.ServiceTemplate, templateId *string) error

func (*ControlClient) AssignIPs

func (s *ControlClient) AssignIPs(assignmentRequest dao.AssignmentRequest, _ *struct{}) (err error)

func (*ControlClient) AsyncBackup

func (s *ControlClient) AsyncBackup(backupDirectory string, backupFilePath *string) error

func (*ControlClient) AsyncRestore

func (s *ControlClient) AsyncRestore(backupFilePath string, unused *int) error

func (*ControlClient) AsyncSnapshot

func (s *ControlClient) AsyncSnapshot(serviceId string, label *string) error

func (*ControlClient) Backup

func (s *ControlClient) Backup(backupDirectory string, backupFilePath *string) error

func (*ControlClient) BackupStatus

func (s *ControlClient) BackupStatus(notUsed int, backupStatus *string) error

func (*ControlClient) Close

func (s *ControlClient) Close() (err error)

Return the matching hosts.

func (*ControlClient) Commit

func (s *ControlClient) Commit(containerId string, label *string) error

func (*ControlClient) DeleteSnapshot

func (s *ControlClient) DeleteSnapshot(snapshotId string, unused *int) error

func (*ControlClient) DeleteSnapshots

func (s *ControlClient) DeleteSnapshots(serviceId string, unused *int) error

func (*ControlClient) DeployService

func (s *ControlClient) DeployService(service dao.ServiceDeploymentRequest, serviceId *string) (err error)

func (*ControlClient) DeployTemplate

func (s *ControlClient) DeployTemplate(request dao.ServiceTemplateDeploymentRequest, tenantIDs *[]string) error

func (*ControlClient) DeployTemplateActive

func (s *ControlClient) DeployTemplateActive(notUsed string, active *[]map[string]string) error

func (*ControlClient) DeployTemplateStatus

func (s *ControlClient) DeployTemplateStatus(request dao.ServiceTemplateDeploymentRequest, status *string) error

func (*ControlClient) FindChildService

func (s *ControlClient) FindChildService(request dao.FindChildRequest, service *service.Service) (err error)

func (*ControlClient) GetRunningService

func (s *ControlClient) GetRunningService(request dao.ServiceStateRequest, running *dao.RunningService) error

func (*ControlClient) GetRunningServices

func (s *ControlClient) GetRunningServices(request dao.EntityRequest, runningServices *[]dao.RunningService) (err error)

func (*ControlClient) GetRunningServicesForHost

func (s *ControlClient) GetRunningServicesForHost(hostId string, runningServices *[]dao.RunningService) (err error)

func (*ControlClient) GetRunningServicesForService

func (s *ControlClient) GetRunningServicesForService(serviceId string, runningServices *[]dao.RunningService) (err error)

func (*ControlClient) GetService

func (s *ControlClient) GetService(serviceId string, service *service.Service) (err error)

func (*ControlClient) GetServiceAddressAssignments

func (s *ControlClient) GetServiceAddressAssignments(serviceID string, addresses *[]addressassignment.AddressAssignment) (err error)

func (*ControlClient) GetServiceEndpoints

func (s *ControlClient) GetServiceEndpoints(serviceId string, response *map[string][]dao.ApplicationEndpoint) (err error)

func (*ControlClient) GetServiceLogs

func (s *ControlClient) GetServiceLogs(serviceId string, logs *string) error

func (*ControlClient) GetServiceState

func (s *ControlClient) GetServiceState(request dao.ServiceStateRequest, state *servicestate.ServiceState) error

func (*ControlClient) GetServiceStateLogs

func (s *ControlClient) GetServiceStateLogs(request dao.ServiceStateRequest, logs *string) error

func (*ControlClient) GetServiceStates

func (s *ControlClient) GetServiceStates(serviceId string, states *[]servicestate.ServiceState) (err error)

func (*ControlClient) GetServiceStatus

func (s *ControlClient) GetServiceStatus(serviceID string, statusmap *map[string]dao.ServiceStatus) (err error)

func (*ControlClient) GetServiceTemplates

func (s *ControlClient) GetServiceTemplates(unused int, serviceTemplates *map[string]servicetemplate.ServiceTemplate) error

func (*ControlClient) GetServices

func (s *ControlClient) GetServices(request dao.ServiceRequest, replyServices *[]service.Service) (err error)

func (*ControlClient) GetSystemUser

func (s *ControlClient) GetSystemUser(unused int, user *user.User) error

func (*ControlClient) GetTaggedServices

func (s *ControlClient) GetTaggedServices(request dao.ServiceRequest, replyServices *[]service.Service) (err error)

func (*ControlClient) GetTenantId

func (s *ControlClient) GetTenantId(serviceId string, tenantId *string) (err error)

func (*ControlClient) GetVolume

func (s *ControlClient) GetVolume(serviceID string, volume volume.Volume) error

func (*ControlClient) ImageLayerCount

func (s *ControlClient) ImageLayerCount(imageUUID string, layers *int) error

func (*ControlClient) ListBackups

func (s *ControlClient) ListBackups(backupDirectory string, backupFiles *[]dao.BackupFile) error

func (*ControlClient) ListSnapshots

func (s *ControlClient) ListSnapshots(serviceId string, snapshots *[]dao.SnapshotInfo) error

func (*ControlClient) LogHealthCheck

func (s *ControlClient) LogHealthCheck(result domain.HealthCheckResult, unused *int) error

func (*ControlClient) ReadyDFS

func (s *ControlClient) ReadyDFS(unused bool, unusedint *int) error

func (*ControlClient) RemoveService

func (s *ControlClient) RemoveService(serviceId string, unused *int) (err error)

func (*ControlClient) RemoveServiceTemplate

func (s *ControlClient) RemoveServiceTemplate(serviceTemplateID string, unused *int) error

func (*ControlClient) ResetRegistry

func (s *ControlClient) ResetRegistry(request dao.EntityRequest, unused *int) error

func (*ControlClient) RestartService

func (s *ControlClient) RestartService(request dao.ScheduleServiceRequest, affected *int) (err error)

func (*ControlClient) Restore

func (s *ControlClient) Restore(backupFilePath string, unused *int) error

func (*ControlClient) Rollback

func (s *ControlClient) Rollback(request dao.RollbackRequest, unused *int) error

func (*ControlClient) Snapshot

func (s *ControlClient) Snapshot(request dao.SnapshotRequest, label *string) error

func (*ControlClient) StartService

func (s *ControlClient) StartService(request dao.ScheduleServiceRequest, affected *int) (err error)

func (*ControlClient) StopRunningInstance

func (s *ControlClient) StopRunningInstance(request dao.HostServiceRequest, unused *int) (err error)

func (*ControlClient) StopService

func (s *ControlClient) StopService(request dao.ScheduleServiceRequest, affected *int) (err error)

func (*ControlClient) UpdateService

func (s *ControlClient) UpdateService(service service.Service, unused *int) (err error)

func (*ControlClient) UpdateServiceState

func (s *ControlClient) UpdateServiceState(state servicestate.ServiceState, unused *int) (err error)

func (*ControlClient) UpdateServiceTemplate

func (s *ControlClient) UpdateServiceTemplate(serviceTemplate servicetemplate.ServiceTemplate, unused *int) error

func (*ControlClient) ValidateCredentials

func (s *ControlClient) ValidateCredentials(user user.User, result *bool) error

func (*ControlClient) WaitService

func (s *ControlClient) WaitService(request dao.WaitServiceRequest, _ *struct{}) (err error)

type DockerVersion

type DockerVersion struct {
	Client []int
	Server []int
}

DockerVersion contains the tuples that describe the version of docker.

func GetDockerVersion

func GetDockerVersion() (DockerVersion, error)

GetDockerVersion returns docker version number.

type HealthCheckRequest

type HealthCheckRequest struct {
	ServiceID  string
	InstanceID int
}

type HostAgent

type HostAgent struct {
	// contains filtered or unexported fields
}

HostAgent is an instance of the control center Agent.

func NewHostAgent

func NewHostAgent(options AgentOptions) (*HostAgent, error)

NewHostAgent creates a new HostAgent given a connection string

func (*HostAgent) AckProxySnapshotQuiece

func (a *HostAgent) AckProxySnapshotQuiece(snapshotId string, unused *interface{}) error

AckProxySnapshotQuiece is called by clients when the snapshot command has shown the service is quieced; the agent returns a response when the snapshot is complete

func (*HostAgent) AttachAndRun

func (a *HostAgent) AttachAndRun(dockerID string, command []string) ([]byte, error)

AttachAndRun implements zkdocker.ActionHandler; it attaches to a running container and performs a command as specified by the container's service definition

func (*HostAgent) AttachService

func (a *HostAgent) AttachService(svc *service.Service, state *servicestate.ServiceState, exited func(string)) error

AttachService attempts to attach to a running container

func (*HostAgent) BindVirtualIP

func (a *HostAgent) BindVirtualIP(virtualIP *pool.VirtualIP, name string) error

BindVirtualIP implements virtualip.VirtualIPHandler

func (*HostAgent) GetHealthCheck

func (a *HostAgent) GetHealthCheck(req HealthCheckRequest, healthChecks *map[string]domain.HealthCheck) error

GetHealthCheck returns the health check configuration for a service, if it exists

func (*HostAgent) GetHostID

func (a *HostAgent) GetHostID(_ string, hostID *string) error

GetHostID returns the agent's host id

func (*HostAgent) GetProxySnapshotQuiece

func (a *HostAgent) GetProxySnapshotQuiece(serviceId string, snapshotId *string) error

GetProxySnapshotQuiece blocks until there is a snapshot request to the service

func (*HostAgent) GetService

func (a *HostAgent) GetService(serviceID string, response *service.Service) (err error)

func (*HostAgent) GetServiceBindMounts

func (a *HostAgent) GetServiceBindMounts(serviceID string, bindmounts *map[string]string) error

GetServiceBindMounts returns the service bindmounts

func (*HostAgent) GetServiceEndpoints

func (a *HostAgent) GetServiceEndpoints(serviceId string, response *map[string][]dao.ApplicationEndpoint) (err error)

func (*HostAgent) GetServiceInstance

func (a *HostAgent) GetServiceInstance(req ServiceInstanceRequest, response *service.Service) (err error)

func (*HostAgent) GetTenantId

func (a *HostAgent) GetTenantId(serviceId string, tenantId *string) error

Call the master's to retrieve its tenant id

func (*HostAgent) GetZkInfo

func (a *HostAgent) GetZkInfo(_ string, zkInfo *ZkInfo) error

GetZkInfo returns the agent's zookeeper connection string and its poolID

func (*HostAgent) LogHealthCheck

func (a *HostAgent) LogHealthCheck(result domain.HealthCheckResult, unused *int) error

LogHealthCheck proxies RegisterHealthCheck.

func (*HostAgent) PauseService

func (a *HostAgent) PauseService(service *service.Service, state *servicestate.ServiceState) error

PauseService pauses a running service

func (*HostAgent) Ping

func (a *HostAgent) Ping(waitFor time.Duration, timestamp *time.Time) error

func (*HostAgent) ResumeService

func (a *HostAgent) ResumeService(service *service.Service, state *servicestate.ServiceState) error

ResumeService resumes a paused service

func (*HostAgent) SendLogMessage

func (a *HostAgent) SendLogMessage(serviceLogInfo ServiceLogInfo, _ *struct{}) (err error)

func (*HostAgent) Start

func (a *HostAgent) Start(shutdown <-chan interface{})

main loop of the HostAgent

func (*HostAgent) StartService

func (a *HostAgent) StartService(svc *service.Service, state *servicestate.ServiceState, exited func(string)) error

StartService starts a new instance of the specified service and updates the control center state accordingly.

func (*HostAgent) StopService

func (a *HostAgent) StopService(state *servicestate.ServiceState) error

StopService terminates a particular service instance (serviceState) on the localhost.

func (*HostAgent) UnbindVirtualIP

func (a *HostAgent) UnbindVirtualIP(virtualIP *pool.VirtualIP) error

func (*HostAgent) VirtualInterfaceMap

func (a *HostAgent) VirtualInterfaceMap(prefix string) (map[string]*pool.VirtualIP, error)

type LBClient

type LBClient struct {
	// contains filtered or unexported fields
}

A LBClient implementation.

func NewLBClient

func NewLBClient(addr string) (*LBClient, error)

Create a new AgentClient.

func (*LBClient) AckProxySnapshotQuiece

func (a *LBClient) AckProxySnapshotQuiece(snapshotId string, unused *interface{}) error

AckProxySnapshotQuiece is called by clients when the snapshot command has shown the service is quieced; the agent returns a response when the snapshot is complete

func (*LBClient) Close

func (a *LBClient) Close() error

func (*LBClient) GetHealthCheck

func (a *LBClient) GetHealthCheck(req HealthCheckRequest, healthChecks *map[string]domain.HealthCheck) error

GetHealthCheck returns the health check configuration for a service, if it exists

func (*LBClient) GetHostID

func (a *LBClient) GetHostID(hostID *string) error

GetHostID returns the agent's host id

func (*LBClient) GetProxySnapshotQuiece

func (a *LBClient) GetProxySnapshotQuiece(serviceId string, snapshotId *string) error

GetProxySnapshotQuiece blocks until there is a snapshot request to the service

func (*LBClient) GetService

func (a *LBClient) GetService(serviceId string, service *service.Service) error

GetService returns a service for the given service id request.

func (*LBClient) GetServiceBindMounts

func (a *LBClient) GetServiceBindMounts(serviceID string, bindmounts *map[string]string) error

GetServiceBindMounts returns the service

func (*LBClient) GetServiceEndpoints

func (a *LBClient) GetServiceEndpoints(serviceId string, endpoints *map[string][]dao.ApplicationEndpoint) error

GetServiceEndpoints returns a list of endpoints for the given service endpoint request.

func (*LBClient) GetServiceInstance

func (a *LBClient) GetServiceInstance(req ServiceInstanceRequest, service *service.Service) error

GetServiceInstance returns a service for the given service id request.

func (*LBClient) GetTenantId

func (a *LBClient) GetTenantId(serviceId string, tenantId *string) error

GetTenantId return's the service's tenant id

func (*LBClient) GetZkInfo

func (a *LBClient) GetZkInfo(zkInfo *ZkInfo) error

GetZkInfo returns the agent's zookeeper connection string

func (*LBClient) LogHealthCheck

func (a *LBClient) LogHealthCheck(result domain.HealthCheckResult, unused *int) error

LogHealthCheck stores a health check result.

func (*LBClient) Ping

func (a *LBClient) Ping(waitFor time.Duration, timestamp *time.Time) error

Ping waits for the specified time then returns the server time

func (*LBClient) SendLogMessage

func (a *LBClient) SendLogMessage(serviceLogInfo ServiceLogInfo, _ *struct{}) error

SendLogMessage simply outputs the ServiceLogInfo on the serviced master

type LoadBalancer

type LoadBalancer interface {
	// SendLogMessage allows the proxy to send messages/logs to the master (to be displayed on the serviced master)
	SendLogMessage(serviceLogInfo ServiceLogInfo, _ *struct{}) error

	GetServiceEndpoints(serviceId string, endpoints *map[string][]dao.ApplicationEndpoint) error

	// GetProxySnapshotQuiece blocks until there is a snapshot request
	GetProxySnapshotQuiece(serviceId string, snapshotId *string) error

	// AckProxySnapshotQuiece is called by clients when the snapshot command has
	// shown the service is quieced; the agent returns a response when the snapshot is complete
	AckProxySnapshotQuiece(snapshotId string, unused *interface{}) error

	// GetTenantId retrieves a service's tenant id
	GetTenantId(serviceId string, tenantId *string) error

	GetHealthCheck(req HealthCheckRequest, healthCheck *map[string]domain.HealthCheck) error

	LogHealthCheck(result domain.HealthCheckResult, unused *int) error

	// GetService retrieves a service object with templates evaluated.
	GetService(serviceId string, response *service.Service) error

	// GetServiceInstance retrieves a service object with templates evaluated using a
	// given instance ID.
	GetServiceInstance(req ServiceInstanceRequest, response *service.Service) error

	// Ping waits for the specified time then returns the server time
	Ping(waitFor time.Duration, timestamp *time.Time) error
}

The API for a service proxy.

type ProtocolType

type ProtocolType string

Network protocol type.

type ServiceInstanceRequest

type ServiceInstanceRequest struct {
	ServiceID  string
	InstanceID int
}

type ServiceLogInfo

type ServiceLogInfo struct {
	ServiceID string
	Message   string
}

type ZkInfo

type ZkInfo struct {
	ZkDSN  string
	PoolID string
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL