ecsbackend

package
v0.0.0-test7 Latest Latest
Warning

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

Go to latest
Published: Sep 1, 2021 License: Apache-2.0 Imports: 32 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ClusterCapacityReason = "Waiting for cluster capacity to run"
	StopTaskReason        = "Task deleted by user"
)
View Source
const MAX_SERVICE_CREATE_RETRIES = 10
View Source
const MAX_TASK_IDS = 100

Variables

View Source
var CreateRenderedDockerrun = func(body []byte) (*models.Dockerrun, error) {
	dockerrun, err := MarshalDockerrun(body)
	if err != nil {
		return nil, err
	}

	for _, container := range dockerrun.ContainerDefinitions {
		if container.LogConfiguration == nil {
			container.LogConfiguration = &awsecs.LogConfiguration{
				LogDriver: stringp("awslogs"),
				Options: map[string]*string{
					"awslogs-group":         stringp(config.AWSLogGroupID()),
					"awslogs-region":        stringp(config.AWSRegion()),
					"awslogs-stream-prefix": stringp("l0"),
				},
			}
		}
	}

	return dockerrun, nil
}
View Source
var GetLogs = func(cloudWatchLogs cloudwatchlogs.Provider, taskARNs []*string, start, end string, tail int) ([]*models.LogFile, error) {
	taskIDCatalog := generateTaskIDCatalog(taskARNs)

	orderBy := "LastEventTime"
	logStreams, err := cloudWatchLogs.DescribeLogStreams(config.AWSLogGroupID(), orderBy)
	if err != nil {
		return nil, err
	}

	logFiles := []*models.LogFile{}
	for _, logStream := range logStreams {

		streamNameSplit := strings.Split(*logStream.LogStreamName, "/")
		if len(streamNameSplit) != 3 {
			continue
		}

		streamTaskID := streamNameSplit[2]
		if _, ok := taskIDCatalog[streamTaskID]; !ok {
			continue
		}

		logFile := &models.LogFile{
			Name:  streamNameSplit[1],
			Lines: []string{},
		}

		logEvents, err := cloudWatchLogs.GetLogEvents(
			config.AWSLogGroupID(),
			*logStream.LogStreamName,
			start,
			end,
			int64(tail))
		if err != nil {
			return nil, err
		}

		for _, logEvent := range logEvents {
			logFile.Lines = append(logFile.Lines, *logEvent.Message)
		}

		logFiles = append(logFiles, logFile)
	}

	return logFiles, nil
}

Functions

func ContainsErrCode

func ContainsErrCode(err error, code string) bool

func ContainsErrMsg

func ContainsErrMsg(err error, msg string) bool

func IteratePages

func IteratePages(fn paginatedf) error

func MarshalDockerrun added in v0.10.3

func MarshalDockerrun(body []byte) (*models.Dockerrun, error)

Types

type ECSBackend

todo: this is an awkward design pattern - we don't need to split the ECSBackend object into many parts with self-references to 'this.Backend' we should just make the backend one single object with many functions

func NewBackend

func NewBackend(
	tagData tag_store.TagStore,
	s3 s3.Provider,
	iam iam.Provider,
	ec2 ec2.Provider,
	ecs ecs.Provider,
	elb elb.Provider,
	autoscaling autoscaling.Provider,
	cloudWatchLogs cloudwatchlogs.Provider,
) *ECSBackend

type ECSDeployManager

type ECSDeployManager struct {
	ECS ecs.Provider
}

func NewECSDeployManager

func NewECSDeployManager(ecsprovider ecs.Provider) *ECSDeployManager

func (*ECSDeployManager) CreateDeploy

func (this *ECSDeployManager) CreateDeploy(deployName string, body []byte) (*models.Deploy, error)

func (*ECSDeployManager) DeleteDeploy

func (this *ECSDeployManager) DeleteDeploy(deployID string) error

func (*ECSDeployManager) GetDeploy

func (this *ECSDeployManager) GetDeploy(deployID string) (*models.Deploy, error)

func (*ECSDeployManager) ListDeploys

func (this *ECSDeployManager) ListDeploys() ([]*models.Deploy, error)

type ECSEnvironmentManager

type ECSEnvironmentManager struct {
	ECS         ecs.Provider
	EC2         ec2.Provider
	AutoScaling autoscaling.Provider
	Backend     backend.Backend
	Clock       waitutils.Clock
}

func NewECSEnvironmentManager

func NewECSEnvironmentManager(
	ecsprovider ecs.Provider,
	ec2 ec2.Provider,
	asg autoscaling.Provider,
	backend backend.Backend) *ECSEnvironmentManager

func (*ECSEnvironmentManager) CreateEnvironment

func (e *ECSEnvironmentManager) CreateEnvironment(
	environmentName string,
	instanceSize string,
	operatingSystem string,
	amiID string,
	minClusterCount int,
	userDataTemplate []byte,
) (*models.Environment, error)
func (e *ECSEnvironmentManager) CreateEnvironmentLink(sourceEnvironmentID, destEnvironmentID string) error

func (*ECSEnvironmentManager) DeleteEnvironment

func (e *ECSEnvironmentManager) DeleteEnvironment(environmentID string) error
func (e *ECSEnvironmentManager) DeleteEnvironmentLink(sourceEnvironmentID, destEnvironmentID string) error

func (*ECSEnvironmentManager) GetEnvironment

func (e *ECSEnvironmentManager) GetEnvironment(environmentID string) (*models.Environment, error)

func (*ECSEnvironmentManager) ListEnvironments

func (e *ECSEnvironmentManager) ListEnvironments() ([]id.ECSEnvironmentID, error)

func (*ECSEnvironmentManager) UpdateEnvironment

func (e *ECSEnvironmentManager) UpdateEnvironment(environmentID string, minClusterCount int) (*models.Environment, error)

type ECSLoadBalancerManager

type ECSLoadBalancerManager struct {
	EC2     ec2.Provider
	ELB     elb.Provider
	IAM     iam.Provider
	Backend backend.Backend
	Clock   waitutils.Clock
}

func NewECSLoadBalancerManager

func NewECSLoadBalancerManager(ec2 ec2.Provider, elb elb.Provider, iam iam.Provider, backend backend.Backend) *ECSLoadBalancerManager

func (*ECSLoadBalancerManager) CreateLoadBalancer

func (e *ECSLoadBalancerManager) CreateLoadBalancer(
	loadBalancerName,
	environmentID string,
	isPublic bool,
	ports []models.Port,
	healthCheck models.HealthCheck,
	idleTimeout int,
	crossZone bool,
) (*models.LoadBalancer, error)

func (*ECSLoadBalancerManager) DeleteLoadBalancer

func (e *ECSLoadBalancerManager) DeleteLoadBalancer(loadBalancerID string) error

func (*ECSLoadBalancerManager) GetLoadBalancer

func (e *ECSLoadBalancerManager) GetLoadBalancer(loadBalancerID string) (*models.LoadBalancer, error)

func (*ECSLoadBalancerManager) ListLoadBalancers

func (e *ECSLoadBalancerManager) ListLoadBalancers() ([]*models.LoadBalancer, error)

func (*ECSLoadBalancerManager) UpdateLoadBalancerCrossZone added in v0.11.0

func (e *ECSLoadBalancerManager) UpdateLoadBalancerCrossZone(loadBalancerID string, crossZone bool) (*models.LoadBalancer, error)

func (*ECSLoadBalancerManager) UpdateLoadBalancerHealthCheck

func (e *ECSLoadBalancerManager) UpdateLoadBalancerHealthCheck(loadBalancerID string, healthCheck models.HealthCheck) (*models.LoadBalancer, error)

func (*ECSLoadBalancerManager) UpdateLoadBalancerIdleTimeout added in v0.10.7

func (e *ECSLoadBalancerManager) UpdateLoadBalancerIdleTimeout(loadBalancerID string, idleTimeout int) (*models.LoadBalancer, error)

func (*ECSLoadBalancerManager) UpdateLoadBalancerPorts

func (e *ECSLoadBalancerManager) UpdateLoadBalancerPorts(loadBalancerID string, ports []models.Port) (*models.LoadBalancer, error)

type ECSResourceManager

type ECSResourceManager struct {
	ECS         ecs.Provider
	Autoscaling autoscaling.Provider
	// contains filtered or unexported fields
}

func (*ECSResourceManager) CalculateNewProvider

func (r *ECSResourceManager) CalculateNewProvider(environmentID string) (*resource.ResourceProvider, error)

func (*ECSResourceManager) GetProviders

func (r *ECSResourceManager) GetProviders(environmentID string) ([]*resource.ResourceProvider, error)

func (*ECSResourceManager) ScaleTo

func (r *ECSResourceManager) ScaleTo(environmentID string, scale int, unusedProviders []*resource.ResourceProvider) (int, error)

type ECSServiceManager

type ECSServiceManager struct {
	ECS            ecs.Provider
	EC2            ec2.Provider
	CloudWatchLogs cloudwatchlogs.Provider
	Backend        backend.Backend
	Clock          waitutils.Clock
}

func NewECSServiceManager

func NewECSServiceManager(
	ecsProvider ecs.Provider,
	ec2Provider ec2.Provider,
	cloudWatchLogsProvider cloudwatchlogs.Provider,
	backend backend.Backend,
) *ECSServiceManager

func (*ECSServiceManager) CreateService

func (this *ECSServiceManager) CreateService(
	serviceName,
	environmentID,
	deployID,
	loadBalancerID string,
) (*models.Service, error)

func (*ECSServiceManager) DeleteService

func (this *ECSServiceManager) DeleteService(environmentID, serviceID string) error

func (*ECSServiceManager) GetEnvironmentServices added in v0.10.4

func (this *ECSServiceManager) GetEnvironmentServices(environmentID string) ([]*models.Service, error)

func (*ECSServiceManager) GetService

func (this *ECSServiceManager) GetService(environmentID, serviceID string) (*models.Service, error)

func (*ECSServiceManager) GetServiceLogs

func (this *ECSServiceManager) GetServiceLogs(environmentID, serviceID, start, end string, tail int) ([]*models.LogFile, error)

func (*ECSServiceManager) ListServices

func (this *ECSServiceManager) ListServices() ([]id.ECSServiceID, error)

func (*ECSServiceManager) ScaleService

func (this *ECSServiceManager) ScaleService(environmentID string, serviceID string, count int) (*models.Service, error)

func (*ECSServiceManager) UpdateService

func (this *ECSServiceManager) UpdateService(
	environmentID string,
	serviceID string,
	deployID string,
) (*models.Service, error)

type ECSTaskManager

type ECSTaskManager struct {
	ECS            ecs.Provider
	CloudWatchLogs cloudwatchlogs.Provider
	Backend        backend.Backend
}

func NewECSTaskManager

func NewECSTaskManager(
	ecsProvider ecs.Provider,
	cloudWatchLogsProvider cloudwatchlogs.Provider,
	backend backend.Backend,
) *ECSTaskManager

func (*ECSTaskManager) CreateTask

func (this *ECSTaskManager) CreateTask(
	environmentID string,
	deployID string,
	overrides []models.ContainerOverride,
) (string, error)

func (*ECSTaskManager) DeleteTask

func (this *ECSTaskManager) DeleteTask(environmentID, taskARN string) error

func (*ECSTaskManager) GetEnvironmentTasks added in v0.10.4

func (this *ECSTaskManager) GetEnvironmentTasks(environmentID string) (map[string]*models.Task, error)

func (*ECSTaskManager) GetTask

func (this *ECSTaskManager) GetTask(environmentID, taskARN string) (*models.Task, error)

func (*ECSTaskManager) GetTaskLogs

func (this *ECSTaskManager) GetTaskLogs(environmentID, taskARN, start, end string, tail int) ([]*models.LogFile, error)

func (*ECSTaskManager) ListTasks

func (this *ECSTaskManager) ListTasks() ([]string, error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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