Skip to content

Commit

Permalink
Compare only mta version instead calculating checksum of merged descr…
Browse files Browse the repository at this point in the history
…iptors
  • Loading branch information
theghost5800 authored and Yavor16 committed Jan 6, 2025
1 parent 69a37fa commit a54feca
Show file tree
Hide file tree
Showing 30 changed files with 181 additions and 236 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,7 @@ ConfigurationSubscriptionFactory getConfigurationSubscriptionFactory(DeploymentD
ApplicationCloudModelBuilder getApplicationCloudModelBuilder(DeploymentDescriptor deploymentDescriptor, boolean prettyPrinting,
DeployedMta deployedMta, String deployId, String namespace,
UserMessageLogger stepLogger, AppSuffixDeterminer appSuffixDeterminer,
CloudControllerClient client, boolean incrementalInstancesUpdate,
String checksumOfMergedDescriptor);
CloudControllerClient client, boolean incrementalInstancesUpdate);

ServicesCloudModelBuilder getServicesCloudModelBuilder(DeploymentDescriptor deploymentDescriptor, String namespace);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ public class MtaMetadataLabels {
public static final String MTA_ID = "mta_id";
public static final String MTA_NAMESPACE = "mta_namespace";
public static final String SPACE_GUID = "space_guid";
public static final String MTA_DESCRIPTOR_CHECKSUM = "mta_descriptor_checksum";
public static final String AUTOSCALER_LABEL = "app-autoscaler.cloudfoundry.org/disable-autoscaling";

private MtaMetadataLabels() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ public class ApplicationCloudModelBuilder {
protected final AppSuffixDeterminer appSuffixDeterminer;
protected final CloudControllerClient client;
protected final boolean incrementalInstancesUpdate;
protected final String checksumOfMergedDescriptor;

protected final ParametersChainBuilder parametersChainBuilder;

Expand All @@ -84,7 +83,6 @@ protected ApplicationCloudModelBuilder(AbstractBuilder<?> builder) {
this.appSuffixDeterminer = builder.appSuffixDeterminer;
this.client = builder.client;
this.incrementalInstancesUpdate = builder.incrementalInstancesUpdate;
this.checksumOfMergedDescriptor = builder.checksumOfMergedDescriptor;
}

protected CloudHandlerFactory createCloudHandlerFactory() {
Expand Down Expand Up @@ -123,8 +121,7 @@ protected CloudApplicationExtended getApplication(Module module) {
.dockerInfo(parseParameters(parametersList, new DockerInfoParser()))
.attributesUpdateStrategy(getApplicationAttributesUpdateStrategy(parametersList))
.v3Metadata(ApplicationMetadataBuilder.build(deploymentDescriptor, namespace, module,
getApplicationServices(module),
checksumOfMergedDescriptor))
getApplicationServices(module)))
.build();
}

Expand Down Expand Up @@ -317,7 +314,6 @@ protected abstract static class AbstractBuilder<T extends AbstractBuilder<T>> {
private AppSuffixDeterminer appSuffixDeterminer;
private CloudControllerClient client;
private boolean incrementalInstancesUpdate;
private String checksumOfMergedDescriptor;

public T deploymentDescriptor(DeploymentDescriptor deploymentDescriptor) {
this.deploymentDescriptor = deploymentDescriptor;
Expand Down Expand Up @@ -364,11 +360,6 @@ public T incrementalInstancesUpdate(boolean incrementalInstancesUpdate) {
return self();
}

public T checksumOfMergedDescriptor(String checksumOfMergedDescriptor) {
this.checksumOfMergedDescriptor = checksumOfMergedDescriptor;
return self();
}

protected abstract T self();

public abstract ApplicationCloudModelBuilder build();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,12 @@

public class ApplicationMetadataBuilder {

public static Metadata build(DeploymentDescriptor deploymentDescriptor, String namespace, Module module, List<String> services,
String checksumOfMergedDescriptor) {
public static Metadata build(DeploymentDescriptor deploymentDescriptor, String namespace, Module module, List<String> services) {
String mtaModuleAnnotation = buildMtaModuleAnnotation(module);
String mtaModuleProvidedDependenciesAnnotation = buildMtaModuleProvidedDependenciesAnnotation(module);
String mtaServicesAnnotation = buildBoundMtaServicesAnnotation(services);

Metadata.Builder builder = MtaMetadataBuilder.init(deploymentDescriptor, namespace, checksumOfMergedDescriptor)
Metadata.Builder builder = MtaMetadataBuilder.init(deploymentDescriptor, namespace)
.annotation(MtaMetadataAnnotations.MTA_MODULE, mtaModuleAnnotation)
.annotation(MtaMetadataAnnotations.MTA_MODULE_PUBLIC_PROVIDED_DEPENDENCIES,
mtaModuleProvidedDependenciesAnnotation)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,11 @@
public class CloudHandlerFactoryV2 extends HandlerFactoryV2 implements CloudHandlerFactory {

@Override
public ApplicationCloudModelBuilder
getApplicationCloudModelBuilder(DeploymentDescriptor deploymentDescriptor, boolean prettyPrinting, DeployedMta deployedMta,
String deployId, String namespace, UserMessageLogger stepLogger,
AppSuffixDeterminer appSuffixDeterminer, CloudControllerClient client,
boolean incrementalInstancesUpdate, String checksumOfMergedDescriptor) {
public ApplicationCloudModelBuilder getApplicationCloudModelBuilder(DeploymentDescriptor deploymentDescriptor, boolean prettyPrinting,
DeployedMta deployedMta, String deployId, String namespace,
UserMessageLogger stepLogger,
AppSuffixDeterminer appSuffixDeterminer,
CloudControllerClient client, boolean incrementalInstancesUpdate) {
return new ApplicationCloudModelBuilder.Builder().deploymentDescriptor(deploymentDescriptor)
.prettyPrinting(prettyPrinting)
.deployedMta(deployedMta)
Expand All @@ -46,7 +46,6 @@ public class CloudHandlerFactoryV2 extends HandlerFactoryV2 implements CloudHand
.appSuffixDeterminer(appSuffixDeterminer)
.client(client)
.incrementalInstancesUpdate(incrementalInstancesUpdate)
.checksumOfMergedDescriptor(checksumOfMergedDescriptor)
.build();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

public class MtaMetadataBuilder {

public static Builder init(DeploymentDescriptor deploymentDescriptor, String namespace, String checksumOfMergedDescriptor) {
public static Builder init(DeploymentDescriptor deploymentDescriptor, String namespace) {
String hashedMtaId = MtaMetadataUtil.getHashedLabel(deploymentDescriptor.getId());
Builder builder = Metadata.builder()
.label(MtaMetadataLabels.MTA_ID, hashedMtaId)
Expand All @@ -22,11 +22,6 @@ public static Builder init(DeploymentDescriptor deploymentDescriptor, String nam
builder.label(MtaMetadataLabels.MTA_NAMESPACE, hashedMtaNamespace)
.annotation(MtaMetadataAnnotations.MTA_NAMESPACE, namespace);
}

if (StringUtils.isNotEmpty(checksumOfMergedDescriptor)) {
builder.label(MtaMetadataLabels.MTA_DESCRIPTOR_CHECKSUM, checksumOfMergedDescriptor);
}

return builder;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ public class ServiceKeyMetadataBuilder {

public static Metadata build(DeploymentDescriptor deploymentDescriptor, String namespace, String spaceGuid) {

Builder builder = MtaMetadataBuilder.init(deploymentDescriptor, namespace, null)
Builder builder = MtaMetadataBuilder.init(deploymentDescriptor, namespace)
.label(MtaMetadataLabels.SPACE_GUID, spaceGuid);

return builder.build();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public class ServiceMetadataBuilder {
public static Metadata build(DeploymentDescriptor deploymentDescriptor, String namespace, Resource resource) {
String mtaResourceAnnotation = buildMtaResourceAnnotation(resource);

Builder builder = MtaMetadataBuilder.init(deploymentDescriptor, namespace, null)
Builder builder = MtaMetadataBuilder.init(deploymentDescriptor, namespace)
.annotation(MtaMetadataAnnotations.MTA_RESOURCE, mtaResourceAnnotation);

return builder.build();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,11 @@
public class CloudHandlerFactoryV3 extends HandlerFactoryV3 implements CloudHandlerFactory {

@Override
public ApplicationCloudModelBuilder
getApplicationCloudModelBuilder(DeploymentDescriptor deploymentDescriptor, boolean prettyPrinting, DeployedMta deployedMta,
String deployId, String namespace, UserMessageLogger stepLogger,
AppSuffixDeterminer appSuffixDeterminer, CloudControllerClient client,
boolean incrementalInstancesUpdate, String checksumOfMergedDescriptor) {
public ApplicationCloudModelBuilder getApplicationCloudModelBuilder(DeploymentDescriptor deploymentDescriptor, boolean prettyPrinting,
DeployedMta deployedMta, String deployId, String namespace,
UserMessageLogger stepLogger,
AppSuffixDeterminer appSuffixDeterminer,
CloudControllerClient client, boolean incrementalInstancesUpdate) {
return new ApplicationCloudModelBuilder.Builder().deploymentDescriptor(deploymentDescriptor)
.prettyPrinting(prettyPrinting)
.deployedMta(deployedMta)
Expand All @@ -45,7 +45,6 @@ public class CloudHandlerFactoryV3 extends HandlerFactoryV3 implements CloudHand
.appSuffixDeterminer(appSuffixDeterminer)
.client(client)
.incrementalInstancesUpdate(incrementalInstancesUpdate)
.checksumOfMergedDescriptor(checksumOfMergedDescriptor)
.build();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@ default long getId() {
@Nullable
String getNamespace();

String getChecksum();

@Value.Default
default LocalDateTime getTimestamp() {
return LocalDateTime.now();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ private AttributeNames() {
public static final String MTA_ID = "mtaId";
public static final String SPACE_ID = "spaceId";
public static final String NAMESPACE = "namespace";
public static final String CHECKSUM = "checksum";
public static final String MTA_VERSION = "mtaVersion";
public static final String TIMESTAMP = "timestamp";
}

Expand All @@ -53,9 +53,6 @@ private AttributeNames() {
@Column(name = TableColumnNames.BACKUP_DESCRIPTOR_NAMESPACE, nullable = true)
private String namespace;

@Column(name = TableColumnNames.BACKUP_DESCRIPTOR_CHECKSUM, nullable = false)
private String checksum;

@Column(name = TableColumnNames.BACKUP_DESCRIPTOR_TIMESTAMP, nullable = false)
private LocalDateTime timestamp;

Expand All @@ -64,14 +61,13 @@ protected BackupDescriptorDto() {
}

public BackupDescriptorDto(long id, byte[] descriptor, String mtaId, String mtaVersion, String spaceId, String namespace,
String checksum, LocalDateTime timestamp) {
LocalDateTime timestamp) {
this.id = id;
this.descriptor = descriptor;
this.mtaId = mtaId;
this.mtaVersion = mtaVersion;
this.spaceId = spaceId;
this.namespace = namespace;
this.checksum = checksum;
this.timestamp = timestamp;
}

Expand Down Expand Up @@ -109,10 +105,6 @@ public String getNamespace() {
return namespace;
}

public String getChecksum() {
return checksum;
}

public LocalDateTime getTimestamp() {
return timestamp;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,6 @@ private TableColumnNames() {
public static final String BACKUP_DESCRIPTOR_MTA_VERSION = "mta_version";
public static final String BACKUP_DESCRIPTOR_SPACE_ID = "space_id";
public static final String BACKUP_DESCRIPTOR_NAMESPACE = "namespace";
public static final String BACKUP_DESCRIPTOR_CHECKSUM = "checksum";
public static final String BACKUP_DESCRIPTOR_TIMESTAMP = "timestamp";
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ public interface DescriptorBackupQuery extends Query<BackupDescriptor, Descripto

DescriptorBackupQuery namespace(String namespace);

DescriptorBackupQuery checksum(String checksum);
DescriptorBackupQuery mtaVersion(String mtaVersion);

DescriptorBackupQuery checksumsNotMatch(List<String> checksum);
DescriptorBackupQuery mtaVersionsNotMatch(List<String> mtaVersions);

DescriptorBackupQuery olderThan(LocalDateTime time);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,22 +67,22 @@ public DescriptorBackupQuery namespace(String namespace) {
}

@Override
public DescriptorBackupQuery checksum(String checksum) {
public DescriptorBackupQuery mtaVersion(String mtaVersion) {
queryCriteria.addRestriction(ImmutableQueryAttributeRestriction.builder()
.attribute(AttributeNames.CHECKSUM)
.attribute(AttributeNames.MTA_VERSION)
.condition(getCriteriaBuilder()::equal)
.value(checksum)
.value(mtaVersion)
.build());
return this;
}

@Override
public DescriptorBackupQuery checksumsNotMatch(List<String> checksums) {
public DescriptorBackupQuery mtaVersionsNotMatch(List<String> mtaVersions) {
queryCriteria.addRestriction(ImmutableQueryAttributeRestriction.builder()
.attribute(AttributeNames.CHECKSUM)
.condition((expression, value) -> expression.in(checksums)
.attribute(AttributeNames.MTA_VERSION)
.condition((expression, value) -> expression.in(mtaVersions)
.not())
.value(checksums)
.value(mtaVersions)
.build());
return this;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,7 @@ protected PersistenceObjectMapper<BackupDescriptor, BackupDescriptorDto> getPers

@Override
protected void onEntityConflict(BackupDescriptorDto dto, Throwable t) {
throw new ConflictException(t,
Messages.BACKUP_DESCRIPTOR_FOR_MTA_ID_0_AND_ID_1_ALREADY_EXIST,
dto.getMtaId(),
dto.getPrimaryKey());
throw new ConflictException(t, Messages.BACKUP_DESCRIPTOR_FOR_MTA_ID_0_AND_ID_1_ALREADY_EXIST, dto.getMtaId(), dto.getPrimaryKey());
}

@Override
Expand All @@ -61,7 +58,6 @@ public BackupDescriptor fromDto(BackupDescriptorDto dto) {
.mtaVersion(dto.getMtaVersion())
.spaceId(dto.getSpaceId())
.namespace(dto.getNamespace())
.checksum(dto.getChecksum())
.timestamp(dto.getTimestamp())
.build();
}
Expand All @@ -83,9 +79,8 @@ public BackupDescriptorDto toDto(BackupDescriptor backupDescriptor) {
.toString();
String spaceId = backupDescriptor.getSpaceId();
String namespace = backupDescriptor.getNamespace();
String checksum = backupDescriptor.getChecksum();
LocalDateTime timestamp = backupDescriptor.getTimestamp();
return new BackupDescriptorDto(id, serializeDescriptor(descriptor), mtaId, mtaVersion, spaceId, namespace, checksum, timestamp);
return new BackupDescriptorDto(id, serializeDescriptor(descriptor), mtaId, mtaVersion, spaceId, namespace, timestamp);
}

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,6 @@
<constraints nullable="false" />
</column>
<column name="namespace" type="VARCHAR(255)"/>
<column name="checksum" type="VARCHAR(255)">
<constraints nullable="false" />
</column>
<column name="timestamp" type="TIMESTAMP">
<constraints nullable="false" />
</column>
Expand Down
Loading

0 comments on commit a54feca

Please sign in to comment.