This repository was archived by the owner on Dec 19, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 391
Force delete support for ASGs #315
Open
acasas
wants to merge
2
commits into
Netflix:master
Choose a base branch
from
acasas:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 1 commit
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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]) | ||
|
Contributor
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) { | ||
|
Contributor
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 = { | ||
|
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.