use of com.sequenceiq.cloudbreak.orchestrator.salt.domain.MinionStatusSaltResponse in project cloudbreak by hortonworks.
the class SaltOrchestrator method removeDeadSaltMinions.
@Override
@Retryable(backoff = @Backoff(delay = 1000, multiplier = 2, maxDelay = 10000), maxAttempts = 5)
public void removeDeadSaltMinions(GatewayConfig gateway) throws CloudbreakOrchestratorFailedException {
try (SaltConnector saltConnector = saltService.createSaltConnector(gateway)) {
MinionStatusSaltResponse minionStatusSaltResponse = SaltStates.collectNodeStatus(saltConnector);
List<String> downNodes = minionStatusSaltResponse.downMinions();
LOGGER.info("Deleting dead minions {} from {}", StringUtils.join(downNodes, ", "), gateway.getHostname());
if (!CollectionUtils.isEmpty(downNodes)) {
saltConnector.wheel("key.delete", downNodes, Object.class);
}
} catch (Exception e) {
LOGGER.info("Error occurred during dead salt minions removal on " + gateway.getHostname(), e);
throw new CloudbreakOrchestratorFailedException(e.getMessage(), e);
}
}
use of com.sequenceiq.cloudbreak.orchestrator.salt.domain.MinionStatusSaltResponse in project cloudbreak by hortonworks.
the class SaltOrchestratorTest method testRemoveDeadSaltMinions.
@Test
public void testRemoveDeadSaltMinions() throws Exception {
PowerMockito.mockStatic(SaltStates.class);
MinionStatusSaltResponse minionStatusSaltResponse = new MinionStatusSaltResponse();
List<MinionStatus> minionStatusList = new ArrayList<>();
MinionStatus minionStatus = new MinionStatus();
List<String> upNodes = Lists.newArrayList("10-0-0-1.example.com", "10-0-0-2.example.com", "10-0-0-3.example.com");
minionStatus.setUp(upNodes);
List<String> downNodes = Lists.newArrayList("10-0-0-4.example.com", "10-0-0-5.example.com");
minionStatus.setDown(downNodes);
minionStatusList.add(minionStatus);
minionStatusSaltResponse.setResult(minionStatusList);
when(SaltStates.collectNodeStatus(eq(saltConnector))).thenReturn(minionStatusSaltResponse);
saltOrchestrator.removeDeadSaltMinions(gatewayConfig);
verify(saltConnector, times(1)).wheel("key.delete", downNodes, Object.class);
}
use of com.sequenceiq.cloudbreak.orchestrator.salt.domain.MinionStatusSaltResponse in project cloudbreak by hortonworks.
the class SaltOrchestratorTest method testDontRemoveDeadSaltMinions.
@Test
public void testDontRemoveDeadSaltMinions() throws Exception {
PowerMockito.mockStatic(SaltStates.class);
MinionStatusSaltResponse minionStatusSaltResponse = new MinionStatusSaltResponse();
List<MinionStatus> minionStatusList = new ArrayList<>();
MinionStatus minionStatus = new MinionStatus();
List<String> upNodes = Lists.newArrayList("10-0-0-1.example.com", "10-0-0-2.example.com", "10-0-0-3.example.com");
minionStatus.setUp(upNodes);
List<String> downNodes = new ArrayList<>();
minionStatus.setDown(downNodes);
minionStatusList.add(minionStatus);
minionStatusSaltResponse.setResult(minionStatusList);
when(SaltStates.collectNodeStatus(eq(saltConnector))).thenReturn(minionStatusSaltResponse);
saltOrchestrator.removeDeadSaltMinions(gatewayConfig);
verify(saltConnector, never()).wheel("key.delete", downNodes, Object.class);
}
use of com.sequenceiq.cloudbreak.orchestrator.salt.domain.MinionStatusSaltResponse in project cloudbreak by hortonworks.
the class SaltStates method collectNodeStatus.
public static MinionStatusSaltResponse collectNodeStatus(SaltConnector sc) {
MinionStatusSaltResponse minionStatus = measure(() -> sc.run("manage.status", RUNNER, MinionStatusSaltResponse.class), LOGGER, "Manage status call took {}ms");
LOGGER.debug("Minion status: {}", minionStatus);
return minionStatus;
}
use of com.sequenceiq.cloudbreak.orchestrator.salt.domain.MinionStatusSaltResponse in project cloudbreak by hortonworks.
the class SaltOrchestratorTest method tearDownReusedIpAddressTest.
@Test
public void tearDownReusedIpAddressTest() throws Exception {
Map<String, String> privateIpsByFQDN = new HashMap<>();
privateIpsByFQDN.put("10-0-0-1.example.com", "10.0.0.1");
privateIpsByFQDN.put("10-0-0-2.example.com", "10.0.0.2");
privateIpsByFQDN.put("10-0-0-3.example.com", "10.0.0.3");
Set<String> privateIps = privateIpsByFQDN.values().stream().collect(Collectors.toSet());
mockStatic(SaltStates.class);
SaltStates.stopMinions(eq(saltConnector), eq(privateIps));
MinionStatusSaltResponse minionStatusSaltResponse = new MinionStatusSaltResponse();
List<MinionStatus> minionStatusList = new ArrayList<>();
MinionStatus minionStatus = new MinionStatus();
List<String> upNodes = Lists.newArrayList("10-0-0-1.example.com", "10-0-0-2.example.com", "10-0-0-3.example.com");
minionStatus.setUp(upNodes);
List<String> downNodes = Lists.newArrayList("10-0-0-4.example.com", "10-0-0-5.example.com");
minionStatus.setDown(downNodes);
minionStatusList.add(minionStatus);
minionStatusSaltResponse.setResult(minionStatusList);
when(SaltStates.collectNodeStatus(eq(saltConnector))).thenReturn(minionStatusSaltResponse);
Callable<Boolean> callable = mock(Callable.class);
when(saltRunner.runner(any(OrchestratorBootstrap.class), any(ExitCriteria.class), any(ExitCriteriaModel.class))).thenReturn(callable);
Node remainingNode = mock(Node.class);
when(remainingNode.getPrivateIp()).thenReturn("10.0.0.1");
when(remainingNode.getHostname()).thenReturn("hostname");
ExitCriteriaModel exitCriteriaModel = mock(ExitCriteriaModel.class);
saltOrchestrator.tearDown(() -> Set.of(), Collections.singletonList(gatewayConfig), privateIpsByFQDN, Set.of(remainingNode), exitCriteriaModel);
verify(saltConnector, times(1)).wheel(eq("key.delete"), eq(downNodes), eq(Object.class));
verifyStatic(SaltStates.class);
SaltStates.stopMinions(eq(saltConnector), eq(Set.of("10.0.0.2", "10.0.0.3")));
}
Aggregations