From 1edc9574abf0ed19018363da9011a5caf0e42814 Mon Sep 17 00:00:00 2001 From: Vasil Ilchev Date: Fri, 20 Sep 2024 15:20:08 +0300 Subject: [PATCH] Quota for ActionStatus push to be checked only for intermediate statuses. Always allow terminate/final status (#1846) --- .../jpa/management/JpaActionManagement.java | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/management/JpaActionManagement.java b/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/management/JpaActionManagement.java index b4e4e5fe85..d38aa4f5dc 100644 --- a/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/management/JpaActionManagement.java +++ b/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/management/JpaActionManagement.java @@ -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; @@ -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; @@ -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) {