Skip to content

Commit

Permalink
Quota for ActionStatus push to be checked only for intermediate statu…
Browse files Browse the repository at this point in the history
…ses. Always allow terminate/final status (#1846)
  • Loading branch information
vasilchev authored Sep 20, 2024
1 parent aed717d commit 1edc957
Showing 1 changed file with 10 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,6 @@
*/
package org.eclipse.hawkbit.repository.jpa.management;

import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
import java.util.stream.Collectors;

import lombok.extern.slf4j.Slf4j;
import org.eclipse.hawkbit.repository.QuotaManagement;
import org.eclipse.hawkbit.repository.RepositoryProperties;
Expand All @@ -32,6 +27,11 @@
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Sort;

import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
import java.util.stream.Collectors;

import static org.eclipse.hawkbit.repository.model.Action.ActionType.DOWNLOAD_ONLY;
import static org.eclipse.hawkbit.repository.model.Action.Status.FINISHED;

Expand Down Expand Up @@ -158,8 +158,11 @@ protected void onActionStatusUpdate(final Action.Status updatedActionStatus, fin
}

protected void assertActionStatusQuota(final JpaAction action) {
QuotaHelper.assertAssignmentQuota(action.getId(), 1, quotaManagement.getMaxStatusEntriesPerAction(),
ActionStatus.class, Action.class, actionStatusRepository::countByActionId);
final boolean intermediateStatus = FINISHED != action.getStatus() && Action.Status.ERROR != action.getStatus();
if (intermediateStatus) {// check for quota only for intermediate statuses
QuotaHelper.assertAssignmentQuota(action.getId(), 1, quotaManagement.getMaxStatusEntriesPerAction(),
ActionStatus.class, Action.class, actionStatusRepository::countByActionId);
}
}

protected void assertActionStatusMessageQuota(final JpaActionStatus actionStatus) {
Expand Down

0 comments on commit 1edc957

Please sign in to comment.