-
Notifications
You must be signed in to change notification settings - Fork 186
Better exposure of LB status in UI #2071
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
Changes from all commits
11d9475
7f6d885
8d7ab16
b568602
48852d5
46eec76
41e478b
e696de8
9ae61f5
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 |
|---|---|---|
|
|
@@ -9,9 +9,6 @@ | |
| import java.util.concurrent.CompletableFuture; | ||
| import java.util.stream.Collectors; | ||
|
|
||
| import org.slf4j.Logger; | ||
| import org.slf4j.LoggerFactory; | ||
|
|
||
| import com.google.inject.Inject; | ||
| import com.google.inject.Singleton; | ||
| import com.hubspot.mesos.JavaUtils; | ||
|
|
@@ -41,7 +38,6 @@ | |
| import com.hubspot.singularity.data.SingularityValidator; | ||
| import com.hubspot.singularity.data.TaskManager; | ||
| import com.hubspot.singularity.data.UserManager; | ||
| import com.hubspot.singularity.data.history.TaskHistoryHelper; | ||
| import com.hubspot.singularity.expiring.SingularityExpiringBounce; | ||
| import com.hubspot.singularity.expiring.SingularityExpiringPause; | ||
| import com.hubspot.singularity.expiring.SingularityExpiringScale; | ||
|
|
@@ -51,16 +47,13 @@ | |
|
|
||
| @Singleton | ||
| public class RequestHelper { | ||
| private static final Logger LOG = LoggerFactory.getLogger(RequestHelper.class); | ||
|
|
||
| private final RequestManager requestManager; | ||
| private final SingularityMailer mailer; | ||
| private final DeployManager deployManager; | ||
| private final SingularityValidator validator; | ||
| private final UserManager userManager; | ||
| private final TaskManager taskManager; | ||
| private final SingularityDeployHealthHelper deployHealthHelper; | ||
| private final TaskHistoryHelper taskHistoryHelper; | ||
|
|
||
| @Inject | ||
| public RequestHelper(RequestManager requestManager, | ||
|
|
@@ -69,16 +62,14 @@ public RequestHelper(RequestManager requestManager, | |
| SingularityValidator validator, | ||
| UserManager userManager, | ||
| TaskManager taskManager, | ||
| SingularityDeployHealthHelper deployHealthHelper, | ||
| TaskHistoryHelper taskHistoryHelper) { | ||
| SingularityDeployHealthHelper deployHealthHelper) { | ||
| this.requestManager = requestManager; | ||
| this.mailer = mailer; | ||
| this.deployManager = deployManager; | ||
| this.validator = validator; | ||
| this.userManager = userManager; | ||
| this.taskManager = taskManager; | ||
| this.deployHealthHelper = deployHealthHelper; | ||
| this.taskHistoryHelper = taskHistoryHelper; | ||
| } | ||
|
|
||
| public long unpause(SingularityRequest request, Optional<String> user, Optional<String> message, Optional<Boolean> skipHealthchecks) { | ||
|
|
@@ -237,7 +228,6 @@ public List<SingularityRequestParent> fillDataForRequestsAndFilter(List<Singular | |
| Long lastActionTime = null; | ||
| if (includeFullRequestData) { | ||
| lastActionTime = getLastActionTimeForRequest( | ||
| request.getRequest(), | ||
| requestIdToLastHistory.getOrDefault(request.getRequest().getId(), Optional.empty()), | ||
| Optional.ofNullable(deployStates.get(request.getRequest().getId())) | ||
| ); | ||
|
|
@@ -309,6 +299,7 @@ private Optional<SingularityTaskIdsByStatus> getTaskIdsByStatusForRequest(Singul | |
| activeTaskIds.removeAll(cleaningTaskIds); | ||
|
|
||
| List<SingularityTaskId> healthyTaskIds = new ArrayList<>(); | ||
| List<SingularityTaskId> killedTaskIds = new ArrayList<>(); | ||
| List<SingularityTaskId> notYetHealthyTaskIds = new ArrayList<>(); | ||
| Map<String, List<SingularityTaskId>> taskIdsByDeployId = activeTaskIds.stream().collect(Collectors.groupingBy(SingularityTaskId::getDeployId)); | ||
| for (Map.Entry<String, List<SingularityTaskId>> entry : taskIdsByDeployId.entrySet()) { | ||
|
|
@@ -319,15 +310,27 @@ private Optional<SingularityTaskIdsByStatus> getTaskIdsByStatusForRequest(Singul | |
| entry.getValue(), | ||
| pendingDeploy.isPresent() && pendingDeploy.get().getDeployMarker().getDeployId().equals(entry.getKey())); | ||
| for (SingularityTaskId taskId : entry.getValue()) { | ||
| if (healthyTasksIdsForDeploy.contains(taskId)) { | ||
| if (taskManager.isKilledTask(taskId)) { | ||
| killedTaskIds.add(taskId); | ||
| } else if (healthyTasksIdsForDeploy.contains(taskId)) { | ||
| healthyTaskIds.add(taskId); | ||
| } else { | ||
| notYetHealthyTaskIds.add(taskId); | ||
| } | ||
| } | ||
| } | ||
|
|
||
| return Optional.of(new SingularityTaskIdsByStatus(healthyTaskIds, notYetHealthyTaskIds, pendingTaskIds, cleaningTaskIds)); | ||
| List<SingularityTaskId> loadBalanced = new ArrayList<>(); | ||
| if (requestWithState.getRequest().isLoadBalanced()) { | ||
| healthyTaskIds.stream() | ||
| .filter(taskManager::isInLoadBalancer) | ||
| .forEach(loadBalanced::add); | ||
| cleaningTaskIds.stream() | ||
| .filter(taskManager::isInLoadBalancer) | ||
|
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. does the task manager automatically update itself when tasks go in and out of the load balancer?
Member
Author
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. yeah, the isInLoadBalancer here is a live call to fetch the state (cached on the leader in memory) |
||
| .forEach(loadBalanced::add); | ||
| } | ||
|
|
||
| return Optional.of(new SingularityTaskIdsByStatus(healthyTaskIds, notYetHealthyTaskIds, pendingTaskIds, cleaningTaskIds, loadBalanced, killedTaskIds)); | ||
| } | ||
|
|
||
| private boolean userAssociatedWithDeploy(Optional<SingularityRequestDeployState> deployState, SingularityUser user) { | ||
|
|
@@ -345,7 +348,7 @@ private boolean userModifiedRequestLast(Optional<SingularityRequestHistory> last | |
| return lastHistory.isPresent() && userMatches(lastHistory.get().getUser(), user); | ||
| } | ||
|
|
||
| private long getLastActionTimeForRequest(SingularityRequest request, Optional<SingularityRequestHistory> lastHistory, Optional<SingularityRequestDeployState> deployState) { | ||
| private long getLastActionTimeForRequest(Optional<SingularityRequestHistory> lastHistory, Optional<SingularityRequestDeployState> deployState) { | ||
| long lastUpdate = 0; | ||
| if (lastHistory.isPresent()) { | ||
| lastUpdate = lastHistory.get().getCreatedAt(); | ||
|
|
||
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.
were these methods unused?
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.
yeah all unused