[#2429] Add completeness property for software modules (#2765)

* add `min artifacts` requirement on the Software Module Type level for Software Module completeness
* removed `complete` Distribution Set property from DB - calculated runtime
* Distribution Set and Software Module completeness is calcualted on demand in memory (TODO: implement cache)
* locking of Software Module now requires the software module to be `completed`
* removed 'complete' search field for DistributionSet type. Still keep (DEPRECATED) limited support for search with 'complete' -
  only on the first level of expression and with AND. I.e. complete==true, complete==false and id=in=(1, 3) is suppoted,
  while complete==false or id=in=(1, 3) and id=in(1, 3) and (type==os and complete==true) are not

Signed-off-by: Avgustin Marinov <Avgustin.Marinov@bosch.com>
This commit is contained in:
Avgustin Marinov
2025-10-22 09:57:45 +03:00
committed by GitHub
parent f1c3d0175e
commit e154e1b18a
32 changed files with 377 additions and 155 deletions

View File

@@ -63,6 +63,8 @@ public interface SoftwareModuleTypeManagement<T extends SoftwareModuleType>
@Builder.Default
private int maxAssignments = 1;
@Builder.Default
private int minArtifacts;
}
@SuperBuilder

View File

@@ -28,16 +28,7 @@ public class DistributionSetUpdatedEvent extends RemoteEntityEvent<DistributionS
@Serial
private static final long serialVersionUID = 1L;
private boolean complete;
/**
* Constructor.
*
* @param distributionSet Distribution Set
* @param complete <code>true</code> if {@link DistributionSet} is after the update {@link DistributionSet#isComplete()}
*/
public DistributionSetUpdatedEvent(final DistributionSet distributionSet, final boolean complete) {
public DistributionSetUpdatedEvent(final DistributionSet distributionSet) {
super(distributionSet);
this.complete = complete;
}
}

View File

@@ -0,0 +1,40 @@
/**
* Copyright (c) 2025 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.exception;
import java.io.Serial;
import lombok.EqualsAndHashCode;
import lombok.ToString;
import org.eclipse.hawkbit.exception.AbstractServerRtException;
import org.eclipse.hawkbit.exception.SpServerError;
/**
* Thrown if a software module is being locked while incomplete (i.e. not enough artifacts are assigned).
*/
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
public final class IncompleteSoftwareModuleException extends AbstractServerRtException {
@Serial
private static final long serialVersionUID = 1L;
public IncompleteSoftwareModuleException() {
super(SpServerError.SP_DS_INCOMPLETE);
}
public IncompleteSoftwareModuleException(final Throwable cause) {
super(SpServerError.SP_DS_INCOMPLETE, cause);
}
public IncompleteSoftwareModuleException(final String message) {
super(SpServerError.SP_DS_INCOMPLETE, message);
}
}

View File

@@ -39,12 +39,6 @@ public interface DistributionSet extends NamedVersionedEntity {
*/
Set<SoftwareModule> getModules();
/**
* @return <code>true</code> if all defined {@link DistributionSetType#getMandatoryModuleTypes()} of {@link #getType()} are present in
* this {@link DistributionSet}.
*/
boolean isComplete();
/**
* @return <code>true</code> if this {@link DistributionSet} is locked. If so it's 'functional' properties (e.g. software modules) could not
* be modified anymore.
@@ -66,4 +60,12 @@ public interface DistributionSet extends NamedVersionedEntity {
* active and not automatically canceled if overridden by a newer update.
*/
boolean isRequiredMigrationStep();
/**
* Returns if the distribution set could be assumed as completed. I.e. all requirements (e.g. mandatory software module types) are satisfied.
*
* @return <code>true</code> if all defined {@link DistributionSetType#getMandatoryModuleTypes()} of {@link #getType()} are present in
* this {@link DistributionSet}.
*/
boolean isComplete();
}

View File

@@ -29,12 +29,6 @@ public interface DistributionSetType extends Type {
*/
Set<SoftwareModuleType> getOptionalModuleTypes();
/**
* @param distributionSet to check for completeness
* @return <code>true</code> if the all mandatory software module types are in the system.
*/
boolean checkComplete(DistributionSet distributionSet);
/**
* Checks if the given {@link SoftwareModuleType} is in this {@link DistributionSetType}.
*

View File

@@ -70,6 +70,13 @@ public interface SoftwareModule extends NamedVersionedEntity {
*/
boolean isDeleted();
/**
* Returns if the software module could be assumed as completed. I.e. all requirements (e.g. min artifacts) are satisfied.
*
* @return <code>true</code> if artifacts are more or equals to {@link SoftwareModuleType#getMinArtifacts()} if the software module type.
*/
boolean isComplete();
/**
* @param artifactId to look for
* @return found {@link Artifact}

View File

@@ -16,7 +16,12 @@ package org.eclipse.hawkbit.repository.model;
public interface SoftwareModuleType extends Type {
/**
* @return maximum assignments of an {@link SoftwareModule} of this type to a {@link DistributionSet}.
* @return thet minimum number of artifacts a {@link SoftwareModule} of this type should have in order to be completed.
*/
int getMinArtifacts();
/**
* @return the maximum assignments of a {@link SoftwareModule} of this type to a {@link DistributionSet}.
*/
int getMaxAssignments();
}