@Test public void shouldNotTriggerSync() { String hostFQDN = "host2Name.stopped"; InstanceMetaData instanceMd = getHost(hostFQDN, "master", InstanceStatus.SERVICES_HEALTHY, InstanceGroupType.GATEWAY); when(hostGroupService.getRepairViewByClusterIdAndName(stack.getCluster().getId(), instanceMd.getInstanceGroup().getGroupName())) .thenReturn(Optional.of(getHostGroup(instanceMd, RecoveryMode.MANUAL))); when(instanceMetaDataService.findHostInStack(eq(stack.getId()), eq(hostFQDN))).thenReturn(Optional.of(instanceMd)); when(stackService.findByCrn(STACK_CRN)).thenReturn(stack); when(cloudbreakMessagesService.getMessage(any(), anyCollection())).thenReturn("failed node"); underTest.reportHealthChange(STACK_CRN, Set.of(hostFQDN), Set.of()); verify(flowManager, times(0)).triggerStackSync(eq(stack.getId())); }
public void reportHealthChange(String crn, Set<String> failedNodes, Set<String> newHealthyNodes) { if (!Sets.intersection(failedNodes, newHealthyNodes).isEmpty()) { throw new BadRequestException("Failed nodes " + failedNodes + " and healthy nodes " + newHealthyNodes + " should not have common items."); } if (failedNodes.isEmpty() && newHealthyNodes.isEmpty()) { return; } try { transactionService.required(() -> { Stack stack = stackService.findByCrn(crn); if (stack != null && !stack.getStatus().isInProgress()) { handleHealthChange(failedNodes, newHealthyNodes, stack); } else { LOGGER.debug("Stack [{}] status is {}, thus we do not handle failure report.", stack.getName(), stack.getStatus()); } return null; }); } catch (TransactionExecutionException e) { throw new TransactionRuntimeExecutionException(e); } }
ClusterOperationService { public void reportHealthChange(String crn, Set<String> failedNodes, Set<String> newHealthyNodes) { if (!Sets.intersection(failedNodes, newHealthyNodes).isEmpty()) { throw new BadRequestException("Failed nodes " + failedNodes + " and healthy nodes " + newHealthyNodes + " should not have common items."); } if (failedNodes.isEmpty() && newHealthyNodes.isEmpty()) { return; } try { transactionService.required(() -> { Stack stack = stackService.findByCrn(crn); if (stack != null && !stack.getStatus().isInProgress()) { handleHealthChange(failedNodes, newHealthyNodes, stack); } else { LOGGER.debug("Stack [{}] status is {}, thus we do not handle failure report.", stack.getName(), stack.getStatus()); } return null; }); } catch (TransactionExecutionException e) { throw new TransactionRuntimeExecutionException(e); } } }
ClusterOperationService { public void reportHealthChange(String crn, Set<String> failedNodes, Set<String> newHealthyNodes) { if (!Sets.intersection(failedNodes, newHealthyNodes).isEmpty()) { throw new BadRequestException("Failed nodes " + failedNodes + " and healthy nodes " + newHealthyNodes + " should not have common items."); } if (failedNodes.isEmpty() && newHealthyNodes.isEmpty()) { return; } try { transactionService.required(() -> { Stack stack = stackService.findByCrn(crn); if (stack != null && !stack.getStatus().isInProgress()) { handleHealthChange(failedNodes, newHealthyNodes, stack); } else { LOGGER.debug("Stack [{}] status is {}, thus we do not handle failure report.", stack.getName(), stack.getStatus()); } return null; }); } catch (TransactionExecutionException e) { throw new TransactionRuntimeExecutionException(e); } }  }
ClusterOperationService { public void reportHealthChange(String crn, Set<String> failedNodes, Set<String> newHealthyNodes) { if (!Sets.intersection(failedNodes, newHealthyNodes).isEmpty()) { throw new BadRequestException("Failed nodes " + failedNodes + " and healthy nodes " + newHealthyNodes + " should not have common items."); } if (failedNodes.isEmpty() && newHealthyNodes.isEmpty()) { return; } try { transactionService.required(() -> { Stack stack = stackService.findByCrn(crn); if (stack != null && !stack.getStatus().isInProgress()) { handleHealthChange(failedNodes, newHealthyNodes, stack); } else { LOGGER.debug("Stack [{}] status is {}, thus we do not handle failure report.", stack.getName(), stack.getStatus()); } return null; }); } catch (TransactionExecutionException e) { throw new TransactionRuntimeExecutionException(e); } }  @Measure(ClusterOperationService.class) Cluster create(Stack stack, Cluster cluster, List<ClusterComponent> components, User user); void delete(Long stackId, boolean forced); FlowIdentifier updateHosts(Long stackId, HostGroupAdjustmentV4Request hostGroupAdjustment); FlowIdentifier updateUserNamePassword(Long stackId, UserNamePasswordV4Request userNamePasswordJson); void reportHealthChange(String crn, Set<String> failedNodes, Set<String> newHealthyNodes); FlowIdentifier updateStatus(Long stackId, StatusRequest statusRequest); FlowIdentifier updateStatus(Stack stack, StatusRequest statusRequest); FlowIdentifier recreate(Stack stack, String blueprintName, Set<HostGroup> hostGroups, boolean validateBlueprint); FlowIdentifier triggerMaintenanceModeValidation(Stack stack); FlowIdentifier updateSalt(Stack stack); FlowIdentifier updatePillarConfiguration(Stack stack); FlowIdentifier rotateClusterCertificates(Stack stack, CertificatesRotationV4Request certificatesRotationV4Request); }
ClusterOperationService { public void reportHealthChange(String crn, Set<String> failedNodes, Set<String> newHealthyNodes) { if (!Sets.intersection(failedNodes, newHealthyNodes).isEmpty()) { throw new BadRequestException("Failed nodes " + failedNodes + " and healthy nodes " + newHealthyNodes + " should not have common items."); } if (failedNodes.isEmpty() && newHealthyNodes.isEmpty()) { return; } try { transactionService.required(() -> { Stack stack = stackService.findByCrn(crn); if (stack != null && !stack.getStatus().isInProgress()) { handleHealthChange(failedNodes, newHealthyNodes, stack); } else { LOGGER.debug("Stack [{}] status is {}, thus we do not handle failure report.", stack.getName(), stack.getStatus()); } return null; }); } catch (TransactionExecutionException e) { throw new TransactionRuntimeExecutionException(e); } }  @Measure(ClusterOperationService.class) Cluster create(Stack stack, Cluster cluster, List<ClusterComponent> components, User user); void delete(Long stackId, boolean forced); FlowIdentifier updateHosts(Long stackId, HostGroupAdjustmentV4Request hostGroupAdjustment); FlowIdentifier updateUserNamePassword(Long stackId, UserNamePasswordV4Request userNamePasswordJson); void reportHealthChange(String crn, Set<String> failedNodes, Set<String> newHealthyNodes); FlowIdentifier updateStatus(Long stackId, StatusRequest statusRequest); FlowIdentifier updateStatus(Stack stack, StatusRequest statusRequest); FlowIdentifier recreate(Stack stack, String blueprintName, Set<HostGroup> hostGroups, boolean validateBlueprint); FlowIdentifier triggerMaintenanceModeValidation(Stack stack); FlowIdentifier updateSalt(Stack stack); FlowIdentifier updatePillarConfiguration(Stack stack); FlowIdentifier rotateClusterCertificates(Stack stack, CertificatesRotationV4Request certificatesRotationV4Request);  }