Trigger next rollout group - backend and management API implementatio… (#1294)
* Trigger next rollout group - backend and management API implementations. Backend and management API tests. * Trigger next rollout group - Fixed resource documentation test. * Trigger next rollout group - Fixed resource documentation test. * add rest docs * Trigger next rollout group - UI changes. New button for trigger next rollout group in rollout view. * add error test for rest api * Trigger next rollout group - Added test for triggering next group for all rollout states. * add confirm * fix test * replace DB calls * fix translation * fix error message Signed-off-by: Dimitar Shterev <dimitar.shterev@bosch.io> Signed-off-by: Stefan Klotz <stefan.klotz@bosch.io> Co-authored-by: Stefan Klotz <stefan.klotz@bosch.io>
This commit is contained in:
@@ -19,12 +19,15 @@ import java.util.stream.Collectors;
|
||||
import org.eclipse.hawkbit.repository.RolloutGroupManagement;
|
||||
import org.eclipse.hawkbit.repository.RolloutManagement;
|
||||
import org.eclipse.hawkbit.repository.TenantConfigurationManagement;
|
||||
import org.eclipse.hawkbit.repository.exception.RolloutIllegalStateException;
|
||||
import org.eclipse.hawkbit.repository.model.Rollout;
|
||||
import org.eclipse.hawkbit.repository.model.Rollout.RolloutStatus;
|
||||
import org.eclipse.hawkbit.repository.model.TotalTargetCountStatus;
|
||||
import org.eclipse.hawkbit.repository.model.TotalTargetCountStatus.Status;
|
||||
import org.eclipse.hawkbit.security.SystemSecurityContext;
|
||||
import org.eclipse.hawkbit.tenancy.configuration.TenantConfigurationProperties.TenantConfigurationKey;
|
||||
import org.eclipse.hawkbit.ui.common.CommonUiDependencies;
|
||||
import org.eclipse.hawkbit.ui.common.ConfirmationDialog;
|
||||
import org.eclipse.hawkbit.ui.common.builder.GridComponentBuilder;
|
||||
import org.eclipse.hawkbit.ui.common.builder.StatusIconBuilder.ActionTypeIconSupplier;
|
||||
import org.eclipse.hawkbit.ui.common.builder.StatusIconBuilder.RolloutStatusIconSupplier;
|
||||
@@ -54,6 +57,8 @@ import org.eclipse.hawkbit.ui.utils.SPUIStyleDefinitions;
|
||||
import org.eclipse.hawkbit.ui.utils.UIComponentIdProvider;
|
||||
import org.eclipse.hawkbit.ui.utils.UIMessageIdProvider;
|
||||
import org.eclipse.hawkbit.ui.utils.UINotification;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import com.cronutils.utils.StringUtils;
|
||||
import com.google.common.base.Predicates;
|
||||
@@ -70,6 +75,8 @@ import com.vaadin.ui.renderers.HtmlRenderer;
|
||||
* Rollout list grid component.
|
||||
*/
|
||||
public class RolloutGrid extends AbstractGrid<ProxyRollout, String> {
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(RolloutGrid.class);
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
private static final String ROLLOUT_CAPTION_MSG_KEY = "caption.rollout";
|
||||
|
||||
@@ -88,6 +95,7 @@ public class RolloutGrid extends AbstractGrid<ProxyRollout, String> {
|
||||
private static final String APPROVE_BUTTON_ID = "approve";
|
||||
private static final String RUN_BUTTON_ID = "run";
|
||||
private static final String PAUSE_BUTTON_ID = "pause";
|
||||
private static final String TRIGGER_NEXT_GROUP_BUTTON_ID = "triggerNextGroup";
|
||||
private static final String UPDATE_BUTTON_ID = "update";
|
||||
private static final String COPY_BUTTON_ID = "copy";
|
||||
private static final String DELETE_BUTTON_ID = "delete";
|
||||
@@ -226,6 +234,11 @@ public class RolloutGrid extends AbstractGrid<ProxyRollout, String> {
|
||||
return RolloutStatus.RUNNING == status;
|
||||
}
|
||||
|
||||
private static boolean isTriggerNextGroupAllowed(final ProxyRollout rollout) {
|
||||
final Long scheduled = rollout.getStatusTotalCountMap().get(TotalTargetCountStatus.Status.SCHEDULED);
|
||||
return RolloutStatus.RUNNING == rollout.getStatus() && scheduled != null && scheduled > 0;
|
||||
}
|
||||
|
||||
private static boolean isApprovingAllowed(final RolloutStatus status) {
|
||||
return RolloutStatus.WAITING_FOR_APPROVAL == status;
|
||||
}
|
||||
@@ -335,6 +348,15 @@ public class RolloutGrid extends AbstractGrid<ProxyRollout, String> {
|
||||
permissionChecker.hasRolloutHandlePermission() && isPausingAllowed(rollout.getStatus()));
|
||||
actionColumns.add(GridComponentBuilder.addIconColumn(this, pauseButton, PAUSE_BUTTON_ID, null));
|
||||
|
||||
final ValueProvider<ProxyRollout, Button> triggerNextGroupButton = rollout -> GridComponentBuilder
|
||||
.buildActionButton(i18n, clickEvent -> triggerNextRolloutGroup(rollout.getId(), rollout.getStatus()),
|
||||
VaadinIcons.STEP_FORWARD, UIMessageIdProvider.TOOLTIP_ROLLOUT_TRIGGER_NEXT_GROUP,
|
||||
SPUIStyleDefinitions.STATUS_ICON_NEUTRAL,
|
||||
UIComponentIdProvider.ROLLOUT_TRIGGER_NEXT_GROUP_BUTTON_ID + "." + rollout.getId(),
|
||||
permissionChecker.hasRolloutUpdatePermission() && isTriggerNextGroupAllowed(rollout));
|
||||
actionColumns.add(
|
||||
GridComponentBuilder.addIconColumn(this, triggerNextGroupButton, TRIGGER_NEXT_GROUP_BUTTON_ID, null));
|
||||
|
||||
final ValueProvider<ProxyRollout, Button> updateButton = rollout -> GridComponentBuilder.buildActionButton(i18n,
|
||||
clickEvent -> updateRollout(rollout), VaadinIcons.EDIT, UIMessageIdProvider.TOOLTIP_ROLLOUT_UPDATE,
|
||||
SPUIStyleDefinitions.STATUS_ICON_NEUTRAL,
|
||||
@@ -488,4 +510,30 @@ public class RolloutGrid extends AbstractGrid<ProxyRollout, String> {
|
||||
}
|
||||
return tooltipText.toString();
|
||||
}
|
||||
|
||||
private void triggerNextRolloutGroup(final Long rolloutId, final RolloutStatus rolloutStatus) {
|
||||
if (RolloutStatus.RUNNING != rolloutStatus) {
|
||||
uiNotification.displayValidationError(i18n.getMessage("message.rollout.trigger.next.group.not.running"));
|
||||
} else {
|
||||
final ConfirmationDialog triggerNextDialog = createTriggerNextGroupDialog(rolloutId);
|
||||
UI.getCurrent().addWindow(triggerNextDialog.getWindow());
|
||||
triggerNextDialog.getWindow().bringToFront();
|
||||
}
|
||||
}
|
||||
|
||||
private ConfirmationDialog createTriggerNextGroupDialog(final Long rolloutId) {
|
||||
final String caption = i18n.getMessage("caption.rollout.confirm.trigger.next");
|
||||
final String question = i18n.getMessage("message.rollout.confirm.trigger.next");
|
||||
return new ConfirmationDialog(i18n, caption, question, ok -> {
|
||||
if (Boolean.TRUE.equals(ok)) {
|
||||
try {
|
||||
rolloutManagement.triggerNextGroup(rolloutId);
|
||||
uiNotification.displaySuccess(i18n.getMessage("message.rollout.trigger.next.group.success"));
|
||||
} catch (final RolloutIllegalStateException e) {
|
||||
LOGGER.warn("Error on manually triggering next rollout group: {}", e.getMessage());
|
||||
uiNotification.displayValidationError(i18n.getMessage("message.rollout.trigger.next.group.error"));
|
||||
}
|
||||
}
|
||||
}, UIComponentIdProvider.ROLLOUT_TRIGGER_NEXT_CONFIRMATION_DIALOG);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1154,6 +1154,11 @@ public final class UIComponentIdProvider {
|
||||
*/
|
||||
public static final String ROLLOUT_PAUSE_BUTTON_ID = ROLLOUT_ACTION_ID + ".7";
|
||||
|
||||
/**
|
||||
* Rollout trigger next group button id.
|
||||
*/
|
||||
public static final String ROLLOUT_TRIGGER_NEXT_GROUP_BUTTON_ID = ROLLOUT_ACTION_ID + ".13";
|
||||
|
||||
/**
|
||||
* Rollout update button id.
|
||||
*/
|
||||
@@ -1465,6 +1470,11 @@ public final class UIComponentIdProvider {
|
||||
*/
|
||||
public static final String ROLLOUT_DELETE_CONFIRMATION_DIALOG = "rollout.delete.confirmation.window";
|
||||
|
||||
/**
|
||||
* Id of the rollout 'trigger next group' confirmation window
|
||||
*/
|
||||
public static final String ROLLOUT_TRIGGER_NEXT_CONFIRMATION_DIALOG = "rollout.triggernext.confirmation.window";
|
||||
|
||||
/**
|
||||
* Id of the target filter deletion confirmation window
|
||||
*/
|
||||
|
||||
@@ -351,6 +351,8 @@ public final class UIMessageIdProvider {
|
||||
|
||||
public static final String TOOLTIP_UPLOAD_STATUS_PREFIX = "tooltip.upload.status.";
|
||||
|
||||
public static final String TOOLTIP_ROLLOUT_TRIGGER_NEXT_GROUP = "tooltip.rollout.triggernextgroup";
|
||||
|
||||
/**
|
||||
* Private Constructor.
|
||||
*/
|
||||
|
||||
@@ -336,6 +336,7 @@ tooltip.active.action.status.inactiveerror=In-active Error
|
||||
tooltip.rollout.run = Run
|
||||
tooltip.rollout.approve = Approve
|
||||
tooltip.rollout.pause = Pause
|
||||
tooltip.rollout.triggernextgroup = Trigger next group
|
||||
tooltip.rollout.update = Edit..
|
||||
tooltip.rollout.copy = Copy..
|
||||
tooltip.delete = Delete..
|
||||
@@ -773,6 +774,9 @@ message.rollout.max.group.size.exceeded.advanced = The maximum size of {0} targe
|
||||
message.rollout.approval.required = You should approve or reject the Rollout
|
||||
message.rollout.started = Rollout {0} started successfully
|
||||
message.rollout.paused = Rollout {0} paused successfully
|
||||
message.rollout.trigger.next.group.not.running = Rollout is not in RUNNING state
|
||||
message.rollout.trigger.next.group.success = Next group successfully triggered
|
||||
message.rollout.trigger.next.group.error = Could not trigger next group
|
||||
message.rollout.resumed = Rollout {0} resumed successfully
|
||||
message.rollout.deleted = Rollout {0} deleted successfully
|
||||
message.rollout.noofgroups.or.targetfilter.missing = Please enter number of groups and select target filter
|
||||
@@ -808,6 +812,10 @@ caption.rollout.start.auto.desc = The rollout is started as soon as it is create
|
||||
caption.rollout.start.scheduled = Scheduled
|
||||
caption.rollout.start.scheduled.desc = The rollout starts as soon as it is ready and the set time has passed.
|
||||
label.rollout.calculating = Calculating groups ...
|
||||
|
||||
caption.rollout.confirm.trigger.next = Trigger next rollout group
|
||||
message.rollout.confirm.trigger.next = You are about to trigger the next rollout group.\nAre you sure?
|
||||
|
||||
#rollout - end
|
||||
|
||||
#Menu
|
||||
|
||||
Reference in New Issue
Block a user