Prioritisation of assignments via mgmt-API (#895)
* Updating the schema for targetfilterquery and rollout * Updating the weight validation logic and tests * Make weight optional * Fix existing multi assignment tests by adding weight, remove weight from TargetFilterQuery * Add weight validation tests, fix tests * Add mgmt api tests for assignment and getting action with weight * Add management layer validation and tests for creating rollouts with weight * Fix amqp test, add repo level validation to resource tests * Add weight to rollout mgmt-api and tests * Add weight to mgmt api target Filter create and update * Add target filter auto assign weight. disable enforcement of setting a weight in multiassign mode * Remove ignored tests, fix api doc * Fix minor findings * Fix findings * Remove hardcoded min weight * Add docu text, fix findings * Fix api documentation * Expose weight via DMF * Expose actions according to weight via ddi * Fix documentation * Add method to get actions ordered by weight to deploymentManagement * Updating the schema for targetfilterquery and rollout * Updated the indentation * Updated the helper class, fixed the randomUID in test factory * Updated the class name with prefix JPA * Adding the missing License for WeightValidationHelper class * Adding documentation to the dmf api on weight * Removed the merger markers * Updated the class name * Removed the redundant method * Addressed final PR comments * Updated the missing testcase with latest default weight value * Reverting the default value of weight back to 1000 and updated tests Signed-off-by: Shruthi Manavalli Ramanna <shruthimanavalli.ramanna@bosch-si.com> Signed-off-by: Stefan Klotz <stefan.klotz@bosch-si.com>
This commit is contained in:
committed by
Stefan Behl
parent
09f2d8a481
commit
9cb5d31396
@@ -20,6 +20,7 @@ import org.eclipse.hawkbit.repository.builder.RolloutGroupCreate;
|
||||
import org.eclipse.hawkbit.repository.model.RolloutGroup;
|
||||
import org.eclipse.hawkbit.repository.model.RolloutGroupsValidation;
|
||||
import org.eclipse.hawkbit.repository.rsql.VirtualPropertyReplacer;
|
||||
import org.eclipse.hawkbit.security.SystemSecurityContext;
|
||||
import org.eclipse.hawkbit.tenancy.TenantAware;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.integration.support.locks.LockRegistry;
|
||||
@@ -54,12 +55,18 @@ public abstract class AbstractRolloutManagement implements RolloutManagement {
|
||||
|
||||
protected final RolloutApprovalStrategy rolloutApprovalStrategy;
|
||||
|
||||
protected final TenantConfigurationManagement tenantConfigurationManagement;
|
||||
|
||||
protected final SystemSecurityContext systemSecurityContext;
|
||||
|
||||
protected AbstractRolloutManagement(final TargetManagement targetManagement,
|
||||
final DeploymentManagement deploymentManagement, final RolloutGroupManagement rolloutGroupManagement,
|
||||
final DistributionSetManagement distributionSetManagement, final ApplicationContext context,
|
||||
final VirtualPropertyReplacer virtualPropertyReplacer, final PlatformTransactionManager txManager,
|
||||
final TenantAware tenantAware, final LockRegistry lockRegistry,
|
||||
final RolloutApprovalStrategy rolloutApprovalStrategy) {
|
||||
final RolloutApprovalStrategy rolloutApprovalStrategy,
|
||||
final TenantConfigurationManagement tenantConfigurationManagement,
|
||||
final SystemSecurityContext systemSecurityContext) {
|
||||
this.targetManagement = targetManagement;
|
||||
this.deploymentManagement = deploymentManagement;
|
||||
this.rolloutGroupManagement = rolloutGroupManagement;
|
||||
@@ -70,6 +77,8 @@ public abstract class AbstractRolloutManagement implements RolloutManagement {
|
||||
this.tenantAware = tenantAware;
|
||||
this.lockRegistry = lockRegistry;
|
||||
this.rolloutApprovalStrategy = rolloutApprovalStrategy;
|
||||
this.tenantConfigurationManagement = tenantConfigurationManagement;
|
||||
this.systemSecurityContext = systemSecurityContext;
|
||||
}
|
||||
|
||||
protected RolloutGroupsValidation validateTargetsInGroups(final List<RolloutGroup> groups, final String baseFilter,
|
||||
@@ -156,5 +165,4 @@ public abstract class AbstractRolloutManagement implements RolloutManagement {
|
||||
return new AsyncResult<>(validateTargetsInGroups(
|
||||
groups.stream().map(RolloutGroupCreate::build).collect(Collectors.toList()), baseFilter, totalTargets));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -10,8 +10,13 @@ package org.eclipse.hawkbit.repository.builder;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
import javax.validation.constraints.Max;
|
||||
import javax.validation.constraints.Min;
|
||||
|
||||
import org.eclipse.hawkbit.repository.ValidString;
|
||||
import org.eclipse.hawkbit.repository.model.Action;
|
||||
import org.eclipse.hawkbit.repository.model.Action.ActionType;
|
||||
import org.eclipse.hawkbit.repository.model.DistributionSet;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
/**
|
||||
@@ -30,26 +35,77 @@ public abstract class AbstractRolloutUpdateCreate<T> extends AbstractNamedEntity
|
||||
protected Long forcedTime;
|
||||
protected Long startAt;
|
||||
|
||||
@Min(Action.WEIGHT_MIN)
|
||||
@Max(Action.WEIGHT_MAX)
|
||||
protected Integer weight;
|
||||
|
||||
/**
|
||||
* {@link DistributionSet} of rollout
|
||||
*
|
||||
* @param set
|
||||
* ID of the set
|
||||
* @return this builder
|
||||
*/
|
||||
public T set(final long set) {
|
||||
this.set = set;
|
||||
return (T) this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Filter of the rollout
|
||||
*
|
||||
* @param targetFilterQuery
|
||||
* query
|
||||
* @return this builder
|
||||
*/
|
||||
public T targetFilterQuery(final String targetFilterQuery) {
|
||||
this.targetFilterQuery = StringUtils.trimWhitespace(targetFilterQuery);
|
||||
return (T) this;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@link ActionType} used for {@link Action}s
|
||||
*
|
||||
* @param actionType
|
||||
* type
|
||||
* @return this builder
|
||||
*/
|
||||
public T actionType(final ActionType actionType) {
|
||||
this.actionType = actionType;
|
||||
return (T) this;
|
||||
}
|
||||
|
||||
/**
|
||||
* forcedTime used for {@link Action}s
|
||||
*
|
||||
* @param forcedTime
|
||||
* time
|
||||
* @return this builder
|
||||
*/
|
||||
public T forcedTime(final Long forcedTime) {
|
||||
this.forcedTime = forcedTime;
|
||||
return (T) this;
|
||||
}
|
||||
|
||||
/**
|
||||
* weight used for {@link Action}s
|
||||
*
|
||||
* @param weight
|
||||
* weight
|
||||
* @return this builder
|
||||
*/
|
||||
public T weight(final Integer weight) {
|
||||
this.weight = weight;
|
||||
return (T) this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set start of the Rollout
|
||||
*
|
||||
* @param startAt
|
||||
* start time point
|
||||
* @return this builder
|
||||
*/
|
||||
public T startAt(final Long startAt) {
|
||||
this.startAt = startAt;
|
||||
return (T) this;
|
||||
@@ -67,6 +123,10 @@ public abstract class AbstractRolloutUpdateCreate<T> extends AbstractNamedEntity
|
||||
return Optional.ofNullable(forcedTime);
|
||||
}
|
||||
|
||||
public Optional<Integer> getWeight() {
|
||||
return Optional.ofNullable(weight);
|
||||
}
|
||||
|
||||
public Optional<Long> getStartAt() {
|
||||
return Optional.ofNullable(startAt);
|
||||
}
|
||||
|
||||
@@ -10,8 +10,13 @@ package org.eclipse.hawkbit.repository.builder;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
import javax.validation.constraints.Max;
|
||||
import javax.validation.constraints.Min;
|
||||
|
||||
import org.eclipse.hawkbit.repository.ValidString;
|
||||
import org.eclipse.hawkbit.repository.model.Action;
|
||||
import org.eclipse.hawkbit.repository.model.Action.ActionType;
|
||||
import org.eclipse.hawkbit.repository.model.TargetFilterQuery;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
/**
|
||||
@@ -31,6 +36,17 @@ public abstract class AbstractTargetFilterQueryUpdateCreate<T> extends AbstractB
|
||||
|
||||
protected ActionType actionType;
|
||||
|
||||
@Min(Action.WEIGHT_MIN)
|
||||
@Max(Action.WEIGHT_MAX)
|
||||
protected Integer weight;
|
||||
|
||||
/**
|
||||
* Set DS ID of the {@link Action} created during auto assignment
|
||||
*
|
||||
* @param distributionSetId
|
||||
* of the {@link TargetFilterQuery}
|
||||
* @return this builder
|
||||
*/
|
||||
public T autoAssignDistributionSet(final Long distributionSetId) {
|
||||
this.distributionSetId = distributionSetId;
|
||||
return (T) this;
|
||||
@@ -40,15 +56,46 @@ public abstract class AbstractTargetFilterQueryUpdateCreate<T> extends AbstractB
|
||||
return Optional.ofNullable(distributionSetId);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set {@link ActionType} of the {@link Action} created during auto
|
||||
* assignment
|
||||
*
|
||||
* @param actionType
|
||||
* of the {@link TargetFilterQuery}
|
||||
* @return this builder
|
||||
*/
|
||||
public T autoAssignActionType(final ActionType actionType) {
|
||||
this.actionType = actionType;
|
||||
return (T) this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set weight of the {@link Action} created during auto assignment
|
||||
*
|
||||
* @param weight
|
||||
* of the {@link TargetFilterQuery}
|
||||
* @return this builder
|
||||
*/
|
||||
public T autoAssignWeight(final Integer weight) {
|
||||
this.weight = weight;
|
||||
return (T) this;
|
||||
}
|
||||
|
||||
public Optional<Integer> getAutoAssignWeight() {
|
||||
return Optional.ofNullable(weight);
|
||||
}
|
||||
|
||||
public Optional<ActionType> getAutoAssignActionType() {
|
||||
return Optional.ofNullable(actionType);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set name of the filter
|
||||
*
|
||||
* @param name
|
||||
* of the {@link TargetFilterQuery}
|
||||
* @return this builder
|
||||
*/
|
||||
public T name(final String name) {
|
||||
this.name = StringUtils.trimWhitespace(name);
|
||||
return (T) this;
|
||||
@@ -58,6 +105,13 @@ public abstract class AbstractTargetFilterQueryUpdateCreate<T> extends AbstractB
|
||||
return Optional.ofNullable(name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set query used by the filter
|
||||
*
|
||||
* @param query
|
||||
* of the {@link TargetFilterQuery}
|
||||
* @return this builder
|
||||
*/
|
||||
public T query(final String query) {
|
||||
this.query = StringUtils.trimWhitespace(query);
|
||||
return (T) this;
|
||||
|
||||
@@ -16,5 +16,4 @@ public class GenericRolloutUpdate extends AbstractRolloutUpdateCreate<RolloutUpd
|
||||
public GenericRolloutUpdate(final Long id) {
|
||||
super.id = id;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user