Semi automatic Rollouts with fine groups definition (#337)
* Rollout Mgmt API accepts now extended Group definition. Filling Reollout Groups with Targets is now a scheduled task. Signed-off-by: Dominik Herbst <dominik.herbst@bosch-si.com> * Fire RolloutGroupCreated event and fix db migration. Signed-off-by: Dominik Herbst <dominik.herbst@bosch-si.com> * Fill groups now excludes targets in own group Signed-off-by: Dominik Herbst <dominik.herbst@bosch-si.com> * Starting of Rollouts as scheduled task Signed-off-by: Dominik Herbst <dominik.herbst@bosch-si.com> * Finished implementation of new Rollout starting proccess Signed-off-by: Dominik Herbst <dominik.herbst@bosch-si.com> * Reset last check on status change and fixed unused imports Signed-off-by: Dominik Herbst <dominik.herbst@bosch-si.com> * Code quality improvements Signed-off-by: Dominik Herbst <dominik.herbst@bosch-si.com> * Reworked start of scheduled Actions. Improved code quality. Signed-off-by: Dominik Herbst <dominik.herbst@bosch-si.com>
This commit is contained in:
committed by
Michael Hirsch
parent
66b6983406
commit
b6834e9ee2
@@ -0,0 +1,60 @@
|
||||
/**
|
||||
* Copyright (c) 2015 Bosch Software Innovations GmbH and others.
|
||||
*
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*/
|
||||
package org.eclipse.hawkbit.mgmt.json.model.rollout;
|
||||
|
||||
import org.eclipse.hawkbit.mgmt.json.model.MgmtNamedEntity;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
|
||||
/**
|
||||
* Model for defining Conditions and Actions
|
||||
*/
|
||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||
public abstract class AbstractMgmtRolloutConditionsEntity extends MgmtNamedEntity {
|
||||
|
||||
private MgmtRolloutCondition successCondition;
|
||||
private MgmtRolloutSuccessAction successAction;
|
||||
private MgmtRolloutCondition errorCondition;
|
||||
private MgmtRolloutErrorAction errorAction;
|
||||
|
||||
public MgmtRolloutCondition getSuccessCondition() {
|
||||
return successCondition;
|
||||
}
|
||||
|
||||
public void setSuccessCondition(final MgmtRolloutCondition successCondition) {
|
||||
this.successCondition = successCondition;
|
||||
}
|
||||
|
||||
public MgmtRolloutSuccessAction getSuccessAction() {
|
||||
return successAction;
|
||||
}
|
||||
|
||||
public void setSuccessAction(final MgmtRolloutSuccessAction successAction) {
|
||||
this.successAction = successAction;
|
||||
}
|
||||
|
||||
public MgmtRolloutCondition getErrorCondition() {
|
||||
return errorCondition;
|
||||
}
|
||||
|
||||
public void setErrorCondition(final MgmtRolloutCondition errorCondition) {
|
||||
this.errorCondition = errorCondition;
|
||||
}
|
||||
|
||||
public MgmtRolloutErrorAction getErrorAction() {
|
||||
return errorAction;
|
||||
}
|
||||
|
||||
public void setErrorAction(final MgmtRolloutErrorAction errorAction) {
|
||||
this.errorAction = errorAction;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -13,14 +13,34 @@ import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import com.fasterxml.jackson.annotation.JsonInclude.Include;
|
||||
|
||||
/**
|
||||
*
|
||||
* An action that runs when the error condition is met
|
||||
*/
|
||||
@JsonInclude(Include.NON_NULL)
|
||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||
public class MgmtRolloutErrorAction {
|
||||
|
||||
private ErrorAction action = ErrorAction.PAUSE;
|
||||
private String expression = null;
|
||||
private String expression;
|
||||
|
||||
/**
|
||||
* Creates a rollout error action
|
||||
*
|
||||
* @param action
|
||||
* the action to run when th error condition is met
|
||||
* @param expression
|
||||
* the expression for the action
|
||||
*/
|
||||
public MgmtRolloutErrorAction(ErrorAction action, String expression) {
|
||||
this.action = action;
|
||||
this.expression = expression;
|
||||
}
|
||||
|
||||
/**
|
||||
* Default constructor
|
||||
*/
|
||||
public MgmtRolloutErrorAction() {
|
||||
// Instantiate default error action
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the action
|
||||
@@ -52,6 +72,9 @@ public class MgmtRolloutErrorAction {
|
||||
this.expression = expression;
|
||||
}
|
||||
|
||||
/**
|
||||
* Possible actions
|
||||
*/
|
||||
public enum ErrorAction {
|
||||
PAUSE;
|
||||
}
|
||||
|
||||
@@ -8,12 +8,14 @@
|
||||
*/
|
||||
package org.eclipse.hawkbit.mgmt.json.model.rollout;
|
||||
|
||||
import org.eclipse.hawkbit.mgmt.json.model.MgmtNamedEntity;
|
||||
import org.eclipse.hawkbit.mgmt.json.model.distributionset.MgmtActionType;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import com.fasterxml.jackson.annotation.JsonInclude.Include;
|
||||
import org.eclipse.hawkbit.mgmt.json.model.rolloutgroup.MgmtRolloutGroup;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Model for request containing a rollout body e.g. in a POST request of
|
||||
@@ -21,66 +23,18 @@ import com.fasterxml.jackson.annotation.JsonInclude.Include;
|
||||
*/
|
||||
@JsonInclude(Include.NON_NULL)
|
||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||
public class MgmtRolloutRestRequestBody extends MgmtNamedEntity {
|
||||
public class MgmtRolloutRestRequestBody extends AbstractMgmtRolloutConditionsEntity {
|
||||
|
||||
private String targetFilterQuery;
|
||||
private long distributionSetId;
|
||||
|
||||
private int amountGroups = 1;
|
||||
|
||||
private MgmtRolloutCondition successCondition = new MgmtRolloutCondition();
|
||||
private MgmtRolloutSuccessAction successAction = new MgmtRolloutSuccessAction();
|
||||
private MgmtRolloutCondition errorCondition = null;
|
||||
private MgmtRolloutErrorAction errorAction = null;
|
||||
private Integer amountGroups;
|
||||
|
||||
private Long forcetime;
|
||||
|
||||
private MgmtActionType type;
|
||||
|
||||
/**
|
||||
* @return the finishCondition
|
||||
*/
|
||||
public MgmtRolloutCondition getSuccessCondition() {
|
||||
return successCondition;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param successCondition
|
||||
* the finishCondition to set
|
||||
*/
|
||||
public void setSuccessCondition(final MgmtRolloutCondition successCondition) {
|
||||
this.successCondition = successCondition;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the successAction
|
||||
*/
|
||||
public MgmtRolloutSuccessAction getSuccessAction() {
|
||||
return successAction;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param successAction
|
||||
* the successAction to set
|
||||
*/
|
||||
public void setSuccessAction(final MgmtRolloutSuccessAction successAction) {
|
||||
this.successAction = successAction;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the errorCondition
|
||||
*/
|
||||
public MgmtRolloutCondition getErrorCondition() {
|
||||
return errorCondition;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param errorCondition
|
||||
* the errorCondition to set
|
||||
*/
|
||||
public void setErrorCondition(final MgmtRolloutCondition errorCondition) {
|
||||
this.errorCondition = errorCondition;
|
||||
}
|
||||
private List<MgmtRolloutGroup> groups;
|
||||
|
||||
/**
|
||||
* @return the targetFilterQuery
|
||||
@@ -115,7 +69,7 @@ public class MgmtRolloutRestRequestBody extends MgmtNamedEntity {
|
||||
/**
|
||||
* @return the groupSize
|
||||
*/
|
||||
public int getAmountGroups() {
|
||||
public Integer getAmountGroups() {
|
||||
return amountGroups;
|
||||
}
|
||||
|
||||
@@ -123,7 +77,7 @@ public class MgmtRolloutRestRequestBody extends MgmtNamedEntity {
|
||||
* @param groupSize
|
||||
* the groupSize to set
|
||||
*/
|
||||
public void setAmountGroups(final int groupSize) {
|
||||
public void setAmountGroups(final Integer groupSize) {
|
||||
this.amountGroups = groupSize;
|
||||
}
|
||||
|
||||
@@ -158,18 +112,16 @@ public class MgmtRolloutRestRequestBody extends MgmtNamedEntity {
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the errorAction
|
||||
* @return the List of defined Groups
|
||||
*/
|
||||
public MgmtRolloutErrorAction getErrorAction() {
|
||||
return errorAction;
|
||||
public List<MgmtRolloutGroup> getGroups() {
|
||||
return groups;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param errorAction
|
||||
* the errorAction to set
|
||||
* @param groups List of {@link MgmtRolloutGroup}
|
||||
*/
|
||||
public void setErrorAction(final MgmtRolloutErrorAction errorAction) {
|
||||
this.errorAction = errorAction;
|
||||
public void setGroups(List<MgmtRolloutGroup> groups) {
|
||||
this.groups = groups;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
/**
|
||||
* Copyright (c) 2015 Bosch Software Innovations GmbH and others.
|
||||
*
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*/
|
||||
package org.eclipse.hawkbit.mgmt.json.model.rolloutgroup;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import org.eclipse.hawkbit.mgmt.json.model.rollout.AbstractMgmtRolloutConditionsEntity;
|
||||
|
||||
/**
|
||||
* Model for defining the Attributes of a Rollout Group
|
||||
*/
|
||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||
public class MgmtRolloutGroup extends AbstractMgmtRolloutConditionsEntity {
|
||||
|
||||
private String targetFilterQuery;
|
||||
private Float targetPercentage;
|
||||
|
||||
public String getTargetFilterQuery() {
|
||||
return targetFilterQuery;
|
||||
}
|
||||
|
||||
public void setTargetFilterQuery(final String targetFilterQuery) {
|
||||
this.targetFilterQuery = targetFilterQuery;
|
||||
}
|
||||
|
||||
public Float getTargetPercentage() {
|
||||
return targetPercentage;
|
||||
}
|
||||
|
||||
public void setTargetPercentage(Float targetPercentage) {
|
||||
this.targetPercentage = targetPercentage;
|
||||
}
|
||||
}
|
||||
@@ -8,20 +8,21 @@
|
||||
*/
|
||||
package org.eclipse.hawkbit.mgmt.json.model.rolloutgroup;
|
||||
|
||||
import org.eclipse.hawkbit.mgmt.json.model.MgmtNamedEntity;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import com.fasterxml.jackson.annotation.JsonInclude.Include;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Model for the rollout group annotated with json-annotations for easier
|
||||
* serialization and de-serialization.
|
||||
*/
|
||||
@JsonInclude(Include.NON_NULL)
|
||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||
public class MgmtRolloutGroupResponseBody extends MgmtNamedEntity {
|
||||
public class MgmtRolloutGroupResponseBody extends MgmtRolloutGroup {
|
||||
|
||||
@JsonProperty(value = "id", required = true)
|
||||
private Long rolloutGroupId;
|
||||
@@ -29,6 +30,10 @@ public class MgmtRolloutGroupResponseBody extends MgmtNamedEntity {
|
||||
@JsonProperty(required = true)
|
||||
private String status;
|
||||
|
||||
private int totalTargets;
|
||||
|
||||
private final Map<String, Long> totalTargetsPerStatus = new HashMap<>();
|
||||
|
||||
/**
|
||||
* @return the rolloutGroupId
|
||||
*/
|
||||
@@ -58,4 +63,17 @@ public class MgmtRolloutGroupResponseBody extends MgmtNamedEntity {
|
||||
public void setStatus(final String status) {
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
public int getTotalTargets() {
|
||||
return totalTargets;
|
||||
}
|
||||
|
||||
public void setTotalTargets(int totalTargets) {
|
||||
this.totalTargets = totalTargets;
|
||||
}
|
||||
|
||||
public Map<String, Long> getTotalTargetsPerStatus() {
|
||||
return totalTargetsPerStatus;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -88,8 +88,7 @@ public interface MgmtRolloutRestApi {
|
||||
*/
|
||||
@RequestMapping(method = RequestMethod.POST, value = "/{rolloutId}/start", produces = { "application/hal+json",
|
||||
MediaType.APPLICATION_JSON_VALUE })
|
||||
ResponseEntity<Void> start(@PathVariable("rolloutId") final Long rolloutId,
|
||||
@RequestParam(value = MgmtRestConstants.REQUEST_PARAMETER_ASYNC, defaultValue = "false") final boolean startAsync);
|
||||
ResponseEntity<Void> start(@PathVariable("rolloutId") final Long rolloutId);
|
||||
|
||||
/**
|
||||
* Handles the POST request for pausing a rollout.
|
||||
|
||||
Reference in New Issue
Block a user