Fix cancel action status (#429)
* Fixed handling of action cancellation status updates. Signed-off-by: kaizimmerm <kai.zimmermann@bosch-si.com> * Fix broken DDI test. Signed-off-by: kaizimmerm <kai.zimmermann@bosch-si.com> * Code readibility. Signed-off-by: kaizimmerm <kai.zimmermann@bosch-si.com> * Reduce access to default. Signed-off-by: kaizimmerm <kai.zimmermann@bosch-si.com> * Added test for finished on action that is in cancelling. Signed-off-by: kaizimmerm <kai.zimmermann@bosch-si.com> * Update MariaDb driver Signed-off-by: kaizimmerm <kai.zimmermann@bosch-si.com> * Wrong branch Signed-off-by: kaizimmerm <kai.zimmermann@bosch-si.com> * Remove duplicate status definition. Signed-off-by: kaizimmerm <kai.zimmermann@bosch-si.com> * Use updated picture in docs. Signed-off-by: kaizimmerm <kai.zimmermann@bosch-si.com> * Leverage existing statics. Signed-off-by: kaizimmerm <kai.zimmermann@bosch-si.com> * Fix picture upload. Signed-off-by: kaizimmerm <kai.zimmermann@bosch-si.com> * Revert change Signed-off-by: kaizimmerm <kai.zimmermann@bosch-si.com>
This commit is contained in:
@@ -28,6 +28,7 @@ import org.eclipse.hawkbit.repository.builder.ActionStatusCreate;
|
||||
import org.eclipse.hawkbit.repository.event.remote.DownloadProgressEvent;
|
||||
import org.eclipse.hawkbit.repository.event.remote.TargetPollEvent;
|
||||
import org.eclipse.hawkbit.repository.event.remote.entity.TargetUpdatedEvent;
|
||||
import org.eclipse.hawkbit.repository.exception.CancelActionNotAllowedException;
|
||||
import org.eclipse.hawkbit.repository.exception.EntityNotFoundException;
|
||||
import org.eclipse.hawkbit.repository.exception.ToManyAttributeEntriesException;
|
||||
import org.eclipse.hawkbit.repository.exception.TooManyStatusEntriesException;
|
||||
@@ -101,9 +102,6 @@ public class JpaControllerManagement implements ControllerManagement {
|
||||
@Autowired
|
||||
private RepositoryProperties repositoryProperties;
|
||||
|
||||
@Autowired
|
||||
private TenantConfigurationRepository tenantConfigurationRepository;
|
||||
|
||||
@Autowired
|
||||
private TenantConfigurationManagement tenantConfigurationManagement;
|
||||
|
||||
@@ -242,26 +240,29 @@ public class JpaControllerManagement implements ControllerManagement {
|
||||
final JpaActionStatusCreate create = (JpaActionStatusCreate) c;
|
||||
|
||||
final JpaAction action = getActionAndThrowExceptionIfNotFound(create.getActionId());
|
||||
|
||||
if (!action.isCancelingOrCanceled()) {
|
||||
throw new CancelActionNotAllowedException("The action is not in canceling state.");
|
||||
}
|
||||
|
||||
final JpaActionStatus actionStatus = create.build();
|
||||
|
||||
checkForToManyStatusEntries(action);
|
||||
action.setStatus(actionStatus.getStatus());
|
||||
|
||||
switch (actionStatus.getStatus()) {
|
||||
case WARNING:
|
||||
case ERROR:
|
||||
case RUNNING:
|
||||
break;
|
||||
case CANCELED:
|
||||
case FINISHED:
|
||||
handleFinishedCancelation(actionStatus, action);
|
||||
break;
|
||||
case RETRIEVED:
|
||||
actionStatus.addMessage(RepositoryConstants.SERVER_MESSAGE_PREFIX + "Cancellation request retrieved.");
|
||||
case ERROR:
|
||||
case CANCEL_REJECTED:
|
||||
// Cancellation rejected. Back to running.
|
||||
action.setStatus(Status.RUNNING);
|
||||
break;
|
||||
default:
|
||||
// do nothing
|
||||
// information status entry - check for a potential DOS attack
|
||||
checkForToManyStatusEntries(action);
|
||||
break;
|
||||
}
|
||||
|
||||
actionStatus.setAction(actionRepository.save(action));
|
||||
actionStatusRepository.save(actionStatus);
|
||||
|
||||
@@ -306,17 +307,11 @@ public class JpaControllerManagement implements ControllerManagement {
|
||||
|
||||
/**
|
||||
* Sets {@link TargetUpdateStatus} based on given {@link ActionStatus}.
|
||||
*
|
||||
* @param actionStatus
|
||||
* @param action
|
||||
* @return
|
||||
*/
|
||||
private Action handleAddUpdateActionStatus(final JpaActionStatus actionStatus, final JpaAction action) {
|
||||
LOG.debug("addUpdateActionStatus for action {}", action.getId());
|
||||
|
||||
JpaTarget target = (JpaTarget) action.getTarget();
|
||||
// check for a potential DOS attack
|
||||
checkForToManyStatusEntries(action);
|
||||
|
||||
switch (actionStatus.getStatus()) {
|
||||
case ERROR:
|
||||
@@ -327,10 +322,9 @@ public class JpaControllerManagement implements ControllerManagement {
|
||||
case FINISHED:
|
||||
handleFinishedAndStoreInTargetStatus(target, action);
|
||||
break;
|
||||
case CANCELED:
|
||||
case WARNING:
|
||||
case RUNNING:
|
||||
default:
|
||||
// information status entry - check for a potential DOS attack
|
||||
checkForToManyStatusEntries(action);
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -339,8 +333,6 @@ public class JpaControllerManagement implements ControllerManagement {
|
||||
|
||||
LOG.debug("addUpdateActionStatus {} for target {} is finished.", action, target.getId());
|
||||
|
||||
action.setStatus(actionStatus.getStatus());
|
||||
|
||||
return actionRepository.save(action);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user