Skip to content

Commit

Permalink
Remove unused TargetWithActionStatus and its retrieval methods
Browse files Browse the repository at this point in the history
Signed-off-by: Avgustin Marinov <[email protected]>
  • Loading branch information
avgustinmm committed Dec 11, 2024
1 parent d8c8e80 commit e68f889
Show file tree
Hide file tree
Showing 13 changed files with 114 additions and 413 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -220,16 +220,16 @@ public ResponseEntity<PagedList<MgmtRolloutGroupResponseBody>> getRolloutGroups(
final Page<RolloutGroup> rolloutGroups;
if (rsqlParam != null) {
if (isFullMode) {
rolloutGroups = this.rolloutGroupManagement.findByRolloutAndRsqlWithDetailedStatus(pageable,
rolloutId, rsqlParam);
rolloutGroups = this.rolloutGroupManagement.findByRolloutAndRsqlWithDetailedStatus(rolloutId, rsqlParam, pageable
);
} else {
rolloutGroups = this.rolloutGroupManagement.findByRolloutAndRsql(pageable, rolloutId, rsqlParam);
rolloutGroups = this.rolloutGroupManagement.findByRolloutAndRsql(rolloutId, rsqlParam, pageable);
}
} else {
if (isFullMode) {
rolloutGroups = this.rolloutGroupManagement.findByRolloutWithDetailedStatus(pageable, rolloutId);
rolloutGroups = this.rolloutGroupManagement.findByRolloutWithDetailedStatus(rolloutId, pageable);
} else {
rolloutGroups = this.rolloutGroupManagement.findByRollout(pageable, rolloutId);
rolloutGroups = this.rolloutGroupManagement.findByRollout(rolloutId, pageable);
}
}

Expand Down Expand Up @@ -269,7 +269,7 @@ public ResponseEntity<PagedList<MgmtTarget>> getRolloutGroupTargets(
rolloutGroupTargets = this.rolloutGroupManagement.findTargetsOfRolloutGroupByRsql(pageable, groupId,
rsqlParam);
} else {
final Page<Target> pageTargets = this.rolloutGroupManagement.findTargetsOfRolloutGroup(pageable, groupId);
final Page<Target> pageTargets = this.rolloutGroupManagement.findTargetsOfRolloutGroup(groupId, pageable);
rolloutGroupTargets = pageTargets;
}
final List<MgmtTarget> rest = MgmtTargetMapper.toResponse(rolloutGroupTargets.getContent(), tenantConfigHelper);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ public void getRolloutDeployGroupTargetsWithParameters() throws Exception {
final DistributionSet dsA = testdataFactory.createDistributionSet("");
final Rollout rollout = createRollout("rollout1", 2, dsA.getId(), "controllerId==rollout*");
final RolloutGroup firstRolloutGroup = rolloutGroupManagement
.findByRollout(PageRequest.of(0, 1), rollout.getId()).getContent().get(0);
.findByRollout(rollout.getId(), PageRequest.of(0, 1)).getContent().get(0);

mvc.perform(get(MgmtRestConstants.ROLLOUT_V1_REQUEST_MAPPING + "/{rolloutId}/deploygroups/{deployGroupId}/targets",
rollout.getId(), firstRolloutGroup.getId()).param("offset", "0").param("limit", "2")
Expand Down Expand Up @@ -485,10 +485,10 @@ void createDynamicRolloutWithDefaultDynamicGroupDefinition() throws Exception {

rolloutHandler.handleAll();

final List<RolloutGroup> groups = rolloutGroupManagement.findByRollout(PAGE, rollout.getId()).getContent();
final List<RolloutGroup> groups = rolloutGroupManagement.findByRollout(rollout.getId(), PAGE).getContent();
groups.forEach(group -> {
if (!group.isDynamic()) {
rolloutGroupManagement.findTargetsOfRolloutGroup(PAGE, group.getId())
rolloutGroupManagement.findTargetsOfRolloutGroup(group.getId(), PAGE)
.forEach(target -> deploymentManagement.findActionsByTarget(target.getControllerId(), PAGE)
.forEach(action -> {
deploymentManagement.cancelAction(action.getId());
Expand Down Expand Up @@ -768,7 +768,7 @@ void verifyConfirmationStateIfNotProvided(final boolean confirmationFlowActive)

final List<Rollout> content = rolloutManagement.findAll(PAGE, false).getContent();
assertThat(content).hasSizeGreaterThan(0).allSatisfy(rollout -> {
assertThat(rolloutGroupManagement.findByRollout(PAGE, rollout.getId()))
assertThat(rolloutGroupManagement.findByRollout(rollout.getId(), PAGE))
.describedAs("Confirmation required flag depends on feature active.")
.allMatch(group -> group.isConfirmationRequired() == confirmationFlowActive);
});
Expand Down Expand Up @@ -805,7 +805,7 @@ void verifyRolloutGroupWillUseRolloutPropertyFirst() throws Exception {

final List<Rollout> content = rolloutManagement.findAll(PAGE, false).getContent();
assertThat(content).hasSize(1).allSatisfy(rollout -> {
final List<RolloutGroup> groups = rolloutGroupManagement.findByRollout(PAGE, rollout.getId()).getContent();
final List<RolloutGroup> groups = rolloutGroupManagement.findByRollout(rollout.getId(), PAGE).getContent();
assertThat(groups).hasSize(2).allMatch(group -> {
if (group.getName().equals("Group1")) {
return group.isConfirmationRequired();
Expand Down Expand Up @@ -848,7 +848,7 @@ void verifyRolloutGroupWillUseConfigIfNotProvidedWithRollout() throws Exception

final List<Rollout> content = rolloutManagement.findAll(PAGE, false).getContent();
assertThat(content).hasSize(1).allSatisfy(rollout -> {
final List<RolloutGroup> groups = rolloutGroupManagement.findByRollout(PAGE, rollout.getId()).getContent();
final List<RolloutGroup> groups = rolloutGroupManagement.findByRollout(rollout.getId(), PAGE).getContent();
assertThat(groups).hasSize(2).allMatch(group -> {
if (group.getName().equals("Group1")) {
return !group.isConfirmationRequired();
Expand Down Expand Up @@ -1026,7 +1026,7 @@ void deployGroupsShouldValidateRelationWithRollout() throws Exception {
rolloutHandler.handleAll();

final RolloutGroup firstGroup = rolloutGroupManagement
.findByRollout(PageRequest.of(0, 1, Direction.ASC, "id"), rollout1.getId()).getContent().get(0);
.findByRollout(rollout1.getId(), PageRequest.of(0, 1, Direction.ASC, "id")).getContent().get(0);

// make request for firstGroupId and the rolloutId of the second rollout (the one with no groups)
mvc.perform(get("/rest/v1/rollouts/{rolloutId}/deploygroups/{groupId}", rollout2.getId(), firstGroup.getId())
Expand Down Expand Up @@ -1240,9 +1240,9 @@ void retrieveSingleRolloutGroup(final boolean confirmationFlowEnabled, final boo
.successCondition(RolloutGroupSuccessCondition.THRESHOLD, "100").build());

final RolloutGroup firstGroup = rolloutGroupManagement
.findByRollout(PageRequest.of(0, 1, Direction.ASC, "id"), rollout.getId()).getContent().get(0);
.findByRollout(rollout.getId(), PageRequest.of(0, 1, Direction.ASC, "id")).getContent().get(0);
final RolloutGroup secondGroup = rolloutGroupManagement
.findByRollout(PageRequest.of(1, 1, Direction.ASC, "id"), rollout.getId()).getContent().get(0);
.findByRollout(rollout.getId(), PageRequest.of(1, 1, Direction.ASC, "id")).getContent().get(0);

retrieveAndVerifyRolloutGroupInCreating(rollout, firstGroup);
retrieveAndVerifyRolloutGroupInReady(rollout, firstGroup);
Expand All @@ -1262,7 +1262,7 @@ void retrieveTargetsFromRolloutGroup() throws Exception {
final Rollout rollout = createRollout("rollout1", 2, dsA.getId(), "controllerId==rollout*");

final RolloutGroup firstGroup = rolloutGroupManagement
.findByRollout(PageRequest.of(0, 1, Direction.ASC, "id"), rollout.getId()).getContent().get(0);
.findByRollout(rollout.getId(), PageRequest.of(0, 1, Direction.ASC, "id")).getContent().get(0);

// retrieve targets from the first rollout group with known ID
mvc.perform(
Expand All @@ -1287,9 +1287,9 @@ void retrieveTargetsFromRolloutGroupWithQuery() throws Exception {
final Rollout rollout = createRollout("rollout1", 2, dsA.getId(), "controllerId==rollout*");

final RolloutGroup firstGroup = rolloutGroupManagement
.findByRollout(PageRequest.of(0, 1, Direction.ASC, "id"), rollout.getId()).getContent().get(0);
.findByRollout(rollout.getId(), PageRequest.of(0, 1, Direction.ASC, "id")).getContent().get(0);

final String targetInGroup = rolloutGroupManagement.findTargetsOfRolloutGroup(PAGE, firstGroup.getId())
final String targetInGroup = rolloutGroupManagement.findTargetsOfRolloutGroup(firstGroup.getId(), PAGE)
.getContent().get(0).getControllerId();

// retrieve targets from the first rollout group with known ID
Expand Down Expand Up @@ -1320,7 +1320,7 @@ void retrieveTargetsFromRolloutGroupAfterRolloutIsStarted() throws Exception {
rolloutHandler.handleAll();

final RolloutGroup firstGroup = rolloutGroupManagement
.findByRollout(PageRequest.of(0, 1, Direction.ASC, "id"), rollout.getId()).getContent().get(0);
.findByRollout(rollout.getId(), PageRequest.of(0, 1, Direction.ASC, "id")).getContent().get(0);

// retrieve targets from the first rollout group with known ID
mvc.perform(
Expand Down Expand Up @@ -1573,7 +1573,7 @@ void triggeringNextGroupRollout() throws Exception {
.andDo(MockMvcResultPrinter.print())
.andExpect(status().isOk());

final List<RolloutGroupStatus> groupStatus = rolloutGroupManagement.findByRollout(PAGE, rollout.getId())
final List<RolloutGroupStatus> groupStatus = rolloutGroupManagement.findByRollout(rollout.getId(), PAGE)
.getContent().stream().map(RolloutGroup::getStatus).collect(Collectors.toList());
assertThat(groupStatus).containsExactly(RolloutGroupStatus.RUNNING, RolloutGroupStatus.RUNNING,
RolloutGroupStatus.SCHEDULED, RolloutGroupStatus.SCHEDULED);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
import org.eclipse.hawkbit.repository.model.Rollout;
import org.eclipse.hawkbit.repository.model.RolloutGroup;
import org.eclipse.hawkbit.repository.model.Target;
import org.eclipse.hawkbit.repository.model.TargetWithActionStatus;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.security.access.prepost.PreAuthorize;
Expand All @@ -31,94 +30,67 @@
public interface RolloutGroupManagement {

/**
* Retrieves a page of {@link RolloutGroup}s filtered by a given
* {@link Rollout} with the detailed status.
* Retrieves a page of {@link RolloutGroup}s filtered by a given {@link Rollout} with the detailed status.
*
* @param pageable the page request to sort and limit the result
* @param rolloutId the ID of the rollout to filter the {@link RolloutGroup}s
* @param pageable the page request to sort and limit the result
* @return a page of found {@link RolloutGroup}s
* @throws EntityNotFoundException of rollout with given ID does not exist
*/
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_ROLLOUT_MANAGEMENT_READ)
Page<RolloutGroup> findByRolloutWithDetailedStatus(@NotNull Pageable pageable, long rolloutId);

/**
* Find all targets with action status by rollout group id. The action
* status might be {@code null} if for the target within the rollout no
* actions as been created, e.g. the target already had assigned the same
* distribution set we do not create an action for it but the target is in
* the result list of the rollout-group.
*
* @param pageable the page request to sort and limit the result
* @param rolloutGroupId rollout group
* @return {@link TargetWithActionStatus} target with action status
* @throws EntityNotFoundException if rollout group with given ID does not exist
*/
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_ROLLOUT_MANAGEMENT_READ_AND_TARGET_READ)
Page<TargetWithActionStatus> findAllTargetsOfRolloutGroupWithActionStatus(@NotNull Pageable pageable,
long rolloutGroupId);
Page<RolloutGroup> findByRolloutWithDetailedStatus(long rolloutId, @NotNull Pageable pageable);

/**
* Retrieves a single {@link RolloutGroup} by its ID.
*
* @param rolloutGroupId the ID of the rollout group to find
* @return the found {@link RolloutGroup} by its ID or {@code null} if it
* does not exists
* @return the found {@link RolloutGroup} by its ID or {@code null} if it does not exist
*/
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_ROLLOUT_MANAGEMENT_READ)
Optional<RolloutGroup> get(long rolloutGroupId);

/**
* Retrieves a page of {@link RolloutGroup}s filtered by a given
* {@link Rollout} and the an rsql filter.
* Retrieves a page of {@link RolloutGroup}s filtered by a given {@link Rollout} and an RSQL filter.
*
* @param pageable the page request to sort and limit the result
* @param rolloutId the rollout to filter the {@link RolloutGroup}s
* @param rsqlParam the specification to filter the result set based on attributes
* of the {@link RolloutGroup}
* @param rsqlParam the specification to filter the result set based on attributes of the {@link RolloutGroup}
* @param pageable the page request to sort and limit the result
* @return a page of found {@link RolloutGroup}s
* @throws RSQLParameterUnsupportedFieldException if a field in the RSQL string is used but not provided by the
* given {@code fieldNameProvider}
* @throws RSQLParameterSyntaxException if the RSQL syntax is wrong
*/
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_ROLLOUT_MANAGEMENT_READ)
Page<RolloutGroup> findByRolloutAndRsql(@NotNull Pageable pageable, long rolloutId,
@NotNull String rsqlParam);
Page<RolloutGroup> findByRolloutAndRsql(long rolloutId, @NotNull String rsqlParam, @NotNull Pageable pageable);

/**
* Retrieves a page of {@link RolloutGroup}s filtered by a given
* {@link Rollout} and a rsql filter with detailed status.
* Retrieves a page of {@link RolloutGroup}s filtered by a given {@link Rollout} and a rsql filter with detailed status.
*
* @param pageable the page request to sort and limit the result
* @param rolloutId the rollout to filter the {@link RolloutGroup}s
* @param rsqlParam the specification to filter the result set based on attributes
* of the {@link RolloutGroup}
* @param rsqlParam the specification to filter the result set based on attributes of the {@link RolloutGroup}
* @param pageable the page request to sort and limit the result
* @return a page of found {@link RolloutGroup}s
* @throws RSQLParameterUnsupportedFieldException if a field in the RSQL string is used but not provided by the
* given {@code fieldNameProvider}
* @throws RSQLParameterSyntaxException if the RSQL syntax is wrong
*/
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_ROLLOUT_MANAGEMENT_READ)
Page<RolloutGroup> findByRolloutAndRsqlWithDetailedStatus(@NotNull Pageable pageable, long rolloutId,
@NotNull String rsqlParam);
Page<RolloutGroup> findByRolloutAndRsqlWithDetailedStatus(long rolloutId, @NotNull String rsqlParam, @NotNull Pageable pageable);

/**
* Retrieves a page of {@link RolloutGroup}s filtered by a given
* {@link Rollout}.
* Retrieves a page of {@link RolloutGroup}s filtered by a given {@link Rollout}.
*
* @param pageable the page request to sort and limit the result
* @param rolloutId the ID of the rollout to filter the {@link RolloutGroup}s
* @param pageable the page request to sort and limit the result
* @return a page of found {@link RolloutGroup}s
*/
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_ROLLOUT_MANAGEMENT_READ)
Page<RolloutGroup> findByRollout(@NotNull Pageable pageable, long rolloutId);
Page<RolloutGroup> findByRollout(long rolloutId, @NotNull Pageable pageable);

/**
* Retrieves a page of {@link RolloutGroup}s filtered by a given
* {@link Rollout}.
* Retrieves a page of {@link RolloutGroup}s filtered by a given {@link Rollout}.
*
* @param rolloutId the ID of the rollout to filter the {@link RolloutGroup}s
* @param pageable the page request to sort and limit the result
* @return a page of found {@link RolloutGroup}s
*/
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_ROLLOUT_MANAGEMENT_READ)
Expand All @@ -127,13 +99,13 @@ Page<RolloutGroup> findByRolloutAndRsqlWithDetailedStatus(@NotNull Pageable page
/**
* Get targets of specified rollout group.
*
* @param pageable the page request to sort and limit the result
* @param rolloutGroupId rollout group
* @param pageable the page request to sort and limit the result
* @return Page<Target> list of targets of a rollout group
* @throws EntityNotFoundException if group with ID does not exist
*/
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_ROLLOUT_MANAGEMENT_READ_AND_TARGET_READ)
Page<Target> findTargetsOfRolloutGroup(@NotNull Pageable pageable, long rolloutGroupId);
Page<Target> findTargetsOfRolloutGroup(long rolloutGroupId, @NotNull Pageable pageable);

/**
* Get targets of specified rollout group.
Expand All @@ -151,7 +123,7 @@ Page<Target> findTargetsOfRolloutGroupByRsql(@NotNull Pageable pageable, long ro
@NotNull String rsqlParam);

/**
* Get {@link RolloutGroup} by Id.
* Get {@link RolloutGroup} by id.
*
* @param rolloutGroupId rollout group id
* @return rolloutGroup with details of targets count for different statuses
Expand All @@ -168,4 +140,4 @@ Page<Target> findTargetsOfRolloutGroupByRsql(@NotNull Pageable pageable, long ro
*/
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_ROLLOUT_MANAGEMENT_READ)
long countTargetsOfRolloutsGroup(long rolloutGroupId);
}
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -206,8 +206,8 @@ private void handleCreateRollout(final JpaRollout rollout) {
log.debug("handleCreateRollout called for rollout {}", rollout.getId());

final List<RolloutGroup> rolloutGroups = rolloutGroupManagement.findByRollout(
PageRequest.of(0, quotaManagement.getMaxRolloutGroupsPerRollout(), Sort.by(Direction.ASC, "id")),
rollout.getId()).getContent();
rollout.getId(), PageRequest.of(0, quotaManagement.getMaxRolloutGroupsPerRollout(), Sort.by(Direction.ASC, "id"))
).getContent();

int readyGroups = 0;
int totalTargets = 0;
Expand Down
Loading

0 comments on commit e68f889

Please sign in to comment.