-
Notifications
You must be signed in to change notification settings - Fork 402
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Force delete support for ASGs #315
base: master
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -37,6 +37,7 @@ import com.netflix.asgard.model.GroupedInstance | |
import com.netflix.asgard.model.InstancePriceType | ||
import com.netflix.asgard.model.SubnetTarget | ||
import com.netflix.asgard.model.Subnets | ||
import com.netflix.asgard.push.GroupDeleteOperation | ||
import com.netflix.grails.contextParam.ContextParam | ||
import grails.converters.JSON | ||
import grails.converters.XML | ||
|
@@ -57,6 +58,7 @@ class AutoScalingController { | |
def configService | ||
def instanceTypeService | ||
def mergedInstanceService | ||
def pushService | ||
def spotInstanceRequestService | ||
def stackService | ||
|
||
|
@@ -450,13 +452,15 @@ class AutoScalingController { | |
String name = params.name | ||
AutoScalingGroup group = awsAutoScalingService.getAutoScalingGroup(userContext, name) | ||
Boolean showGroupNext = false | ||
Boolean showTask = false | ||
if (!group) { | ||
flash.message = "Auto Scaling Group '${name}' not found." | ||
} else { | ||
if (group?.instances?.size() <= 0) { | ||
try { | ||
awsAutoScalingService.deleteAutoScalingGroup(userContext, name) | ||
flash.message = "AutoScaling Group '${name}' has been deleted." | ||
GroupDeleteOperation operation = pushService.startGroupDelete(userContext, group) | ||
showTask = true | ||
redirect(controller: 'task', action: 'show', params: [id: operation.taskId]) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Just return from the method after the redirect, so there's no need to check state and hold extra booleans to decide what to do later. |
||
} catch (Exception e) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This catch block no longer makes sense, since we're not calling Amazon synchronously anymore. |
||
flash.message = "Could not delete Auto Scaling Group: ${e}" | ||
showGroupNext = true | ||
|
@@ -467,7 +471,9 @@ class AutoScalingController { | |
showGroupNext = true | ||
} | ||
} | ||
showGroupNext ? redirect(action: 'show', params: [id: name]) : redirect(action: 'list') | ||
if (!showTask) { | ||
showGroupNext ? redirect(action: 'show', params: [id: name]) : redirect(action: 'list') | ||
} | ||
} | ||
|
||
def postpone = { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Keeping this check defeats the purpose of this change.