Skip to content

Commit

Permalink
Merge branch 'develop' into #939
Browse files Browse the repository at this point in the history
  • Loading branch information
dmtgrinevich committed Oct 5, 2023
2 parents b4ae35e + cad0cf2 commit 012fe2b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
6 changes: 5 additions & 1 deletion cachemaps/resourcesToAllocate/resourcesToAllocate.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"context"
"encoding/json"

"github.com/go-redis/redis/v8"
"github.com/zebrunner/esg/config"
)

Expand Down Expand Up @@ -37,10 +38,13 @@ func GetAllEntities() ([]*Resources, error) {
return nil, err
}

resources := make([]*Resources, len(keys))
resources := make([]*Resources, 0, len(keys))
for _, uuid := range keys {
data, err := config.ResourcesConnection.Get(context.Background(), uuid).Result()
if err != nil {
if err == redis.Nil {
continue
}
return nil, err
}

Expand Down
3 changes: 2 additions & 1 deletion service/taskRegistrar.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,10 @@ func registerTask(ctx context.Context, env environment.ExecutionEnvironment, wai
var resultRunTask *ecs.RunTaskOutput
resultRunTask, err := svc.RunTask(runTaskInput)
if err != nil {
l.WithError(err).Error("Task register failed.")
// Not good solution but aws doesn't give a choice
errStr := err.Error()
if errStr == "ClientException: TaskDefinition not found." {
l.WithError(err).Error("Task register failed.")
if markedToAllocate {
resourcesToAllocate.RemoveEntity(env.RouterUUID)
}
Expand All @@ -83,6 +83,7 @@ func registerTask(ctx context.Context, env environment.ExecutionEnvironment, wai
}

if errStr == "ClientException: Tasks provisioning capacity limit exceeded." || strings.Contains(errStr, "ThrottlingException: Rate exceeded") {
l.WithError(err).Trace("Task register failed.")
if !markedToAllocate {
resources := env.CalculateResources()
err := resourcesToAllocate.AddEntity(resources)
Expand Down

0 comments on commit 012fe2b

Please sign in to comment.