Skip to content
This repository has been archived by the owner on Oct 21, 2024. It is now read-only.

Commit

Permalink
Merge pull request #57 from AssemblyAI/mitch/fix-multi-service-deploy
Browse files Browse the repository at this point in the history
fix multi service rolling deploy logic
  • Loading branch information
chilledornaments authored Aug 31, 2021
2 parents 55b1125 + 4fd0276 commit e2fafbf
Showing 1 changed file with 21 additions and 18 deletions.
39 changes: 21 additions & 18 deletions cmd/plugin/rolling.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,31 +69,34 @@ func release(e types.ECSClient, service string, cluster string, maxDeployChecks
func rolling(e types.ECSClient, cluster string, container string, image string, maxDeployChecks int) error {
services := getServiceNames(os.Getenv("PLUGIN_SERVICE"))

for _, service := range services {
log.Printf("Starting deployment for service '%s'\n", service)
// Retrieve the task definition that the first service is using. The first service may be the only service
// In the event that len(services) > 1, we can reasonably assume that all services in the array use the same task definition
// That's the entire point of this feature
td, err := deploy.GetServiceRunningTaskDefinition(context.TODO(), e, services[0], cluster)

td, err := deploy.GetServiceRunningTaskDefinition(context.TODO(), e, service, cluster)
if err != nil {
log.Println("Failing because of an error determining the currently in-use task definition:", err.Error())
return errors.New("deploy failed")
}

if err != nil {
log.Println("Failing because of an error determining the currently in-use task definition")
return errors.New("deploy failed")
}
currTD, err := deploy.RetrieveTaskDefinition(context.TODO(), e, td)

currTD, err := deploy.RetrieveTaskDefinition(context.TODO(), e, td)
if err != nil {
log.Println("Failing because of an error retrieving the currently in-use task definition:", err.Error())
return errors.New("deploy failed")
}

if err != nil {
log.Println("Failing because of an error retrieving the currently in-use task definition")
return errors.New("deploy failed")
}
newTD, err := deploy.CreateNewTaskDefinitionRevision(context.TODO(), e, currTD, container, image)

newTD, err := deploy.CreateNewTaskDefinitionRevision(context.TODO(), e, currTD, container, image)
if err != nil {
log.Println("Failing because of an error retrieving the creating a new task definition revision:", err.Error())
return errors.New("deploy failed")
}

if err != nil {
log.Println("Failing because of an error retrieving the creating a new task definition revision")
return errors.New("deploy failed")
}
log.Println("Created new task definition revision", newTD.Revision)

log.Println("Created new task definition revision", newTD.Revision)
for _, service := range services {
log.Printf("Starting deployment for service '%s'\n", service)

deploymentOK, _ := release(e, service, cluster, maxDeployChecks, *newTD.TaskDefinitionArn)

Expand Down

0 comments on commit e2fafbf

Please sign in to comment.