Search in sources :

Example 1 with SingularityLoadBalancerUpdate

use of com.hubspot.singularity.SingularityLoadBalancerUpdate in project Singularity by HubSpot.

the class TaskManager method getTaskHistory.

public Optional<SingularityTaskHistory> getTaskHistory(SingularityTaskId taskId) {
    final Optional<SingularityTask> task = getTaskCheckCache(taskId, true);
    if (!task.isPresent()) {
        return Optional.absent();
    }
    List<SingularityTaskHistoryUpdate> taskUpdates = getTaskHistoryUpdates(taskId);
    Optional<String> directory = getDirectory(taskId);
    Optional<String> containerId = getContainerId(taskId);
    List<SingularityTaskHealthcheckResult> healthchecks = getHealthcheckResults(taskId);
    List<SingularityLoadBalancerUpdate> loadBalancerUpdates = Lists.newArrayListWithCapacity(2);
    checkLoadBalancerHistory(loadBalancerUpdates, taskId, LoadBalancerRequestType.ADD);
    checkLoadBalancerHistory(loadBalancerUpdates, taskId, LoadBalancerRequestType.REMOVE);
    List<SingularityTaskShellCommandHistory> shellCommandHistory = getTaskShellCommandHistory(taskId);
    List<SingularityTaskMetadata> taskMetadata = getTaskMetadata(taskId);
    return Optional.of(new SingularityTaskHistory(taskUpdates, directory, containerId, healthchecks, task.get(), loadBalancerUpdates, shellCommandHistory, taskMetadata));
}
Also used : SingularityLoadBalancerUpdate(com.hubspot.singularity.SingularityLoadBalancerUpdate) SingularityTaskShellCommandHistory(com.hubspot.singularity.SingularityTaskShellCommandHistory) SingularityTaskHealthcheckResult(com.hubspot.singularity.SingularityTaskHealthcheckResult) SingularityTask(com.hubspot.singularity.SingularityTask) SingularityTaskMetadata(com.hubspot.singularity.SingularityTaskMetadata) SingularityTaskHistoryUpdate(com.hubspot.singularity.SingularityTaskHistoryUpdate) SingularityTaskHistory(com.hubspot.singularity.SingularityTaskHistory)

Example 2 with SingularityLoadBalancerUpdate

use of com.hubspot.singularity.SingularityLoadBalancerUpdate in project Singularity by HubSpot.

the class SingularitySchedulerTest method testLBCleanup.

@Test
public void testLBCleanup() {
    initLoadBalancedRequest();
    initFirstDeploy();
    configuration.setLoadBalancerRemovalGracePeriodMillis(10000);
    SingularityTask task = launchTask(request, firstDeploy, 1, TaskState.TASK_RUNNING);
    saveLoadBalancerState(BaragonRequestState.SUCCESS, task.getTaskId(), LoadBalancerRequestType.ADD);
    statusUpdate(task, TaskState.TASK_FAILED);
    Assert.assertTrue(!taskManager.getLBCleanupTasks().isEmpty());
    testingLbClient.setNextBaragonRequestState(BaragonRequestState.WAITING);
    cleaner.drainCleanupQueue();
    Assert.assertTrue(!taskManager.getLBCleanupTasks().isEmpty());
    Optional<SingularityLoadBalancerUpdate> lbUpdate = taskManager.getLoadBalancerState(task.getTaskId(), LoadBalancerRequestType.REMOVE);
    Assert.assertTrue(lbUpdate.isPresent());
    Assert.assertTrue(lbUpdate.get().getLoadBalancerState() == BaragonRequestState.WAITING);
    testingLbClient.setNextBaragonRequestState(BaragonRequestState.FAILED);
    cleaner.drainCleanupQueue();
    Assert.assertTrue(!taskManager.getLBCleanupTasks().isEmpty());
    lbUpdate = taskManager.getLoadBalancerState(task.getTaskId(), LoadBalancerRequestType.REMOVE);
    Assert.assertTrue(lbUpdate.isPresent());
    Assert.assertTrue(lbUpdate.get().getLoadBalancerState() == BaragonRequestState.FAILED);
    testingLbClient.setNextBaragonRequestState(BaragonRequestState.SUCCESS);
    cleaner.drainCleanupQueue();
    Assert.assertTrue(!taskManager.getLBCleanupTasks().isEmpty());
    configuration.setLoadBalancerRemovalGracePeriodMillis(0);
    cleaner.drainCleanupQueue();
    Assert.assertTrue(taskManager.getLBCleanupTasks().isEmpty());
    lbUpdate = taskManager.getLoadBalancerState(task.getTaskId(), LoadBalancerRequestType.REMOVE);
    Assert.assertTrue(lbUpdate.isPresent());
    Assert.assertTrue(lbUpdate.get().getLoadBalancerState() == BaragonRequestState.SUCCESS);
    Assert.assertTrue(lbUpdate.get().getLoadBalancerRequestId().getAttemptNumber() == 2);
}
Also used : SingularityLoadBalancerUpdate(com.hubspot.singularity.SingularityLoadBalancerUpdate) SingularityTask(com.hubspot.singularity.SingularityTask) Test(org.junit.Test)

Example 3 with SingularityLoadBalancerUpdate

use of com.hubspot.singularity.SingularityLoadBalancerUpdate in project Singularity by HubSpot.

the class SingularitySchedulerTestBase method startDeploy.

protected void startDeploy(SingularityDeployMarker deployMarker, long timestamp) {
    SingularityDeployProgress startingDeployProgress = new SingularityDeployProgress(1, 0, 1, 10, false, true, Collections.<SingularityTaskId>emptySet(), timestamp);
    deployManager.savePendingDeploy(new SingularityPendingDeploy(deployMarker, Optional.<SingularityLoadBalancerUpdate>absent(), DeployState.WAITING, Optional.of(startingDeployProgress), Optional.<SingularityRequest>absent()));
}
Also used : SingularityLoadBalancerUpdate(com.hubspot.singularity.SingularityLoadBalancerUpdate) SingularityPendingDeploy(com.hubspot.singularity.SingularityPendingDeploy) SingularityRequest(com.hubspot.singularity.SingularityRequest) SingularityDeployProgress(com.hubspot.singularity.SingularityDeployProgress)

Example 4 with SingularityLoadBalancerUpdate

use of com.hubspot.singularity.SingularityLoadBalancerUpdate in project Singularity by HubSpot.

the class SingularitySchedulerTestBase method saveLoadBalancerState.

protected void saveLoadBalancerState(BaragonRequestState brs, SingularityTaskId taskId, LoadBalancerRequestType lbrt) {
    final LoadBalancerRequestId lbri = new LoadBalancerRequestId(taskId.getId(), lbrt, Optional.<Integer>absent());
    SingularityLoadBalancerUpdate update = new SingularityLoadBalancerUpdate(brs, lbri, Optional.<String>absent(), System.currentTimeMillis(), LoadBalancerMethod.CHECK_STATE, null);
    taskManager.saveLoadBalancerState(taskId, lbrt, update);
}
Also used : SingularityLoadBalancerUpdate(com.hubspot.singularity.SingularityLoadBalancerUpdate) LoadBalancerRequestId(com.hubspot.singularity.LoadBalancerRequestType.LoadBalancerRequestId)

Example 5 with SingularityLoadBalancerUpdate

use of com.hubspot.singularity.SingularityLoadBalancerUpdate in project Singularity by HubSpot.

the class SingularityDeployChecker method cancelLoadBalancer.

private SingularityDeployResult cancelLoadBalancer(SingularityPendingDeploy pendingDeploy, List<SingularityDeployFailure> deployFailures) {
    final SingularityLoadBalancerUpdate lbUpdate = sendCancelToLoadBalancer(pendingDeploy);
    final DeployState deployState = interpretLoadBalancerState(lbUpdate, DeployState.CANCELING);
    updatePendingDeploy(pendingDeploy, Optional.of(lbUpdate), deployState);
    return new SingularityDeployResult(deployState, lbUpdate, deployFailures);
}
Also used : SingularityLoadBalancerUpdate(com.hubspot.singularity.SingularityLoadBalancerUpdate) DeployState(com.hubspot.singularity.DeployState) SingularityRequestDeployState(com.hubspot.singularity.SingularityRequestDeployState) SingularityDeployResult(com.hubspot.singularity.SingularityDeployResult)

Aggregations

SingularityLoadBalancerUpdate (com.hubspot.singularity.SingularityLoadBalancerUpdate)13 LoadBalancerRequestId (com.hubspot.singularity.LoadBalancerRequestType.LoadBalancerRequestId)5 SingularityTask (com.hubspot.singularity.SingularityTask)4 SingularityDeployResult (com.hubspot.singularity.SingularityDeployResult)3 SingularityTaskId (com.hubspot.singularity.SingularityTaskId)3 DeployState (com.hubspot.singularity.DeployState)2 SingularityDeployProgress (com.hubspot.singularity.SingularityDeployProgress)2 SingularityRequestDeployState (com.hubspot.singularity.SingularityRequestDeployState)2 SingularityTaskHealthcheckResult (com.hubspot.singularity.SingularityTaskHealthcheckResult)2 DeployHealth (com.hubspot.singularity.scheduler.SingularityDeployHealthHelper.DeployHealth)2 ArrayList (java.util.ArrayList)2 Test (org.junit.Test)2 VisibleForTesting (com.google.common.annotations.VisibleForTesting)1 SingularityPendingDeploy (com.hubspot.singularity.SingularityPendingDeploy)1 SingularityRequest (com.hubspot.singularity.SingularityRequest)1 SingularityRequestLbCleanup (com.hubspot.singularity.SingularityRequestLbCleanup)1 SingularityTaskHistory (com.hubspot.singularity.SingularityTaskHistory)1 SingularityTaskHistoryUpdate (com.hubspot.singularity.SingularityTaskHistoryUpdate)1 SimplifiedTaskState (com.hubspot.singularity.SingularityTaskHistoryUpdate.SimplifiedTaskState)1 SingularityTaskMetadata (com.hubspot.singularity.SingularityTaskMetadata)1