Skip to content

Commit

Permalink
Merge branch 'master' into add-support-for-cnb
Browse files Browse the repository at this point in the history
  • Loading branch information
s-yonkov-yonkov committed Jan 31, 2025
2 parents 4d08555 + 8403887 commit ebc2911
Show file tree
Hide file tree
Showing 73 changed files with 2,834 additions and 205 deletions.
2 changes: 1 addition & 1 deletion multiapps-controller-api/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<parent>
<groupId>org.cloudfoundry.multiapps</groupId>
<artifactId>multiapps-controller-parent</artifactId>
<version>1.182.0-SNAPSHOT</version>
<version>1.184.0-SNAPSHOT</version>
</parent>

<dependencies>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,18 @@ public class ProcessType {
private static final String BLUE_GREEN_DEPLOY_NAME = "BLUE_GREEN_DEPLOY";
private static final String UNDEPLOY_NAME = "UNDEPLOY";
private static final String CTS_DEPLOY_NAME = "CTS_DEPLOY";
private static final String ROLLBACK_MTA_DEPLOY_NAME = "ROLLBACK_MTA";
private static final String DEPLOYMENT_DISPLAY_NAME = "Deployment";
private static final String BLUE_GREEN_DEPLOYMENT_DISPLAY_NAME = "Blue-Green Deployment";
private static final String UNDEPLOYMENT_DISPLAY_NAME = "Undeployment";
private static final String CTS_DEPLOYMENT_DISPLAY_NAME = "CTS Deployment";
private static final String ROLLBACK_MTA_DEPLOYMENT_DISPLAY_NAME = "Rollback MTA Deployment";

public static final ProcessType DEPLOY = new ProcessType(DEPLOY_NAME, DEPLOYMENT_DISPLAY_NAME);
public static final ProcessType BLUE_GREEN_DEPLOY = new ProcessType(BLUE_GREEN_DEPLOY_NAME, BLUE_GREEN_DEPLOYMENT_DISPLAY_NAME);
public static final ProcessType UNDEPLOY = new ProcessType(UNDEPLOY_NAME, UNDEPLOYMENT_DISPLAY_NAME);
public static final ProcessType CTS_DEPLOY = new ProcessType(CTS_DEPLOY_NAME, CTS_DEPLOYMENT_DISPLAY_NAME);
public static final ProcessType ROLLBACK_MTA = new ProcessType(ROLLBACK_MTA_DEPLOY_NAME, ROLLBACK_MTA_DEPLOYMENT_DISPLAY_NAME);

private String name;
private String displayName;
Expand Down Expand Up @@ -79,6 +82,8 @@ public static ProcessType fromString(String name) {
return UNDEPLOY;
case CTS_DEPLOY_NAME:
return CTS_DEPLOY;
case ROLLBACK_MTA_DEPLOY_NAME:
return ROLLBACK_MTA;
default:
throw new IllegalStateException("Illegal process type: " + name);
}
Expand Down
2 changes: 1 addition & 1 deletion multiapps-controller-client/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<parent>
<groupId>org.cloudfoundry.multiapps</groupId>
<artifactId>multiapps-controller-parent</artifactId>
<version>1.182.0-SNAPSHOT</version>
<version>1.184.0-SNAPSHOT</version>
</parent>

<dependencies>
Expand Down
2 changes: 1 addition & 1 deletion multiapps-controller-core-test/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<parent>
<groupId>org.cloudfoundry.multiapps</groupId>
<artifactId>multiapps-controller-parent</artifactId>
<version>1.182.0-SNAPSHOT</version>
<version>1.184.0-SNAPSHOT</version>
</parent>

<dependencies>
Expand Down
2 changes: 1 addition & 1 deletion multiapps-controller-core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<parent>
<groupId>org.cloudfoundry.multiapps</groupId>
<artifactId>multiapps-controller-parent</artifactId>
<version>1.182.0-SNAPSHOT</version>
<version>1.184.0-SNAPSHOT</version>
</parent>

<dependencies>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,7 @@ public final class Messages {
public static final String ON_START_FILES_CLEANER_WITHOUT_CONTENT_ENABLED_0 = "On start files cleaner without content enabled: {0}";
public static final String THREADS_FOR_FILE_UPLOAD_TO_CONTROLLER_0 = "Threads for file upload to controller: {0}";
public static final String THREADS_FOR_FILE_STORAGE_UPLOAD_0 = "Threads for file storage upload: {0}";
public static final String DELETED_ORPHANED_MTA_DESCRIPTORS_COUNT = "Deleted orphaned mta descriptors count: {0}";

// Debug messages
public static final String DEPLOYMENT_DESCRIPTOR = "Deployment descriptor: {0}";
Expand All @@ -188,6 +189,7 @@ public final class Messages {
public static final String DELETE_SUBSCRIPTION_AUDIT_LOG_MESSAGE = "Delete subscription in space with id: {0}";
public static final String DELETE_ENTRY_AUDIT_LOG_MESSAGE = "Delete entry in space with id: {0}";
public static final String DELETE_OPERATION_AUDIT_LOG_MESSAGE = "Delete operation in space with id: {0}";
public static final String DELETE_BACKUP_DESCRIPTOR_AUDIT_LOG_MESSAGE = "Delete backup descriptor in space with id: {0}";
public static final String UPLOAD_FILE_AUDIT_LOG_MESSAGE = "Upload file in space with id: {0}";
public static final String UPLOAD_FILE_FROM_URL_AUDIT_LOG_MESSAGE = "Upload file from url in space with id: {0}";
public static final String GET_INFO_FOR_UPLOAD_URL_JOB_AUDIT_LOG_MESSAGE = "Get info for upload from url job in space with id: {0}";
Expand Down Expand Up @@ -219,6 +221,7 @@ public final class Messages {
public static final String FILE_UPLOAD_AUDIT_LOG_CONFIG = "File upload";
public static final String FILE_UPLOAD_FROM_URL_AUDIT_LOG_CONFIG = "File upload from url";
public static final String UPLOAD_FROM_URL_JOB_INFO_AUDIT_LOG_CONFIG = "Upload from url job info";
public static final String MTA_DESCRIPTOR_DELETE_AUDIT_LOG_CONFIG = "Mta descriptor delete";

public static final String OPERATION_LIST_AUDIT_LOG_CONFIG = "Operation list";
public static final String OPERATION_ACTIONS_LIST_AUDIT_LOG_CONFIG = "Operation actions list";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import org.cloudfoundry.multiapps.controller.core.Messages;
import org.cloudfoundry.multiapps.controller.core.auditlogging.model.AuditLogConfiguration;
import org.cloudfoundry.multiapps.controller.core.auditlogging.model.ConfigurationChangeActions;
import org.cloudfoundry.multiapps.controller.persistence.dto.BackupDescriptor;
import org.cloudfoundry.multiapps.controller.persistence.model.ConfigurationEntry;
import org.cloudfoundry.multiapps.controller.persistence.model.ConfigurationSubscription;

Expand All @@ -30,6 +31,7 @@ public class MtaConfigurationPurgerAuditLog {
private static final String STARTED_AT_PROPERTY_NAME = "startedAt";
private static final String STATE_PROPERTY_NAME = "state";
private static final String ERROR_TYPE_PROPERTY_NAME = "errorType";
private static final String STORED_AT_PROPERTY_NAME = "storedAt";

private final AuditLoggingFacade auditLoggingFacade;

Expand Down Expand Up @@ -85,6 +87,16 @@ public void logDeleteOperation(String spaceGuid, Operation operation) {
ConfigurationChangeActions.CONFIGURATION_DELETE);
}

public void logDeleteBackupDescriptor(String spaceGuid, BackupDescriptor backupDescriptor) {
String performedAction = MessageFormat.format(Messages.DELETE_BACKUP_DESCRIPTOR_AUDIT_LOG_MESSAGE, spaceGuid);
auditLoggingFacade.logConfigurationChangeAuditLog(new AuditLogConfiguration(Strings.EMPTY,
spaceGuid,
performedAction,
Messages.MTA_DESCRIPTOR_DELETE_AUDIT_LOG_CONFIG,
createAuditLogDeleteMtaBackupDescriptorIdentifier(backupDescriptor)),
ConfigurationChangeActions.CONFIGURATION_DELETE);
}

private Map<String, String> createAuditLogDeleteSubscriptionConfigurationIdentifier(ConfigurationSubscription subscription) {
Map<String, String> identifiers = new HashMap<>();

Expand Down Expand Up @@ -124,4 +136,14 @@ private Map<String, String> createAuditLogDeleteOperationConfigurationIdentifier

return identifiers;
}

private Map<String, String> createAuditLogDeleteMtaBackupDescriptorIdentifier(BackupDescriptor backupDescriptor) {
Map<String, String> identifiers = new HashMap<>();

identifiers.put(MTA_ID_PROPERTY_NAME, backupDescriptor.getMtaId());
identifiers.put(STORED_AT_PROPERTY_NAME, backupDescriptor.getTimestamp()
.toString());

return identifiers;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,13 @@ public class ResourcesCloudModelBuilderContentCalculator implements CloudModelBu

private final List<String> resourcesSpecifiedForDeployment;
private final UserMessageLogger userMessageLogger;
private final boolean processOnlyUserProvidedService;

public ResourcesCloudModelBuilderContentCalculator(List<String> resourcesSpecifiedForDeployment, UserMessageLogger userMessageLogger) {
public ResourcesCloudModelBuilderContentCalculator(List<String> resourcesSpecifiedForDeployment, UserMessageLogger userMessageLogger,
boolean processOnlyUserProvidedService) {
this.resourcesSpecifiedForDeployment = resourcesSpecifiedForDeployment;
this.userMessageLogger = userMessageLogger;
this.processOnlyUserProvidedService = processOnlyUserProvidedService;
}

@Override
Expand All @@ -24,9 +27,17 @@ public List<Resource> calculateContentForBuilding(List<? extends Resource> eleme
.filter(this::isActive)
.filter(this::isResourceSpecifiedForDeployment)
.filter(this::isService)
.filter(this::shouldProcessService)
.collect(Collectors.toList());
}

private boolean shouldProcessService(Resource resource) {
if (processOnlyUserProvidedService) {
return CloudModelBuilderUtil.isUserProvidedService(resource);
}
return true;
}

private boolean isService(Resource resource) {
if (!CloudModelBuilderUtil.isService(resource)) {
warnInvalidResourceType(resource);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ public static Metadata build(DeploymentDescriptor deploymentDescriptor, String n
String mtaServicesAnnotation = buildBoundMtaServicesAnnotation(services);

Metadata.Builder builder = MtaMetadataBuilder.init(deploymentDescriptor, namespace)
.annotation(MtaMetadataAnnotations.MTA_MODULE, mtaModuleAnnotation)
.annotation(MtaMetadataAnnotations.MTA_MODULE_PUBLIC_PROVIDED_DEPENDENCIES,
mtaModuleProvidedDependenciesAnnotation)
.annotation(MtaMetadataAnnotations.MTA_MODULE_BOUND_SERVICES, mtaServicesAnnotation);
.annotation(MtaMetadataAnnotations.MTA_MODULE, mtaModuleAnnotation)
.annotation(MtaMetadataAnnotations.MTA_MODULE_PUBLIC_PROVIDED_DEPENDENCIES,
mtaModuleProvidedDependenciesAnnotation)
.annotation(MtaMetadataAnnotations.MTA_MODULE_BOUND_SERVICES, mtaServicesAnnotation);

return builder.build();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ public static Builder init(DeploymentDescriptor deploymentDescriptor, String nam
builder.label(MtaMetadataLabels.MTA_NAMESPACE, hashedMtaNamespace)
.annotation(MtaMetadataAnnotations.MTA_NAMESPACE, namespace);
}

return builder;
}

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

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

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

return builder.build();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ public class ServiceMetadataBuilder {

public static Metadata build(DeploymentDescriptor deploymentDescriptor, String namespace, Resource resource) {
String mtaResourceAnnotation = buildMtaResourceAnnotation(resource);

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

return builder.build();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ public class BlueGreenApplicationNameSuffix {

public static final BlueGreenApplicationNameSuffix LIVE = new BlueGreenApplicationNameSuffix("live");
public static final BlueGreenApplicationNameSuffix IDLE = new BlueGreenApplicationNameSuffix("idle");
public static final BlueGreenApplicationNameSuffix BLUE = new BlueGreenApplicationNameSuffix("blue");
public static final BlueGreenApplicationNameSuffix GREEN = new BlueGreenApplicationNameSuffix("green");

private final String value;

Expand All @@ -18,7 +20,7 @@ public String asSuffix() {
}

public static boolean isSuffixContainedIn(String name) {
return Stream.of(LIVE, IDLE)
return Stream.of(LIVE, IDLE, BLUE, GREEN)
.map(BlueGreenApplicationNameSuffix::asSuffix)
.anyMatch(name::endsWith);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,6 @@ public class SupportedParameters {
public static final String HEALTH_CHECK_TIMEOUT = "health-check-timeout";
public static final String HEALTH_CHECK_TYPE = "health-check-type";
public static final String HEALTH_CHECK_HTTP_ENDPOINT = "health-check-http-endpoint";
public static final String READINESS_HEALTH_CHECK_TYPE = "readiness-health-check-type";
public static final String READINESS_HEALTH_CHECK_HTTP_ENDPOINT = "readiness-health-check-http-endpoint";
public static final String READINESS_HEALTH_CHECK_INVOCATION_TIMEOUT = "readiness-health-check-invocation-timeout";
public static final String READINESS_HEALTH_CHECK_INTERVAL = "readiness-health-check-interval";
public static final String UPLOAD_TIMEOUT = "upload-timeout";
public static final String STAGE_TIMEOUT = "stage-timeout";
public static final String START_TIMEOUT = "start-timeout";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,17 +32,6 @@ public Staging parse(List<Map<String, Object>> parametersList) {
String healthCheckHttpEndpoint = (String) PropertiesUtil.getPropertyValue(parametersList,
SupportedParameters.HEALTH_CHECK_HTTP_ENDPOINT,
getDefaultHealthCheckHttpEndpoint(healthCheckType));
String readinessHealthCheckType = (String) PropertiesUtil.getPropertyValue(parametersList,
SupportedParameters.READINESS_HEALTH_CHECK_TYPE, null);
String readinessHealthCheckHttpEndpoint = (String) PropertiesUtil.getPropertyValue(parametersList,
SupportedParameters.READINESS_HEALTH_CHECK_HTTP_ENDPOINT,
getDefaultHealthCheckHttpEndpoint(readinessHealthCheckType));
Integer readinessHealthCheckInvocationTimeout = (Integer) PropertiesUtil.getPropertyValue(parametersList,
SupportedParameters.READINESS_HEALTH_CHECK_INVOCATION_TIMEOUT,
null);
Integer readinessHealthCheckInterval = (Integer) PropertiesUtil.getPropertyValue(parametersList,
SupportedParameters.READINESS_HEALTH_CHECK_INTERVAL,
null);
Boolean isSshEnabled = (Boolean) PropertiesUtil.getPropertyValue(parametersList, SupportedParameters.ENABLE_SSH, null);
DockerInfo dockerInfo = new DockerInfoParser().parse(parametersList);
LifecycleType lifecycleType = parseLifecycleType(parametersList);
Expand All @@ -57,10 +46,6 @@ public Staging parse(List<Map<String, Object>> parametersList) {
.invocationTimeout(healthCheckInvocationTimeout)
.healthCheckType(healthCheckType)
.healthCheckHttpEndpoint(healthCheckHttpEndpoint)
.readinessHealthCheckType(readinessHealthCheckType)
.readinessHealthCheckHttpEndpoint(readinessHealthCheckHttpEndpoint)
.readinessHealthCheckTimeout(readinessHealthCheckInvocationTimeout)
.readinessHealthCheckInterval(readinessHealthCheckInterval)
.isSshEnabled(isSshEnabled)
.dockerInfo(dockerInfo)
.lifecycleType(lifecycleType)
Expand Down
Loading

0 comments on commit ebc2911

Please sign in to comment.