Add support for dynamic rollout group template (#1752)
1. Add support in REST and Mgmt API for dynamic group template 2. If present - groups follows the pattern of this template, otherwise - the last static group 3. This allows to create pure dynamic rollout with 0 static groups - auto assignment equivalent with groups Signed-off-by: Marinov Avgustin <Avgustin.Marinov@bosch.com>
This commit is contained in:
@@ -18,6 +18,7 @@ import jakarta.validation.constraints.NotEmpty;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
|
||||
import org.eclipse.hawkbit.im.authentication.SpPermission.SpringEvalExpressions;
|
||||
import org.eclipse.hawkbit.repository.builder.DynamicRolloutGroupTemplate;
|
||||
import org.eclipse.hawkbit.repository.builder.RolloutCreate;
|
||||
import org.eclipse.hawkbit.repository.builder.RolloutGroupCreate;
|
||||
import org.eclipse.hawkbit.repository.builder.RolloutUpdate;
|
||||
@@ -78,6 +79,45 @@ public interface RolloutManagement {
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_ROLLOUT_MANAGEMENT_READ)
|
||||
long countByDistributionSetIdAndRolloutIsStoppable(long setId);
|
||||
|
||||
/**
|
||||
* Persists a new rollout entity. The filter within the
|
||||
* {@link Rollout#getTargetFilterQuery()} is used to retrieve the targets which
|
||||
* are effected by this rollout to create. The amount of groups will be defined
|
||||
* as equally sized.
|
||||
*
|
||||
* The rollout is not started. Only the preparation of the rollout is done,
|
||||
* creating and persisting all the necessary groups. The Rollout and the groups
|
||||
* are persisted in {@link RolloutStatus#CREATING} and
|
||||
* {@link RolloutGroupStatus#CREATING}.
|
||||
*
|
||||
* The RolloutScheduler will start to assign targets to the groups. Once all
|
||||
* targets have been assigned to the groups, the rollout status is changed to
|
||||
* {@link RolloutStatus#READY} so it can be started with .
|
||||
*
|
||||
* @param create
|
||||
* the rollout entity to create
|
||||
* @param amountGroup
|
||||
* the amount of groups to split the rollout into
|
||||
* @param confirmationRequired
|
||||
* if a confirmation is required by the device group(s) of the rollout
|
||||
* @param conditions
|
||||
* the rolloutgroup conditions and actions which should be applied
|
||||
* for each {@link RolloutGroup}
|
||||
* @param dynamicRolloutGroupTemplate the template for dynamic rollout groups
|
||||
* @return the persisted rollout.
|
||||
*
|
||||
* @throws EntityNotFoundException
|
||||
* if given {@link DistributionSet} does not exist
|
||||
* @throws ConstraintViolationException
|
||||
* if rollout or group parameters are invalid.
|
||||
* @throws AssignmentQuotaExceededException
|
||||
* if the maximum number of allowed targets per rollout group is
|
||||
* exceeded.
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_ROLLOUT_MANAGEMENT_CREATE)
|
||||
Rollout create(@NotNull @Valid RolloutCreate create, int amountGroup, boolean confirmationRequired,
|
||||
@NotNull RolloutGroupConditions conditions, DynamicRolloutGroupTemplate dynamicRolloutGroupTemplate);
|
||||
|
||||
/**
|
||||
* Persists a new rollout entity. The filter within the
|
||||
* {@link Rollout#getTargetFilterQuery()} is used to retrieve the targets which
|
||||
@@ -130,7 +170,7 @@ public interface RolloutManagement {
|
||||
* The RolloutScheduler will start to assign targets to the groups. Once all
|
||||
* targets have been assigned to the groups, the rollout status is changed to
|
||||
* {@link RolloutStatus#READY} so it can be started with
|
||||
* {@link #start(Rollout)}.
|
||||
* {@link #start(long)}.
|
||||
*
|
||||
* @param rollout
|
||||
* the rollout entity to create
|
||||
@@ -274,8 +314,6 @@ public interface RolloutManagement {
|
||||
*
|
||||
* @param rolloutId
|
||||
* rollout id
|
||||
* @param deleted
|
||||
* flag if deleted rollouts should be included
|
||||
* @return rollout details of targets count for different statuses
|
||||
*
|
||||
*
|
||||
|
||||
@@ -0,0 +1,44 @@
|
||||
/**
|
||||
* Copyright (c) 2024 Contributors to the Eclipse Foundation
|
||||
*
|
||||
* This program and the accompanying materials are made
|
||||
* available under the terms of the Eclipse Public License 2.0
|
||||
* which is available at https://www.eclipse.org/legal/epl-2.0/
|
||||
*
|
||||
* SPDX-License-Identifier: EPL-2.0
|
||||
*/
|
||||
package org.eclipse.hawkbit.repository.builder;
|
||||
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import org.eclipse.hawkbit.repository.model.RolloutGroupConditions;
|
||||
|
||||
/**
|
||||
* Builder to create a new dynamic rollout group secret
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
public class DynamicRolloutGroupTemplate {
|
||||
|
||||
/**
|
||||
* The name suffix, by default "" is used.
|
||||
*/
|
||||
@NotNull
|
||||
private String nameSuffix = "";
|
||||
|
||||
/**
|
||||
* The count of matching Targets that should be assigned to this Group
|
||||
*/
|
||||
private long targetCount;
|
||||
|
||||
/**
|
||||
* The group conditions
|
||||
*/
|
||||
private RolloutGroupConditions conditions;
|
||||
|
||||
/**
|
||||
* If confirmation is required for this rollout group (considered with confirmation flow active)
|
||||
*/
|
||||
private boolean confirmationRequired;
|
||||
}
|
||||
@@ -13,7 +13,6 @@ import org.eclipse.hawkbit.repository.model.Rollout;
|
||||
|
||||
/**
|
||||
* Builder for {@link Rollout}.
|
||||
*
|
||||
*/
|
||||
@FunctionalInterface
|
||||
public interface RolloutGroupBuilder {
|
||||
@@ -22,5 +21,4 @@ public interface RolloutGroupBuilder {
|
||||
* @return builder instance
|
||||
*/
|
||||
RolloutGroupCreate create();
|
||||
|
||||
}
|
||||
}
|
||||
@@ -24,49 +24,41 @@ import org.eclipse.hawkbit.repository.model.TargetFilterQuery;
|
||||
* Builder to create a new {@link RolloutGroup} entry. Defines all fields that
|
||||
* can be set at creation time. Other fields are set by the repository
|
||||
* automatically, e.g. {@link BaseEntity#getCreatedAt()}.
|
||||
*
|
||||
*/
|
||||
public interface RolloutGroupCreate {
|
||||
/**
|
||||
* @param name
|
||||
* for {@link Rollout#getName()}
|
||||
* @param name for {@link Rollout#getName()}
|
||||
* @return updated builder instance
|
||||
*/
|
||||
RolloutGroupCreate name(@Size(min = 1, max = NamedEntity.NAME_MAX_SIZE) @NotNull String name);
|
||||
|
||||
/**
|
||||
* @param description
|
||||
* for {@link Rollout#getDescription()}
|
||||
* @param description for {@link Rollout#getDescription()}
|
||||
* @return updated builder instance
|
||||
*/
|
||||
RolloutGroupCreate description(@Size(max = NamedEntity.DESCRIPTION_MAX_SIZE) String description);
|
||||
|
||||
/**
|
||||
* @param targetFilterQuery
|
||||
* for {@link Rollout#getTargetFilterQuery()}
|
||||
* @param targetFilterQuery for {@link Rollout#getTargetFilterQuery()}
|
||||
* @return updated builder instance
|
||||
*/
|
||||
RolloutGroupCreate targetFilterQuery(
|
||||
@Size(min = 1, max = TargetFilterQuery.QUERY_MAX_SIZE) @NotNull String targetFilterQuery);
|
||||
|
||||
/**
|
||||
* @param targetPercentage
|
||||
* the percentage of matching Targets that should be assigned to
|
||||
* this Group
|
||||
* @param targetPercentage the percentage of matching Targets that should be assigned to this Group
|
||||
* @return updated builder instance
|
||||
*/
|
||||
RolloutGroupCreate targetPercentage(Float targetPercentage);
|
||||
|
||||
/**
|
||||
* @param conditions
|
||||
* as created by {@link RolloutGroupConditionBuilder}.
|
||||
* @param conditions as created by {@link RolloutGroupConditionBuilder}.
|
||||
* @return updated builder instance
|
||||
*/
|
||||
RolloutGroupCreate conditions(RolloutGroupConditions conditions);
|
||||
|
||||
/**
|
||||
* @param confirmationRequired
|
||||
* if confirmation is required for this rollout group (considered
|
||||
* @param confirmationRequired if confirmation is required for this rollout group (considered
|
||||
* with confirmation flow active)
|
||||
* @return updated builder instance
|
||||
*/
|
||||
@@ -76,5 +68,4 @@ public interface RolloutGroupCreate {
|
||||
* @return peek on current state of {@link RolloutGroup} in the builder
|
||||
*/
|
||||
RolloutGroup build();
|
||||
|
||||
}
|
||||
}
|
||||
@@ -12,15 +12,12 @@ package org.eclipse.hawkbit.repository.builder;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import jakarta.validation.constraints.Size;
|
||||
|
||||
import org.eclipse.hawkbit.repository.model.Action;
|
||||
import org.eclipse.hawkbit.repository.model.DistributionSet;
|
||||
import org.eclipse.hawkbit.repository.model.NamedEntity;
|
||||
import org.eclipse.hawkbit.repository.model.Rollout;
|
||||
|
||||
/**
|
||||
* Builder to update an existing {@link Rollout} entry. Defines all fields that
|
||||
* can be updated.
|
||||
*
|
||||
*/
|
||||
public interface RolloutUpdate {
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user