Fix rollout management cancel running action (#466)
* fix cancellation of wrong obsolete action during rollout-mgmt Signed-off-by: Michael Hirsch <michael.hirsch@bosch-si.com> * add unit test to verify rollout not cancel running action with same DS Signed-off-by: Michael Hirsch <michael.hirsch@bosch-si.com>
This commit is contained in:
@@ -254,8 +254,9 @@ public class JpaDeploymentManagement implements DeploymentManagement {
|
||||
|
||||
targetIds.forEach(tIds -> targetRepository.setAssignedDistributionSetAndUpdateStatus(TargetUpdateStatus.PENDING,
|
||||
set, System.currentTimeMillis(), currentUser, tIds));
|
||||
final Map<String, JpaAction> targetIdsToActions = targets.stream().map(
|
||||
t -> actionRepository.save(createTargetAction(targetsWithActionMap, t, set, rollout, rolloutGroup)))
|
||||
final Map<String, JpaAction> targetIdsToActions = targets.stream()
|
||||
.map(t -> actionRepository
|
||||
.save(createTargetAction(targetsWithActionMap, t, set, rollout, rolloutGroup)))
|
||||
.collect(Collectors.toMap(a -> a.getTarget().getControllerId(), Function.identity()));
|
||||
|
||||
// create initial action status when action is created so we remember
|
||||
@@ -465,10 +466,6 @@ public class JpaDeploymentManagement implements DeploymentManagement {
|
||||
}
|
||||
|
||||
private void startScheduledAction(final JpaAction action) {
|
||||
// check if we need to override running update actions
|
||||
final Set<Long> overrideObsoleteUpdateActions = overrideObsoleteUpdateActions(
|
||||
Collections.singletonList(action.getTarget().getId()));
|
||||
|
||||
JpaTarget target = (JpaTarget) action.getTarget();
|
||||
|
||||
if (target.getAssignedDistributionSet() != null
|
||||
@@ -482,6 +479,10 @@ public class JpaDeploymentManagement implements DeploymentManagement {
|
||||
return;
|
||||
}
|
||||
|
||||
// check if we need to override running update actions
|
||||
final Set<Long> overrideObsoleteUpdateActions = overrideObsoleteUpdateActions(
|
||||
Collections.singletonList(action.getTarget().getId()));
|
||||
|
||||
action.setActive(true);
|
||||
action.setStatus(Status.RUNNING);
|
||||
final JpaAction savedAction = actionRepository.save(action);
|
||||
@@ -669,7 +670,7 @@ public class JpaDeploymentManagement implements DeploymentManagement {
|
||||
final Long totalCount = entityManager.createQuery(countMsgQuery).getSingleResult();
|
||||
|
||||
final CriteriaQuery<String> msgQuery = cb.createQuery(String.class);
|
||||
final Root<JpaActionStatus>as = msgQuery.from(JpaActionStatus.class);
|
||||
final Root<JpaActionStatus> as = msgQuery.from(JpaActionStatus.class);
|
||||
final ListJoin<JpaActionStatus, String> join = as.joinList("messages", JoinType.LEFT);
|
||||
final CriteriaQuery<String> selMsgQuery = msgQuery.select(join);
|
||||
selMsgQuery.where(cb.equal(as.get(JpaActionStatus_.id), actionStatusId));
|
||||
|
||||
Reference in New Issue
Block a user