Skip to content

Commit

Permalink
Semi automatic Rollouts with fine groups definition (#337)
Browse files Browse the repository at this point in the history
* Rollout Mgmt API accepts now extended Group definition. Filling Reollout Groups with Targets is now a scheduled task.

Signed-off-by: Dominik Herbst <[email protected]>

* Fire RolloutGroupCreated event and fix db migration.

Signed-off-by: Dominik Herbst <[email protected]>

* Fill groups now excludes targets in own group

Signed-off-by: Dominik Herbst <[email protected]>

* Starting of Rollouts as scheduled task

Signed-off-by: Dominik Herbst <[email protected]>

* Finished implementation of new Rollout starting proccess

Signed-off-by: Dominik Herbst <[email protected]>

* Reset last check on status change and fixed unused imports

Signed-off-by: Dominik Herbst <[email protected]>

* Code quality improvements

Signed-off-by: Dominik Herbst <[email protected]>

* Reworked start of scheduled Actions. Improved code quality.

Signed-off-by: Dominik Herbst <[email protected]>
  • Loading branch information
dominikhb authored and michahirsch committed Nov 16, 2016
1 parent 66b6983 commit b6834e9
Show file tree
Hide file tree
Showing 37 changed files with 2,004 additions and 452 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ private void runRollout(final MgmtDistributionSet set, final Scenario scenario)
.getBody();

// start the created Rollout
rolloutResource.start(rolloutResponseBody.getRolloutId(), true);
rolloutResource.start(rolloutResponseBody.getRolloutId());

// wait until rollout is complete
do {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ public void run() {
.getBody();

// start the created Rollout
rolloutResource.start(rolloutResponseBody.getRolloutId(), false);
rolloutResource.start(rolloutResponseBody.getRolloutId());
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -164,15 +164,20 @@ public enum SpServerError {
/**
*
*/
SP_ROLLOUT_ILLEGAL_STATE("hawkbit.server.error.rollout.illegalstate", "The rollout is currently in the wrong state for the current operation");
SP_ROLLOUT_ILLEGAL_STATE("hawkbit.server.error.rollout.illegalstate", "The rollout is in the wrong state for the requested operation"),

/**
*
*/
SP_ROLLOUT_VERIFICATION_FAILED("hawkbit.server.error.rollout.verificationFailed", "The rollout configuration could not be verified successfully");

private final String key;
private final String message;

/*
* Repository side Error codes
*/
private SpServerError(final String errorKey, final String message) {
SpServerError(final String errorKey, final String message) {
key = errorKey;
this.message = message;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,14 @@ public enum TargetFields implements FieldNameProvider {
* The description field.
*/
DESCRIPTION("description"),
/**
* The createdAt field.
*/
CREATEDAT("createdAt"),
/**
* The createdAt field.
*/
LASTMODIFIEDAT("lastModifiedAt"),
/**
* The controllerId field.
*/
Expand Down Expand Up @@ -75,19 +83,19 @@ public enum TargetFields implements FieldNameProvider {
private List<String> subEntityAttribues;
private boolean mapField;

private TargetFields(final String fieldName) {
TargetFields(final String fieldName) {
this(fieldName, false, Collections.emptyList());
}

private TargetFields(final String fieldName, final boolean isMapField) {
TargetFields(final String fieldName, final boolean isMapField) {
this(fieldName, isMapField, Collections.emptyList());
}

private TargetFields(final String fieldName, final String... subEntityAttribues) {
TargetFields(final String fieldName, final String... subEntityAttribues) {
this(fieldName, false, Arrays.asList(subEntityAttribues));
}

private TargetFields(final String fieldName, final boolean mapField, final List<String> subEntityAttribues) {
TargetFields(final String fieldName, final boolean mapField, final List<String> subEntityAttribues) {
this.fieldName = fieldName;
this.mapField = mapField;
this.subEntityAttribues = subEntityAttribues;
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,34 @@
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
Expand Down Expand Up @@ -52,6 +72,9 @@ public void setExpression(final String expression) {
this.expression = expression;
}

/**
* Possible actions
*/
public enum ErrorAction {
PAUSE;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,79 +8,33 @@
*/
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
* creating a rollout via REST API.
*/
@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
Expand Down Expand Up @@ -115,15 +69,15 @@ public void setDistributionSetId(final long distributionSetId) {
/**
* @return the groupSize
*/
public int getAmountGroups() {
public Integer getAmountGroups() {
return amountGroups;
}

/**
* @param groupSize
* the groupSize to set
*/
public void setAmountGroups(final int groupSize) {
public void setAmountGroups(final Integer groupSize) {
this.amountGroups = groupSize;
}

Expand Down Expand Up @@ -158,18 +112,16 @@ public void setType(final MgmtActionType type) {
}

/**
* @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;
}

}
Original file line number Diff line number Diff line change
@@ -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;
}
}
Loading

0 comments on commit b6834e9

Please sign in to comment.