Use distinct family per service definition

Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
This commit is contained in:
Nicolas De Loof 2020-06-02 14:17:48 +02:00
parent 7d4222a725
commit 1bf4bc9d46
No known key found for this signature in database
GPG Key ID: 9858809D6F8F6E7E
5 changed files with 13 additions and 9 deletions

View File

@ -77,7 +77,7 @@ func Convert(project *compose.Project, service types.ServiceConfig) (*ecs.TaskDe
},
},
Cpu: cpu,
Family: project.Name,
Family: fmt.Sprintf("%s-%s", project.Name, service.Name),
IpcMode: service.Ipc,
Memory: mem,
NetworkMode: ecsapi.NetworkModeAwsvpc, // FIXME could be set by service.NetworkMode, Fargate only supports network mode awsvpc.

View File

@ -20,9 +20,13 @@ func (c *client) ComposePs(ctx context.Context, project *compose.Project) error
fmt.Fprintf(w, "Name\tState\tPorts\n")
defer w.Flush()
arns, err := c.api.ListTasks(ctx, cluster, project.Name)
if err != nil {
return err
arns := []string{}
for _, service := range project.Services {
tasks, err := c.api.ListTasks(ctx, cluster, service.Name)
if err != nil {
return err
}
arns = append(arns, tasks...)
}
if len(arns) == 0 {
return nil

View File

@ -341,10 +341,10 @@ func (s sdk) GetLogs(ctx context.Context, name string, consumer LogConsumer) err
}
}
func (s sdk) ListTasks(ctx context.Context, cluster string, name string) ([]string, error) {
func (s sdk) ListTasks(ctx context.Context, cluster string, service string) ([]string, error) {
tasks, err := s.ECS.ListTasksWithContext(ctx, &ecs.ListTasksInput{
Cluster: aws.String(cluster),
Family: aws.String(name),
Cluster: aws.String(cluster),
ServiceName: aws.String(service),
})
if err != nil {
return nil, err

View File

@ -181,7 +181,7 @@
"ExecutionRoleArn": {
"Ref": "SimpleTaskExecutionRole"
},
"Family": "TestSimpleConvert",
"Family": "TestSimpleConvert-simple",
"Memory": "512",
"NetworkMode": "awsvpc",
"RequiresCompatibilities": [

View File

@ -181,7 +181,7 @@
"ExecutionRoleArn": {
"Ref": "SimpleTaskExecutionRole"
},
"Family": "TestSimpleWithOverrides",
"Family": "TestSimpleWithOverrides-simple",
"Memory": "512",
"NetworkMode": "awsvpc",
"RequiresCompatibilities": [