Skip to content

Commit

Permalink
Add support for dynamic rollouts
Browse files Browse the repository at this point in the history
-- Current status --

Initial draft only !!!, to be improved

TODO:
 * evaluate the target count - if update group/rollout total count fails dynamic updates could (?), actually, contain more targets
 * is it needed to break handler on group creating?
 * if dynamic group schedulers occur to be heavy - maybe a handler per tenant will ensure that one tenant won't break all

*Concept for dynamic groups*:

Rollouts are static and dynamic.
Static rollouts consist of static groups only while dynamic rollouts have a number of static groups (first groups) and then an unlimited number of dynamic groups.

Group targets assignments:
* static groups include ALL matching targets created at the time the rollout was created, nevertheless they have active actions with bigger weight or not. Actions for the rollout and included targeets however are created at the start time.
* dynamic groups however are filled in when started and consider the action weight. The targets included in a dynamic group are:
  * matching (filter and distribution set compatible)
  * not included in this or following rollout static groups (if already included in any of the following rollouts - it's intended to be overridden)
  * not in active actions of any rollouts with equal or bigger weight

In general, when you create a rollout it contains all matching targets available at create time overriding any previous rollouts, actions, and so on. If the rollout is dynamic when its dynamic group becomes running it gets only matching targets that doesn't belong to static groups or have actions with great or equal weight

Signed-off-by: Marinov Avgustin <Avgustin.Marinov@bosch.com>
  • Loading branch information
avgustinmm committed Jan 12, 2024
1 parent ae47b1b commit 3f28484
Show file tree
Hide file tree
Showing 36 changed files with 862 additions and 132 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,7 @@ Slice<Target> findByTargetFilterQueryAndNonDSAndCompatibleAndUpdatable(@NotNull
* the pageRequest to enhance the query for paging and sorting
* @param groups
* the list of {@link RolloutGroup}s
* @param rsqlParam
* @param targetFilterQuery
* filter definition in RSQL syntax
* @param distributionSetType
* type of the {@link DistributionSet} the targets must be compatible
Expand All @@ -319,9 +319,17 @@ Slice<Target> findByTargetFilterQueryAndNonDSAndCompatibleAndUpdatable(@NotNull
*/
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_UPDATE_TARGET)
Slice<Target> findByTargetFilterQueryAndNotInRolloutGroupsAndCompatibleAndUpdatable(@NotNull Pageable pageRequest,
@NotEmpty Collection<Long> groups, @NotNull String rsqlParam,
@NotEmpty Collection<Long> groups, @NotNull String targetFilterQuery,
@NotNull DistributionSetType distributionSetType);

@PreAuthorize(SpringEvalExpressions.HAS_AUTH_UPDATE_TARGET)
Slice<Target> findByNotInGEGroupAndNotInActiveActionGEWeightOrInRolloutAndTargetFilterQueryAndCompatibleAndUpdatable(
@NotNull Pageable pageRequest, final long rolloutId, final int weight, final long firstGroupId, @NotNull String targetFilterQuery,
@NotNull DistributionSetType distributionSetType);

@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET)
long countByActionsInRolloutGroup(final long rolloutGroupId);

/**
* Finds all targets with failed actions for specific Rollout and that are not
* assigned to one of the retried {@link RolloutGroup}s and are compatible with
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,15 @@ RolloutCreate targetFilterQuery(
*/
RolloutCreate weight(Integer weight);

/**
* Set if the rollout shall be dynamic
*
* @param dynamic
* for {@link Rollout#isDynamic()}
* @return updated builder instance
*/
RolloutCreate dynamic(boolean dynamic);

/**
* set start
*
Expand All @@ -116,5 +125,4 @@ RolloutCreate targetFilterQuery(
* @return peek on current state of {@link Rollout} in the builder
*/
Rollout build();

}
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,11 @@ public interface Rollout extends NamedEntity {
*/
Optional<Integer> getWeight();

/**
* @return if the {@link Rollout} is dynamic.
*/
boolean isDynamic();

/**
* @return the stored access control context (if present)
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,11 @@ public interface RolloutGroup extends NamedEntity {
*/
RolloutGroup getParent();

/**
* @return if the group is dynamic
*/
boolean isDynamic();

/**
* @return the {@link RolloutGroupSuccessCondition} for this group to
* indicate when a group is successful
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

import java.util.Arrays;
import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;

import javax.validation.ValidationException;
Expand Down Expand Up @@ -229,9 +230,6 @@ public static String getGroupTargetFilter(final String baseFilter, final Rollout
if (StringUtils.isEmpty(group.getTargetFilterQuery())) {
return baseFilter;
}
if (isRolloutRetried(baseFilter)) {
return baseFilter;
}
return concatAndTargetFilters(baseFilter, group.getTargetFilterQuery());
}

Expand All @@ -257,6 +255,23 @@ public static void checkIfRolloutCanStarted(final Rollout rollout, final Rollout
}
}

public static double toPercentFromTheRest(final RolloutGroup group, List<? extends RolloutGroup> rolloutGroups) {
final double percentFromRest;
// assume that the groups are served orderly
double toServePercent = 100;
for (final RolloutGroup next : rolloutGroups) {
if (next == group) {
break;
}
if (Objects.equals(next.getTargetFilterQuery(), group.getTargetFilterQuery())) {
toServePercent -= next.getTargetPercentage();
}
}
percentFromRest =
toServePercent <= 1 ? 100 : Math.min(100, group.getTargetPercentage() * 100 / toServePercent);
return percentFromRest;
}

public static boolean isRolloutRetried(final String targetFilter) {
return targetFilter.contains("failedrollout");
}
Expand Down
Loading

0 comments on commit 3f28484

Please sign in to comment.