Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -561,6 +561,10 @@ private void forceQuitActionsOfRollout(final Rollout rollout) {
.getContent();
log.info("Found {} active actions for rollout {}", actions.size(), rollout.getId());

if (actions.isEmpty()) {
return;
}

storeActionsAndStatuses(actions, Action.Status.CANCELED);

// find next active actions - filter by targetId list and isActive
Expand Down Expand Up @@ -604,7 +608,7 @@ private void storeActionsAndStatuses(List<JpaAction> actions, Action.Status stat
private int updateTargetAssignedDsWithFirstActiveAction(List<Long> targetIds) {
final Query updateQuery = entityManager.createNativeQuery(
"UPDATE sp_target t " +
"SET t.assigned_distribution_set = ( " +
"SET assigned_distribution_set = ( " +
"SELECT a.distribution_set" +
" FROM sp_action a" +
" WHERE a.target = t.id AND a.active = TRUE" +
Expand All @@ -623,10 +627,10 @@ private int updateTargetAssignedDsWithFirstActiveAction(List<Long> targetIds) {
private int updateTargetAssignedDsWithInstalledIfNoActiveActions(List<Long> targetIds) {
final Query updateQuery = entityManager.createNativeQuery(
"UPDATE sp_target t " +
"SET t.assigned_distribution_set = t.installed_distribution_set, t.update_status = 1 " +
"SET assigned_distribution_set = t.installed_distribution_set, update_status = 1 " +
"WHERE t.id IN (" + Jpa.formatNativeQueryInClause("tid", targetIds) + ") " +
" AND (SELECT count(*) FROM sp_action a " +
" WHERE a.target=t.id and a.active=1) = 0"
" WHERE a.target = t.id and a.active = TRUE) = 0"
);
Jpa.setNativeQueryInParameter(updateQuery, "tid", targetIds);
final int updated = updateQuery.executeUpdate();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import jakarta.persistence.NamedEntityGraph;
import jakarta.persistence.NamedEntityGraphs;
import jakarta.persistence.OneToMany;
import jakarta.persistence.OrderBy;
import jakarta.persistence.Table;
import jakarta.persistence.Transient;
import jakarta.validation.constraints.Max;
Expand Down Expand Up @@ -64,6 +65,7 @@
public class JpaRollout extends AbstractJpaNamedEntity implements Rollout, EventAwareEntity {

@OneToMany(targetEntity = JpaRolloutGroup.class, fetch = FetchType.LAZY, cascade = { CascadeType.REMOVE }, mappedBy = "rollout")
@OrderBy("id ASC")
private List<JpaRolloutGroup> rolloutGroups = new ArrayList<>();

@Setter
Expand Down
Loading