diff --git a/cloudfoundry-client-reactor/src/test/java/org/cloudfoundry/reactor/client/v3/applications/ReactorApplicationsV3Test.java b/cloudfoundry-client-reactor/src/test/java/org/cloudfoundry/reactor/client/v3/applications/ReactorApplicationsV3Test.java index 2cdf3bad4c3..90fe6d1cbe4 100644 --- a/cloudfoundry-client-reactor/src/test/java/org/cloudfoundry/reactor/client/v3/applications/ReactorApplicationsV3Test.java +++ b/cloudfoundry-client-reactor/src/test/java/org/cloudfoundry/reactor/client/v3/applications/ReactorApplicationsV3Test.java @@ -117,6 +117,8 @@ import org.cloudfoundry.client.v3.processes.ProcessState; import org.cloudfoundry.client.v3.processes.ProcessStatisticsResource; import org.cloudfoundry.client.v3.processes.ProcessUsage; +import org.cloudfoundry.client.v3.processes.ReadinessHealthCheck; +import org.cloudfoundry.client.v3.processes.ReadinessHealthCheckType; import org.cloudfoundry.client.v3.routes.Application; import org.cloudfoundry.client.v3.routes.Destination; import org.cloudfoundry.client.v3.routes.Process; @@ -807,6 +809,16 @@ public void getProcess() { .endpoint(null) .build()) .build()) + .readinessHealthCheck( + ReadinessHealthCheck.builder() + .type(ReadinessHealthCheckType.PORT) + .data( + Data.builder() + .interval(null) + .timeout(null) + .endpoint(null) + .build()) + .build()) .metadata( Metadata.builder() .annotations(Collections.emptyMap()) @@ -1627,6 +1639,16 @@ public void listProcesses() { .endpoint(null) .build()) .build()) + .readinessHealthCheck( + ReadinessHealthCheck.builder() + .type(ReadinessHealthCheckType.PORT) + .data( + Data.builder() + .interval(null) + .timeout(null) + .endpoint(null) + .build()) + .build()) .metadata( Metadata.builder() .annotations(Collections.emptyMap()) @@ -1685,6 +1707,16 @@ public void listProcesses() { .endpoint(null) .build()) .build()) + .readinessHealthCheck( + ReadinessHealthCheck.builder() + .type(ReadinessHealthCheckType.PORT) + .data( + Data.builder() + .interval(null) + .timeout(null) + .endpoint(null) + .build()) + .build()) .metadata( Metadata.builder() .annotations(Collections.emptyMap()) @@ -2052,6 +2084,16 @@ public void scale() { .endpoint(null) .build()) .build()) + .readinessHealthCheck( + ReadinessHealthCheck.builder() + .type(ReadinessHealthCheckType.PORT) + .data( + Data.builder() + .interval(null) + .timeout(null) + .endpoint(null) + .build()) + .build()) .metadata( Metadata.builder() .annotations(Collections.emptyMap()) diff --git a/cloudfoundry-client-reactor/src/test/java/org/cloudfoundry/reactor/client/v3/processes/ReactorProcessesTest.java b/cloudfoundry-client-reactor/src/test/java/org/cloudfoundry/reactor/client/v3/processes/ReactorProcessesTest.java index cd3795562a4..1104e445633 100644 --- a/cloudfoundry-client-reactor/src/test/java/org/cloudfoundry/reactor/client/v3/processes/ReactorProcessesTest.java +++ b/cloudfoundry-client-reactor/src/test/java/org/cloudfoundry/reactor/client/v3/processes/ReactorProcessesTest.java @@ -43,6 +43,8 @@ import org.cloudfoundry.client.v3.processes.ProcessState; import org.cloudfoundry.client.v3.processes.ProcessStatisticsResource; import org.cloudfoundry.client.v3.processes.ProcessUsage; +import org.cloudfoundry.client.v3.processes.ReadinessHealthCheck; +import org.cloudfoundry.client.v3.processes.ReadinessHealthCheckType; import org.cloudfoundry.client.v3.processes.ScaleProcessRequest; import org.cloudfoundry.client.v3.processes.ScaleProcessResponse; import org.cloudfoundry.client.v3.processes.TerminateProcessInstanceRequest; @@ -121,6 +123,16 @@ public void get() { .endpoint(null) .build()) .build()) + .readinessHealthCheck( + ReadinessHealthCheck.builder() + .type(ReadinessHealthCheckType.PORT) + .data( + Data.builder() + .interval(null) + .timeout(null) + .endpoint(null) + .build()) + .build()) .metadata( Metadata.builder() .annotations(Collections.emptyMap()) @@ -309,6 +321,16 @@ public void list() { .endpoint(null) .build()) .build()) + .readinessHealthCheck( + ReadinessHealthCheck.builder() + .type(ReadinessHealthCheckType.PORT) + .data( + Data.builder() + .interval(null) + .timeout(null) + .endpoint(null) + .build()) + .build()) .metadata( Metadata.builder() .annotations(Collections.emptyMap()) @@ -367,6 +389,16 @@ public void list() { .endpoint(null) .build()) .build()) + .readinessHealthCheck( + ReadinessHealthCheck.builder() + .type(ReadinessHealthCheckType.PORT) + .data( + Data.builder() + .interval(null) + .timeout(null) + .endpoint(null) + .build()) + .build()) .metadata( Metadata.builder() .annotations(Collections.emptyMap()) @@ -458,6 +490,16 @@ public void scale() { .endpoint(null) .build()) .build()) + .readinessHealthCheck( + ReadinessHealthCheck.builder() + .type(ReadinessHealthCheckType.PORT) + .data( + Data.builder() + .interval(null) + .timeout(null) + .endpoint(null) + .build()) + .build()) .metadata( Metadata.builder() .annotations(Collections.emptyMap()) @@ -545,6 +587,16 @@ public void update() { .endpoint(null) .build()) .build()) + .readinessHealthCheck( + ReadinessHealthCheck.builder() + .type(ReadinessHealthCheckType.PORT) + .data( + Data.builder() + .interval(null) + .timeout(null) + .endpoint(null) + .build()) + .build()) .metadata( Metadata.builder() .annotations(Collections.emptyMap()) diff --git a/cloudfoundry-client-reactor/src/test/resources/fixtures/client/v3/apps/GET_{id}_processes_response.json b/cloudfoundry-client-reactor/src/test/resources/fixtures/client/v3/apps/GET_{id}_processes_response.json index aadb83f8aa2..bd791faf15c 100644 --- a/cloudfoundry-client-reactor/src/test/resources/fixtures/client/v3/apps/GET_{id}_processes_response.json +++ b/cloudfoundry-client-reactor/src/test/resources/fixtures/client/v3/apps/GET_{id}_processes_response.json @@ -28,6 +28,14 @@ "endpoint": null } }, + "readiness_health_check": { + "type": "port", + "data": { + "interval": null, + "endpoint": null, + "invocation_timeout": null + } + }, "metadata": { "annotations": {}, "labels": {} @@ -68,6 +76,14 @@ "endpoint": null } }, + "readiness_health_check": { + "type": "port", + "data": { + "interval": null, + "endpoint": null, + "invocation_timeout": null + } + }, "metadata": { "annotations": {}, "labels": {} diff --git a/cloudfoundry-client-reactor/src/test/resources/fixtures/client/v3/apps/GET_{id}_processes_{type}_response.json b/cloudfoundry-client-reactor/src/test/resources/fixtures/client/v3/apps/GET_{id}_processes_{type}_response.json index a8023d1c74f..d367c69e917 100644 --- a/cloudfoundry-client-reactor/src/test/resources/fixtures/client/v3/apps/GET_{id}_processes_{type}_response.json +++ b/cloudfoundry-client-reactor/src/test/resources/fixtures/client/v3/apps/GET_{id}_processes_{type}_response.json @@ -12,6 +12,14 @@ "endpoint": null } }, + "readiness_health_check": { + "type": "port", + "data": { + "interval": null, + "endpoint": null, + "invocation_timeout": null + } + }, "metadata": { "annotations": {}, "labels": {} diff --git a/cloudfoundry-client-reactor/src/test/resources/fixtures/client/v3/apps/PUT_{id}_processes_{type}_actions_scale_response.json b/cloudfoundry-client-reactor/src/test/resources/fixtures/client/v3/apps/PUT_{id}_processes_{type}_actions_scale_response.json index a8023d1c74f..d367c69e917 100644 --- a/cloudfoundry-client-reactor/src/test/resources/fixtures/client/v3/apps/PUT_{id}_processes_{type}_actions_scale_response.json +++ b/cloudfoundry-client-reactor/src/test/resources/fixtures/client/v3/apps/PUT_{id}_processes_{type}_actions_scale_response.json @@ -12,6 +12,14 @@ "endpoint": null } }, + "readiness_health_check": { + "type": "port", + "data": { + "interval": null, + "endpoint": null, + "invocation_timeout": null + } + }, "metadata": { "annotations": {}, "labels": {} diff --git a/cloudfoundry-client-reactor/src/test/resources/fixtures/client/v3/processes/GET_response.json b/cloudfoundry-client-reactor/src/test/resources/fixtures/client/v3/processes/GET_response.json index 645e8768d8d..0ee0d5c3071 100644 --- a/cloudfoundry-client-reactor/src/test/resources/fixtures/client/v3/processes/GET_response.json +++ b/cloudfoundry-client-reactor/src/test/resources/fixtures/client/v3/processes/GET_response.json @@ -28,6 +28,14 @@ "endpoint": null } }, + "readiness_health_check": { + "type": "port", + "data": { + "interval": null, + "endpoint": null, + "invocation_timeout": null + } + }, "metadata": { "annotations": {}, "labels": {} @@ -68,6 +76,14 @@ "endpoint": null } }, + "readiness_health_check": { + "type": "port", + "data": { + "interval": null, + "endpoint": null, + "invocation_timeout": null + } + }, "metadata": { "annotations": {}, "labels": {} diff --git a/cloudfoundry-client-reactor/src/test/resources/fixtures/client/v3/processes/GET_{id}_response.json b/cloudfoundry-client-reactor/src/test/resources/fixtures/client/v3/processes/GET_{id}_response.json index a8023d1c74f..d367c69e917 100644 --- a/cloudfoundry-client-reactor/src/test/resources/fixtures/client/v3/processes/GET_{id}_response.json +++ b/cloudfoundry-client-reactor/src/test/resources/fixtures/client/v3/processes/GET_{id}_response.json @@ -12,6 +12,14 @@ "endpoint": null } }, + "readiness_health_check": { + "type": "port", + "data": { + "interval": null, + "endpoint": null, + "invocation_timeout": null + } + }, "metadata": { "annotations": {}, "labels": {} diff --git a/cloudfoundry-client-reactor/src/test/resources/fixtures/client/v3/processes/PATCH_{id}_response.json b/cloudfoundry-client-reactor/src/test/resources/fixtures/client/v3/processes/PATCH_{id}_response.json index ccbff60e4a8..f136f02b962 100644 --- a/cloudfoundry-client-reactor/src/test/resources/fixtures/client/v3/processes/PATCH_{id}_response.json +++ b/cloudfoundry-client-reactor/src/test/resources/fixtures/client/v3/processes/PATCH_{id}_response.json @@ -12,6 +12,14 @@ "endpoint": null } }, + "readiness_health_check": { + "type": "port", + "data": { + "interval": null, + "endpoint": null, + "invocation_timeout": null + } + }, "metadata": { "annotations": {}, "labels": {} diff --git a/cloudfoundry-client-reactor/src/test/resources/fixtures/client/v3/processes/POST_{id}_actions_scale_response.json b/cloudfoundry-client-reactor/src/test/resources/fixtures/client/v3/processes/POST_{id}_actions_scale_response.json index a8023d1c74f..d367c69e917 100644 --- a/cloudfoundry-client-reactor/src/test/resources/fixtures/client/v3/processes/POST_{id}_actions_scale_response.json +++ b/cloudfoundry-client-reactor/src/test/resources/fixtures/client/v3/processes/POST_{id}_actions_scale_response.json @@ -12,6 +12,14 @@ "endpoint": null } }, + "readiness_health_check": { + "type": "port", + "data": { + "interval": null, + "endpoint": null, + "invocation_timeout": null + } + }, "metadata": { "annotations": {}, "labels": {} diff --git a/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/processes/Process.java b/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/processes/Process.java index f6314597224..2f0203f2ffd 100644 --- a/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/processes/Process.java +++ b/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/processes/Process.java @@ -43,6 +43,12 @@ public abstract class Process extends Resource { @JsonProperty("health_check") public abstract HealthCheck getHealthCheck(); + /** + * The readiness health check + */ + @JsonProperty("readiness_health_check") + public abstract ReadinessHealthCheck getReadinessHealthCheck(); + /** * The instances */ diff --git a/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/processes/ReadinessHealthCheckType.java b/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/processes/ReadinessHealthCheckType.java new file mode 100644 index 00000000000..2d0a761fbcc --- /dev/null +++ b/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/processes/ReadinessHealthCheckType.java @@ -0,0 +1,69 @@ +/* + * Copyright 2013-2024 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.cloudfoundry.client.v3.processes; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonValue; + +public enum ReadinessHealthCheckType { + + /** + * An http health check + */ + HTTP("http"), + + /** + * A port health check + */ + PORT("port"), + + /** + * A process health check + */ + PROCESS("process"); + + private final String value; + + ReadinessHealthCheckType(String value) { + this.value = value; + } + + @JsonCreator + public static ReadinessHealthCheckType from(String s) { + switch (s.toLowerCase()) { + case "http": + return HTTP; + case "port": + return PORT; + case "process": + return PROCESS; + default: + throw new IllegalArgumentException( + String.format("Unknown health check type: %s", s)); + } + } + + @JsonValue + public String getValue() { + return this.value; + } + + @Override + public String toString() { + return getValue(); + } +} diff --git a/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/processes/_Data.java b/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/processes/_Data.java index 81ab913dc1d..061b3eef025 100644 --- a/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/processes/_Data.java +++ b/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/processes/_Data.java @@ -46,4 +46,11 @@ abstract class _Data { @Nullable abstract Integer getTimeout(); + /** + * The interval + */ + @JsonProperty("interval") + @Nullable + abstract Integer getInterval(); + } diff --git a/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/processes/_ReadinessHealthCheck.java b/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/processes/_ReadinessHealthCheck.java new file mode 100644 index 00000000000..25ae6e009f1 --- /dev/null +++ b/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/processes/_ReadinessHealthCheck.java @@ -0,0 +1,43 @@ +/* + * Copyright 2013-2024 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.cloudfoundry.client.v3.processes; + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import org.cloudfoundry.Nullable; +import org.immutables.value.Value; + +/** + * The health check + */ +@JsonDeserialize +@Value.Immutable +abstract class _ReadinessHealthCheck { + + /** + * The data + */ + @JsonProperty("data") + @Nullable + abstract Data getData(); + + /** + * The type + */ + @JsonProperty("type") + abstract ReadinessHealthCheckType getType(); +} diff --git a/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/processes/_UpdateProcessRequest.java b/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/processes/_UpdateProcessRequest.java index 4fe26b3665e..d00f2a2177f 100644 --- a/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/processes/_UpdateProcessRequest.java +++ b/cloudfoundry-client/src/main/java/org/cloudfoundry/client/v3/processes/_UpdateProcessRequest.java @@ -43,6 +43,13 @@ abstract class _UpdateProcessRequest { @Nullable abstract HealthCheck getHealthCheck(); + /** + * The readiness health check + */ + @JsonProperty("readiness_health_check") + @Nullable + abstract ReadinessHealthCheck getReadinessHealthCheck(); + /** * The process id */ diff --git a/cloudfoundry-operations/src/main/java/org/cloudfoundry/operations/applications/ApplicationManifestUtilsV3.java b/cloudfoundry-operations/src/main/java/org/cloudfoundry/operations/applications/ApplicationManifestUtilsV3.java index eb1ee96a55d..40a96dc5c8e 100644 --- a/cloudfoundry-operations/src/main/java/org/cloudfoundry/operations/applications/ApplicationManifestUtilsV3.java +++ b/cloudfoundry-operations/src/main/java/org/cloudfoundry/operations/applications/ApplicationManifestUtilsV3.java @@ -33,6 +33,7 @@ import java.util.regex.Pattern; import java.util.stream.Stream; import org.cloudfoundry.client.v3.processes.HealthCheckType; +import org.cloudfoundry.client.v3.processes.ReadinessHealthCheckType; import org.yaml.snakeyaml.DumperOptions; import org.yaml.snakeyaml.Yaml; import reactor.core.Exceptions; @@ -209,6 +210,27 @@ private static ManifestV3Process getProcess( variables, s -> HealthCheckType.from((String) s), builder::healthCheckType); + asString( + raw, + "readiness-health-check-http-endpoint", + variables, + builder::readinessHealthCheckHttpEndpoint); + asInteger( + raw, + "readiness-health-check-invocation-timeout", + variables, + builder::readinessHealthCheckInvocationTimeout); + asInteger( + raw, + "readiness-health-check-interval", + variables, + builder::readinessHealthCheckInterval); + as( + raw, + "readiness-health-check-type", + variables, + s -> ReadinessHealthCheckType.from((String) s), + builder::readinessHealthCheckType); asInteger(raw, "instances", variables, builder::instances); asString(raw, "memory", variables, builder::memory); asInteger(raw, "timeout", variables, builder::timeout); @@ -294,6 +316,17 @@ private static Map toProcessYaml(ManifestV3Process process) { putIfPresent( yaml, "health-check-invocation-timeout", process.getHealthCheckInvocationTimeout()); putIfPresent(yaml, "health-check-type", process.getHealthCheckType()); + putIfPresent(yaml, "readiness-health-check-type", process.getReadinessHealthCheckType()); + putIfPresent( + yaml, + "readiness-health-check-http-endpoint", + process.getReadinessHealthCheckHttpEndpoint()); + putIfPresent( + yaml, + "readiness-health-check-invocation-timeout", + process.getReadinessHealthCheckInvocationTimeout()); + putIfPresent( + yaml, "readiness-health-check-interval", process.getReadinessHealthCheckInterval()); putIfPresent(yaml, "instances", process.getInstances()); putIfPresent(yaml, "memory", process.getMemory()); putIfPresent(yaml, "timeout", process.getTimeout()); diff --git a/cloudfoundry-operations/src/main/java/org/cloudfoundry/operations/applications/_ManifestV3Process.java b/cloudfoundry-operations/src/main/java/org/cloudfoundry/operations/applications/_ManifestV3Process.java index a39e55c66c1..0504676d8b9 100644 --- a/cloudfoundry-operations/src/main/java/org/cloudfoundry/operations/applications/_ManifestV3Process.java +++ b/cloudfoundry-operations/src/main/java/org/cloudfoundry/operations/applications/_ManifestV3Process.java @@ -19,6 +19,7 @@ import org.cloudfoundry.Nullable; import org.cloudfoundry.client.v3.processes.HealthCheckType; +import org.cloudfoundry.client.v3.processes.ReadinessHealthCheckType; import org.immutables.value.Value; @Value.Immutable @@ -54,6 +55,30 @@ abstract class _ManifestV3Process { @Nullable abstract HealthCheckType getHealthCheckType(); + /** + * Type of rediness health check to perform + */ + @Nullable + abstract ReadinessHealthCheckType getReadinessHealthCheckType(); + + /** + * The HTTP rediness health check endpoint + */ + @Nullable + abstract String getReadinessHealthCheckHttpEndpoint(); + + /** + * The timeout in seconds for individual rediness health check requests for http and port health checks + */ + @Nullable + abstract Integer getReadinessHealthCheckInvocationTimeout(); + + /** + * The timeout in seconds for individual rediness health check requests for http and port health checks + */ + @Nullable + abstract Integer getReadinessHealthCheckInterval(); + /** * The number of instances of this process */