Skip to content

Commit

Permalink
Fixed generic resource override
Browse files Browse the repository at this point in the history
  • Loading branch information
dmtgrinevich committed Oct 7, 2024
1 parent 681ace4 commit fe11ed4
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 16 deletions.
24 changes: 13 additions & 11 deletions environment/environment.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,24 +36,26 @@ func (env *ExecutionEnvironment) ContainerOverrides() []*ecs.ContainerOverride {
cpu := container.Cpu()
memory := container.Memory()
override := ecs.ContainerOverride{
Name: &container.Name,
Cpu: &cpu,
Memory: &memory,
Command: aws.StringSlice(container.Command),
Name: &container.Name,
Cpu: &cpu,
Memory: &memory,
}

if strings.ToLower(env.Capabilities.PlatformName.ToPrimitive()) != envtype.WINDOWS.String() {
override.MemoryReservation = &memory
}

env := []*ecs.KeyValuePair{}
for k, v := range container.Env {
// need to declare local variables to provide as pointer later
key := k
value := v
env = append(env, &ecs.KeyValuePair{Name: &key, Value: &value})
if env.Type != envtype.GENERIC {
override.Command = aws.StringSlice(container.Command)
env := []*ecs.KeyValuePair{}
for k, v := range container.Env {
// need to declare local variables to provide as pointer later
key := k
value := v
env = append(env, &ecs.KeyValuePair{Name: &key, Value: &value})
}
override.Environment = env
}
override.Environment = env

overrides = append(overrides, &override)
}
Expand Down
6 changes: 1 addition & 5 deletions starter/taskRegistrar.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import (
"github.com/zebrunner/esg/cachemaps/resourcesToAllocate"
"github.com/zebrunner/esg/config"
"github.com/zebrunner/esg/environment"
envtype "github.com/zebrunner/esg/environment/envType"
"github.com/zebrunner/esg/service"
"github.com/zebrunner/esg/utils"
)
Expand All @@ -39,6 +38,7 @@ func registerTask(ctx context.Context, env *environment.ExecutionEnvironment, ro
runTaskInput := &ecs.RunTaskInput{
Cluster: &config.Conf.AwsCluster,
TaskDefinition: &family,
Overrides: &ecs.TaskOverride{ContainerOverrides: env.ContainerOverrides()},
PlacementStrategy: []*ecs.PlacementStrategy{
{
Field: aws.String("memory"),
Expand All @@ -48,10 +48,6 @@ func registerTask(ctx context.Context, env *environment.ExecutionEnvironment, ro
CapacityProviderStrategy: []*ecs.CapacityProviderStrategyItem{{CapacityProvider: &env.CapacityProvider}},
}

if env.Type != envtype.GENERIC {
runTaskInput.Overrides = &ecs.TaskOverride{ContainerOverrides: env.ContainerOverrides()}
}

l.WithField("runTaskInput", runTaskInput).Trace("Res runTaskInput")

// TODO: explicitly minimize errors range to wait only by well-known reasons aka RESOURCE:CPU etc
Expand Down

0 comments on commit fe11ed4

Please sign in to comment.