Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,6 @@ public interface Staging {
@Nullable
String getReadinessHealthCheckHttpEndpoint();

@Nullable
Boolean isReadinessHealthCheckEnabled();

/**
* @return boolean value to see if ssh is enabled
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -395,8 +395,7 @@ private void updateApplicationProcess(UUID applicationGuid, Staging staging) {
if (staging.getHealthCheckType() != null) {
updateProcessRequestBuilder.healthCheck(buildHealthCheck(staging));
}
if (staging.isReadinessHealthCheckEnabled() != null && staging.isReadinessHealthCheckEnabled()
&& staging.getReadinessHealthCheckType() != null) {
if (staging.getReadinessHealthCheckType() != null) {
updateProcessRequestBuilder.readinessHealthCheck(buildReadinessHealthCheck(staging));
}
delegate.processes()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,6 @@ public final class Messages {
public static final String FLOWABLE_JOB_EXECUTOR_CORE_THREADS = "Flowable job executor core threads: {0}";
public static final String FLOWABLE_JOB_EXECUTOR_MAX_THREADS = "Flowable job executor max threads: {0}";
public static final String FLOWABLE_JOB_EXECUTOR_QUEUE_CAPACITY = "Flowable job executor queue capacity: {0}";
public static final String IS_READINESS_HEALTH_CHECK_ENABLED = "Is readiness health check enabled: {0}";
public static final String GLOBAL_AUDITOR_ORIGIN = "Global auditor user origin: {0}";

public static final String AUDIT_LOG_ABOUT_TO_PERFORM_ACTION = "About to perform action \"{0}\"";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@ public class ApplicationConfiguration {
static final String CFG_FLOWABLE_JOB_EXECUTOR_CORE_THREADS = "FLOWABLE_JOB_EXECUTOR_CORE_THREADS";
static final String CFG_FLOWABLE_JOB_EXECUTOR_MAX_THREADS = "FLOWABLE_JOB_EXECUTOR_MAX_THREADS";
static final String CFG_FLOWABLE_JOB_EXECUTOR_QUEUE_CAPACITY = "FLOWABLE_JOB_EXECUTOR_QUEUE_CAPACITY";
static final String IS_READINESS_HEALTH_CHECK_ENABLED = "IS_READINESS_HEALTH_CHECK_ENABLED";
static final String CFG_FSS_CACHE_UPDATE_TIMEOUT_MINUTES = "FSS_CACHE_UPDATE_TIMEOUT_MINUTES";
static final String CFG_THREAD_MONITOR_CACHE_UPDATE_IN_SECONDS = "THREAD_MONITOR_CACHE_UPDATE_IN_SECONDS";
static final String CFG_SPACE_DEVELOPER_CACHE_TIME_IN_SECONDS = "SPACE_DEVELOPER_CACHE_TIME_IN_SECONDS";
Expand Down Expand Up @@ -159,7 +158,6 @@ public class ApplicationConfiguration {
public static final int DEFAULT_THREADS_FOR_FILE_UPLOAD_TO_CONTROLLER = 6;
public static final int DEFAULT_THREADS_FOR_FILE_STORAGE_UPLOAD = 7;
public static final boolean DEFAULT_IS_HEALTH_CHECK_ENABLED = false;
public static final Boolean DEFAULT_IS_READINESS_HEALTH_CHECK_ENABLED = Boolean.FALSE;

protected final Environment environment;

Expand Down Expand Up @@ -219,7 +217,6 @@ public class ApplicationConfiguration {
private Integer threadsForFileStorageUpload;
private Boolean isHealthCheckEnabled;
private Set<String> objectStoreRegions;
private Boolean isReadinessHealthCheckEnabled;

public ApplicationConfiguration() {
this(new Environment());
Expand Down Expand Up @@ -269,7 +266,6 @@ public void load() {
getFilesAsyncUploadExecutorMaxThreads();
getDeployFromUrlExecutorMaxThreads();
getObjectStoreRegions();
getIsReadinessHealthCheckEnabled();
}

public Map<String, String> getNotSensitiveVariables() {
Expand Down Expand Up @@ -552,13 +548,6 @@ public Integer getFssCacheUpdateTimeoutMinutes() {
return fssCacheUpdateTimeoutMinutes;
}

public Boolean getIsReadinessHealthCheckEnabled() {
if (isReadinessHealthCheckEnabled == null) {
isReadinessHealthCheckEnabled = getIsReadinessHealthCheckFromEnvironment();
}
return isReadinessHealthCheckEnabled;
}

public Integer getThreadMonitorCacheUpdateInSeconds() {
if (threadMonitorCacheUpdateInSeconds == null) {
threadMonitorCacheUpdateInSeconds = getThreadMonitorCacheUpdateInSecondsFromEnvironment();
Expand Down Expand Up @@ -980,12 +969,6 @@ private Integer getFlowableJobExecutorQueueCapacityFromEnvironment() {
return value;
}

private Boolean getIsReadinessHealthCheckFromEnvironment() {
Boolean value = environment.getBoolean(IS_READINESS_HEALTH_CHECK_ENABLED, DEFAULT_IS_READINESS_HEALTH_CHECK_ENABLED);
logEnvironmentVariable(IS_READINESS_HEALTH_CHECK_ENABLED, Messages.IS_READINESS_HEALTH_CHECK_ENABLED, value);
return value;
}

private String getCronExpression(String name, String defaultValue) {
String value = environment.getString(name);
if (CronExpression.isValidExpression(value)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@
import org.cloudfoundry.multiapps.controller.client.facade.CloudCredentials;
import org.cloudfoundry.multiapps.controller.client.facade.domain.CloudApplication;
import org.cloudfoundry.multiapps.controller.client.facade.domain.ImmutableCloudApplication;
import org.cloudfoundry.multiapps.controller.client.facade.domain.ImmutableStaging;
import org.cloudfoundry.multiapps.controller.client.facade.domain.Staging;
import org.cloudfoundry.multiapps.controller.client.facade.dto.ApplicationToCreateDto;
import org.cloudfoundry.multiapps.controller.client.facade.dto.ImmutableApplicationToCreateDto;
import org.cloudfoundry.multiapps.controller.client.lib.domain.CloudApplicationExtended;
Expand Down Expand Up @@ -72,7 +70,6 @@ protected StepPhase executeStep(ProcessContext context) throws FileStorageExcept
CloudControllerClient client = context.getControllerClient();
CloudApplication existingApp = client.getApplication(app.getName(), false);
context.setVariable(Variables.EXISTING_APP, existingApp);
app = getApplicationWithReadinessEnabledInStaging(app);

StepFlowHandler flowHandler = createStepFlowHandler(context, client, app, existingApp);

Expand Down Expand Up @@ -110,17 +107,6 @@ private StepFlowHandler createStepFlowHandler(ProcessContext context,
return new UpdateAppFlowHandler(context, client, app, existingApp);
}

private CloudApplicationExtended getApplicationWithReadinessEnabledInStaging(CloudApplicationExtended app) {
Boolean isReadinessHealthCheckEnabled = configuration.getIsReadinessHealthCheckEnabled();
if (isReadinessHealthCheckEnabled == null || !isReadinessHealthCheckEnabled) {
return app;
}
Staging newStaging = ImmutableStaging.copyOf(app.getStaging())
.withIsReadinessHealthCheckEnabled(configuration.getIsReadinessHealthCheckEnabled());
return ImmutableCloudApplicationExtended.copyOf(app)
.withStaging(newStaging);
}

private abstract class StepFlowHandler {

final ProcessContext context;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,6 @@ private ReadinessHealthCheckUtil() {

public static boolean shouldWaitForAppToBecomeRoutable(ProcessContext context) {
CloudApplicationExtended appToProcess = context.getVariable(Variables.APP_TO_PROCESS);
Boolean isReadinessHealthCheckEnabled = appToProcess.getStaging()
.isReadinessHealthCheckEnabled();
if (isReadinessHealthCheckEnabled == null || !isReadinessHealthCheckEnabled) {
return false;
}
return appToProcess.getStaging()
.getReadinessHealthCheckType() != null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,14 +112,13 @@ void testErrorMessageWhenReadinessHealthCheckIsDisabled() {
assertEquals(NORMAL_ERROR_MESSAGE, step.getPollingErrorMessage(context));
}

private CloudApplicationExtended buildApplication(int instancesCount, boolean isReadinessHealthCheckEnabled) {
private CloudApplicationExtended buildApplication(int instancesCount, boolean isReadinessEnabled) {
return ImmutableCloudApplicationExtended.builder()
.metadata(ImmutableCloudMetadata.of(UUID.randomUUID()))
.name(APP_NAME)
.instances(instancesCount)
.staging(ImmutableStaging.builder()
.isReadinessHealthCheckEnabled(isReadinessHealthCheckEnabled)
.readinessHealthCheckType("test")
.readinessHealthCheckType(isReadinessEnabled ? "test" : null)
.build())
.build();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,18 +71,16 @@ private void setUpMocks(Module module) {
.metadata(ImmutableCloudMetadata.of(
UUID.randomUUID()
))
.staging(createStaging(
true))
.staging(createStaging())
.build();
context.setVariable(Variables.APP_TO_PROCESS, applicationExtended);
context.setVariable(Variables.COMPLETE_DEPLOYMENT_DESCRIPTOR, completeDeploymentDescriptor);
context.setVariable(Variables.DEPLOYMENT_DESCRIPTOR, completeDeploymentDescriptor);
when(applicationCloudModelBuilder.build(Mockito.any(), Mockito.any())).thenReturn(applicationExtended);
}

private Staging createStaging(boolean isReadinessHealthCheckEnabled) {
private Staging createStaging() {
return ImmutableStaging.builder()
.isReadinessHealthCheckEnabled(isReadinessHealthCheckEnabled)
.readinessHealthCheckType("http")
.build();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import org.cloudfoundry.multiapps.controller.api.model.ProcessType;
import org.cloudfoundry.multiapps.controller.client.facade.domain.CloudApplication;
import org.cloudfoundry.multiapps.controller.client.facade.domain.ImmutableStaging;
import org.cloudfoundry.multiapps.controller.client.facade.domain.Staging;
import org.cloudfoundry.multiapps.controller.client.lib.domain.CloudApplicationExtended;
import org.cloudfoundry.multiapps.controller.client.lib.domain.ImmutableCloudApplicationExtended;
import org.cloudfoundry.multiapps.controller.core.cf.metadata.processor.MtaMetadataParser;
Expand Down Expand Up @@ -49,7 +48,7 @@ class RestartAppStepTest extends SyncFlowableStepTest<RestartAppStep> {
@Test
void testExecuteWhenAppIsStopped() {
when(processTypeParser.getProcessType(context.getExecution())).thenReturn(ProcessType.DEPLOY);
CloudApplicationExtended app = createApplication(APP_NAME, CloudApplication.State.STOPPED, true);
CloudApplicationExtended app = createApplication(APP_NAME, CloudApplication.State.STOPPED, false);
prepareContextAndClient(app);
step.execute(execution);
assertStepFinishedSuccessfully();
Expand All @@ -68,7 +67,7 @@ protected void assertStepFinishedSuccessfully() {
@Test
void testExecuteWhenAppIsStarted() {
when(processTypeParser.getProcessType(context.getExecution())).thenReturn(ProcessType.DEPLOY);
CloudApplicationExtended app = createApplication(APP_NAME, CloudApplication.State.STARTED, true);
CloudApplicationExtended app = createApplication(APP_NAME, CloudApplication.State.STARTED, false);
prepareContextAndClient(app);
step.execute(execution);
assertStepFinishedSuccessfully();
Expand All @@ -88,21 +87,16 @@ void testGetHookPhasesBeforeStep() {
assertEquals(expectedHooks, hookPhasesBeforeStep);
}

private CloudApplicationExtended createApplication(String name, CloudApplication.State state, boolean isReadinessHealthCheckEnabled) {
private CloudApplicationExtended createApplication(String name, CloudApplication.State state, boolean isReadinessEnabled) {
return ImmutableCloudApplicationExtended.builder()
.name(name)
.state(state)
.staging(createStaging(isReadinessHealthCheckEnabled))
.staging(ImmutableStaging.builder()
.readinessHealthCheckType(isReadinessEnabled ? "test" : null)
.build())
.build();
}

private Staging createStaging(boolean isReadinessHealthCheckEnabled) {
return ImmutableStaging.builder()
.isReadinessHealthCheckEnabled(isReadinessHealthCheckEnabled)
.readinessHealthCheckType("http")
.build();
}

private void prepareContextAndClient(CloudApplicationExtended app) {
when(client.getApplication(APP_NAME)).thenReturn(app);
context.setVariable(Variables.APP_TO_PROCESS, app);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,40 +27,38 @@ class ReadinessHealthCheckUtilTest {
static Stream<Arguments> testShouldWaitForAppToBecomeRoutable() {
return Stream.of(
// (0) Test shouldWaitForAppToBecomeRoutable when enabled is null
Arguments.of(null, null, false),
Arguments.of(null, false),
// (1) Test shouldWaitForAppToBecomeRoutable when enabled is false
Arguments.of(false, null, false),
Arguments.of(null, false),
// (2) Test shouldWaitForAppToBecomeRoutable when enabled is true and type is null
Arguments.of(true, null, false),
Arguments.of(null, false),
// (3) Test shouldWaitForAppToBecomeRoutable when enabled is true and type is not null
Arguments.of(true, "http", true));
Arguments.of("http", true));
}

@ParameterizedTest
@MethodSource
void testShouldWaitForAppToBecomeRoutable(Boolean isReadinessHealthCheckEnabled, String readinessHealthCheckType,
boolean expectedResult) {
void testShouldWaitForAppToBecomeRoutable(String readinessHealthCheckType, boolean expectedResult) {
assertEquals(expectedResult, ReadinessHealthCheckUtil.shouldWaitForAppToBecomeRoutable(
createContext(isReadinessHealthCheckEnabled, readinessHealthCheckType)));
createContext(readinessHealthCheckType)));
}

private ProcessContext createContext(Boolean isReadinessHealthCheckEnabled, String readinessHealthCheckType) {
private ProcessContext createContext(String readinessHealthCheckType) {
DelegateExecution execution = MockDelegateExecution.createSpyInstance();
ProcessContext context = new ProcessContext(execution, stepLogger, clientProvider);

context.setVariable(Variables.APP_TO_PROCESS, createAppToProcess(isReadinessHealthCheckEnabled, readinessHealthCheckType));
context.setVariable(Variables.APP_TO_PROCESS, createAppToProcess(readinessHealthCheckType));
return context;
}

private CloudApplicationExtended createAppToProcess(Boolean isReadinessHealthCheckEnabled, String readinessHealthCheckType) {
private CloudApplicationExtended createAppToProcess(String readinessHealthCheckType) {
return ImmutableCloudApplicationExtended.builder()
.staging(createStaging(isReadinessHealthCheckEnabled, readinessHealthCheckType))
.staging(createStaging(readinessHealthCheckType))
.build();
}

private Staging createStaging(Boolean isReadinessHealthCheckEnabled, String readinessHealthCheckType) {
private Staging createStaging(String readinessHealthCheckType) {
return ImmutableStaging.builder()
.isReadinessHealthCheckEnabled(isReadinessHealthCheckEnabled)
.readinessHealthCheckType(readinessHealthCheckType)
.build();
}
Expand Down
Loading