Documentation
¶
Index ¶
Constants ¶
const ( // The status of one service // ServiceStatusCreating: creating the required resources of the service, such as volumes. ServiceStatusCreating = "CREATING" // ServiceStatusInitializing: service resources are created, wait for the initialization. // at this state, the service containers are running. Some services require the special // initialization configurations, such as configuring the DB replicaset. Some services // does not require this step, such as Cassandra. The service creation script could simply // change the service status to ACTIVE. ServiceStatusInitializing = "INITIALIZING" // ServiceStatusActive: service initialized and ready to use. ServiceStatusActive = "ACTIVE" ServiceStatusDeleting = "DELETING" ServiceStatusDeleted = "DELETED" // The status of one task TaskStatusRunning = "RUNNING" TaskStatusStopped = "STOPPED" // Task types TaskTypeInit = "init" )
const ( Version = "0.7.1" ContainerPlatformECS = "ecs" ContainerPlatformSwarm = "swarm" OrgName = "cloudstax" SystemName = "firecamp" ContainerNamePrefix = OrgName + "/" + SystemName + "-" // VolumeDriverName is the name for docker volume driver. // Do NOT change the volume driver name. If this name is changed, // please update the volume driver plugin in scripts/builddocker.sh. // please also update docker/volume/aws-ecs-agent-patch/firecamp_task_engine.go, // Has the separate definition in firecamp_task_engine.go aims to avoid the dependency of // ecs-agent on firecamp code. VolumeDriverName = OrgName + "/" + SystemName + "-" + "volume" // LogDriverName is the name for docker log driver. // Do NOT change the log driver name. If this name is changed, // please update the log driver plugin in scripts/builddocker.sh. LogDriverName = OrgName + "/" + SystemName + "-" + "log" LOGDRIVER_DEFAULT = "json-file" LOGDRIVER_AWSLOGS = "awslogs" DefaultLogDir = "/var/log/" + SystemName NameSeparator = "-" ServiceMemberDomainNameTTLSeconds = 5 // A ECS container instance has 1,024 cpu units for every CPU core DefaultMaxCPUUnits = -1 DefaultReserveCPUUnits = 256 DefaultMaxMemoryMB = -1 DefaultReserveMemoryMB = 256 DefaultServiceWaitSeconds = 120 DefaultTaskWaitSeconds = 120 DefaultTaskRetryCounts = 5 DefaultRetryWaitSeconds = 3 DomainSeparator = "." DomainNameSuffix = SystemName DomainCom = "com" ContainerNameSuffix = "container" DefaultContainerMountPath = "/data" DefaultConfigDir = "/conf" DefaultConfigPath = DefaultContainerMountPath + DefaultConfigDir DefaultConfigFileMode = 0600 DBTypeControlDB = "controldb" // the controldb service DBTypeCloudDB = "clouddb" // such as AWS DynamoDB ControlDBServerPort = 27030 ControlDBName = "controldb" ControlDBServiceName = SystemName + NameSeparator + ControlDBName ControlDBDefaultDir = DefaultContainerMountPath + "/" + ControlDBName // ControlDBUUIDPrefix defines the prefix of the controldb server id. // The service uuid of the controldb service would be ControlDBUUIDPrefix + volumeID. // The volumeID is the ID of the volume created for the controldb service. ControlDBUUIDPrefix = ControlDBName + NameSeparator ControlDBContainerImage = OrgName + "/" + ControlDBServiceName + ":" + Version ControlDBReserveCPUUnits = 256 ControlDBMaxMemMB = 4096 ControlDBReserveMemMB = 256 ControlDBVolumeSizeGB = int64(4) ManageHTTPServerPort = 27040 ManageName = "manageserver" ManageServiceName = SystemName + NameSeparator + ManageName ManageContainerImage = OrgName + "/" + ManageServiceName + ":" + Version ManageReserveCPUUnits = 256 ManageMaxMemMB = 4096 ManageReserveMemMB = 256 )
const ( // this is for passing the firecamp version to AWS ECS task definition. // the ECS agent patch will construct the correct volume plugin name with it. ENV_VERSION = "VERSION" ENV_VALUE_SEPARATOR = "," ENV_REGION = "REGION" ENV_CLUSTER = "CLUSTER" ENV_MANAGE_SERVER_URL = "MANAGE_SERVER_URL" ENV_OP = "OP" ENV_SERVICE_NAME = "SERVICE_NAME" ENV_SERVICE_NODE = "SERVICE_NODE" ENV_SERVICE_PORT = "SERVICE_PORT" ENV_SERVICE_MASTER = "SERVICE_MASTER" ENV_SERVICE_MEMBERS = "SERVICE_MEMBERS" ENV_SERVICE_TYPE = "SERVICE_TYPE" ENV_CONTAINER_PLATFORM = "CONTAINER_PLATFORM" ENV_DB_TYPE = "DB_TYPE" ENV_AVAILABILITY_ZONES = "AVAILABILITY_ZONES" )
define the common environment keys
Variables ¶
var ( ErrInternal = errors.New("InternalError") ErrTimeout = errors.New("Timeout") ErrSystemCreating = errors.New("System tables are at the creating status, please retry later") ErrServiceExist = errors.New("Service exists") ErrServiceDeleting = errors.New("Service deleting") ErrServiceDeleted = errors.New("Service deleted") ErrConfigMismatch = errors.New("Config mismatch") ErrInvalidArgs = errors.New("InvalidArgs") ErrUnsupportedPlatform = errors.New("Not supported container platform") ErrNotFound = errors.New("NotFound") ErrConditionalCheckFailed = errors.New("ConditionalCheckFailed") )
Functions ¶
This section is empty.
Types ¶
type ConfigFile ¶
type ConfigFile struct {
ServiceUUID string // partition key
FileID string // sort key
FileMD5 string
FileName string
FileMode uint32
LastModified int64
Content string // The content of the config file.
}
ConfigFile represents the detail config content of service member. To update the ConfigFile content of one replica, 2 steps are required: 1) create a new ConfigFile with a new FileID, 2) update ServiceMember MemberConfig to point to the new ConfigFile. We could not directly update the old ConfigFile. If node crashes before step2, ServiceMember MemberConfig will not be consistent with ConfigFile.
type Device ¶
type Device struct {
ClusterName string // partition key
DeviceName string // sort key
// service that the device is assigned to
ServiceName string
}
Device records the assigned device for the service. The DeviceName has to be part of the key, to ensure one device is only assigned to one service.
type EnvKeyValuePair ¶
type MemberConfig ¶
type MemberConfig struct {
FileName string
// The config file uuid
FileID string
// The MD5 checksum of the config file content.
// The config file content would usually not be updated. The checksum could help
// the volume driver easily know whether it needs to load the config file content.
// The config file content may not be small, such as a few hundreds KB.
FileMD5 string
}
MemberConfig represents the configs of one member
type PortMapping ¶
PortMapping defines the container port to host port mapping.
type Resources ¶
type Resources struct {
// The number of cpu units for the container.
// A container instance has 1,024 cpu units for every CPU core.
// MaxCPUUnits specifies how much of the available CPU resources a container can use.
// This will set docker's --cpu-period and --cpu-quota.
// ReserveCPUUnits is docker's --cpu-share, same with the ECS cpu units.
// The value could be -1, which means no limit on the resource.
MaxCPUUnits int64
ReserveCPUUnits int64
MaxMemMB int64
ReserveMemMB int64
}
Resources represents the service/task resources, cpu and memory.
type Service ¶
type Service struct {
ClusterName string // partition key
ServiceName string // sort key
ServiceUUID string
}
Service records the assigned uuid for the service.
type ServiceAttr ¶
type ServiceAttr struct {
ServiceUUID string // partition key
ServiceStatus string
LastModified int64
Replicas int64
VolumeSizeGB int64
ClusterName string
ServiceName string
DeviceName string
// whether the service members need to know each other, such as database replicas.
// if yes, the member will be registered to DNS. in aws, DNS will be Route53.
RegisterDNS bool
// for v1, DomainName would be the default domain, such as cluster-firecamp.com
DomainName string
// The AWS Route53 HostedZone for the current firecamp cluster.
HostedZoneID string
}
ServiceAttr represents the detail attributes of the service. The ServiceUUID is passed as volume name to the volume driver. The volume driver could get the detail service attributes for other operations.
type ServiceMember ¶
type ServiceMember struct {
ServiceUUID string // partition key
MemberName string // sort key
AvailableZone string
TaskID string
ContainerInstanceID string
ServerInstanceID string
LastModified int64
// TODO add a new struct to include VolumeID, DeviceName and Configs,
// as one service may have multiple volumes.
VolumeID string
DeviceName string
// One member could have multiple config files.
// For example, cassandra.yaml and rackdc properties files.
Configs []*MemberConfig
}
ServiceMember represents the attributes of one service member.
type ServiceStatus ¶
ServiceStatus represents the service's running status. TODO add more status. For example, the members are running on which nodes.