-
Notifications
You must be signed in to change notification settings - Fork 703
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
feat(deploy): Scale down orca & rosco during deploys #593
Merged
Merged
Changes from all commits
Commits
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 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 |
---|---|---|
|
@@ -276,16 +276,45 @@ private <T extends Account> void reapRoscoServerGroups(AccountDeploymentDetails< | |
List<Integer> allRoscos = new ArrayList<>(executionsByServerGroupVersion.keySet()); | ||
allRoscos.sort(Integer::compareTo); | ||
|
||
int roscoCount = allRoscos.size(); | ||
if (roscoCount <= MAX_REMAINING_SERVER_GROUPS) { | ||
cleanupServerGroups(details, roscoService, roscoSettings, executionsByServerGroupVersion, allRoscos); | ||
} | ||
|
||
private <S, T extends Account> void cleanupServerGroups(AccountDeploymentDetails<T> details, | ||
DistributedService<S, T> service, | ||
ServiceSettings settings, | ||
Map<Integer, Integer> workloadByVersion, | ||
List<Integer> runningVersions) { | ||
int runningVersionCount = runningVersions.size(); | ||
|
||
if (runningVersionCount <= 1) { | ||
log.info("There are no extra services to cleanup. Running count = " + runningVersionCount); | ||
return; | ||
} | ||
|
||
allRoscos = allRoscos.subList(0, roscoCount - MAX_REMAINING_SERVER_GROUPS); | ||
for (Integer roscoVersion : allRoscos) { | ||
if (executionsByServerGroupVersion.get(roscoVersion) == 0) { | ||
DaemonTaskHandler.message("Reaping old rosco server group sequence " + roscoVersion); | ||
roscoService.deleteVersion(details, roscoSettings, roscoVersion); | ||
/* | ||
* To visualize the array slicing below, say we have 5 running | ||
* server groups, 3 of which we can destroy, one we can scale down, | ||
* and one that's actively serving traffic, as illustrated here: | ||
* | ||
* | ||
* | running - MAX_REMAINING | MAX_REMAINING | | ||
* | No longer in use | backup | active | | ||
* server groups: | v001 | v002 | v003 | v004 | v005 | | ||
*/ | ||
List<Integer> killableVersions = runningVersions.subList(0, runningVersionCount - MAX_REMAINING_SERVER_GROUPS); | ||
List<Integer> shrinkableVersions = runningVersions.subList(runningVersionCount - MAX_REMAINING_SERVER_GROUPS, runningVersionCount - 1); | ||
|
||
for (Integer version : killableVersions) { | ||
if (workloadByVersion.get(version) == 0) { | ||
DaemonTaskHandler.message("Reaping old server group sequence " + version); | ||
service.deleteVersion(details, settings, version); | ||
} | ||
} | ||
|
||
for (Integer version : shrinkableVersions) { | ||
if (workloadByVersion.get(version) == 0) { | ||
DaemonTaskHandler.message("Shrinking old server group sequence " + version); | ||
service.resizeVersion(details, settings, version, 0); | ||
} | ||
} | ||
} | ||
|
@@ -318,18 +347,6 @@ private <T extends Account> void reapOrcaServerGroups(AccountDeploymentDetails<T | |
List<Integer> allOrcas = new ArrayList<>(executionsByServerGroupVersion.keySet()); | ||
allOrcas.sort(Integer::compareTo); | ||
|
||
int orcaCount = allOrcas.size(); | ||
if (orcaCount <= MAX_REMAINING_SERVER_GROUPS) { | ||
return; | ||
} | ||
|
||
allOrcas = allOrcas.subList(0, orcaCount - MAX_REMAINING_SERVER_GROUPS); | ||
for (Integer orcaVersion : allOrcas) { | ||
// TODO(lwander) consult clouddriver to ensure this orca isn't enabled | ||
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. TODO was dropped because the orca versions outside of MAX_REMAINING_SERVER_GROUPS cannot be enabled, since the rollback operation requested by halyard ensures the highest sequence number is always the only one serving traffic. |
||
if (executionsByServerGroupVersion.get(orcaVersion) == 0) { | ||
DaemonTaskHandler.message("Reaping old orca instance " + orcaVersion); | ||
orcaService.deleteVersion(details, orcaSettings, orcaVersion); | ||
} | ||
} | ||
cleanupServerGroups(details, orcaService, orcaSettings, executionsByServerGroupVersion, allOrcas); | ||
} | ||
} |
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
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.
This is not the usual case, correct? Maybe add logging here so you avoid possibly silently failing.
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.
This happens on every fresh deploy - you'll only have one of each service. I'll add a log statement but it's expected to be hit
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.
Got it, still maybe worth it.
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.
Agreed & logged