Skip to content
Snippets Groups Projects
Commit 460fbdbc authored by fsoldatos's avatar fsoldatos
Browse files

feat(automation): implement readiness probe funtionality

parent 73f923be
No related branches found
No related tags found
1 merge request!54Release 2.0.0
# Define the host for the Context Service # Define the host for the Context Service
quarkus.kubernetes.env.vars.context-service-host=context quarkus.kubernetes.env.vars.context-service-host=ContextService
# Define the host for the Device Service # Define the host for the Device Service
quarkus.kubernetes.env.vars.device-service-host=device quarkus.kubernetes.env.vars.device-service-host=DeviceService
\ No newline at end of file \ No newline at end of file
...@@ -4,6 +4,7 @@ import eu.teraflow.automation.context.ContextService; ...@@ -4,6 +4,7 @@ import eu.teraflow.automation.context.ContextService;
import eu.teraflow.automation.device.model.DeviceEvent; import eu.teraflow.automation.device.model.DeviceEvent;
import io.quarkus.runtime.StartupEvent; import io.quarkus.runtime.StartupEvent;
import io.smallrye.mutiny.Multi; import io.smallrye.mutiny.Multi;
import java.time.Duration;
import javax.enterprise.context.ApplicationScoped; import javax.enterprise.context.ApplicationScoped;
import javax.enterprise.event.Observes; import javax.enterprise.event.Observes;
import javax.inject.Inject; import javax.inject.Inject;
...@@ -29,7 +30,15 @@ public class ContextSubscriber { ...@@ -29,7 +30,15 @@ public class ContextSubscriber {
} }
public void listenForDeviceEvents() { public void listenForDeviceEvents() {
Multi<DeviceEvent> deviceEventsMulti = contextService.getDeviceEvents();
Multi<DeviceEvent> deviceEventsMulti =
contextService
.getDeviceEvents()
.onFailure()
.retry()
.withBackOff(Duration.ofSeconds(1))
.withJitter(0.2)
.atMost(10);
deviceEventsMulti deviceEventsMulti
.onItem() .onItem()
......
...@@ -11,6 +11,6 @@ public class SimpleLivenessCheck implements HealthCheck { ...@@ -11,6 +11,6 @@ public class SimpleLivenessCheck implements HealthCheck {
@Override @Override
public HealthCheckResponse call() { public HealthCheckResponse call() {
return HealthCheckResponse.up("Automation Service"); return HealthCheckResponse.up("Automation Service is live");
} }
} }
package eu.teraflow.automation;
import javax.enterprise.context.ApplicationScoped;
import org.eclipse.microprofile.health.HealthCheck;
import org.eclipse.microprofile.health.HealthCheckResponse;
import org.eclipse.microprofile.health.Readiness;
@Readiness
@ApplicationScoped
public class SimpleReadinessCheck implements HealthCheck {
@Override
public HealthCheckResponse call() {
return HealthCheckResponse.up("Automation Service is ready");
}
}
...@@ -38,5 +38,5 @@ quarkus: ...@@ -38,5 +38,5 @@ quarkus:
container-port: 9999 container-port: 9999
env: env:
vars: vars:
context-service-host: context context-service-host: ContextService
device-service-host: device device-service-host: DeviceService
\ No newline at end of file \ No newline at end of file
...@@ -3,8 +3,8 @@ apiVersion: v1 ...@@ -3,8 +3,8 @@ apiVersion: v1
kind: Service kind: Service
metadata: metadata:
annotations: annotations:
app.quarkus.io/commit-id: 43db942bd5641ae293df75b65cd1eefd40b8085e app.quarkus.io/commit-id: 6b96f471f66e6bb59357856c635f8d7e1ce98a5c
app.quarkus.io/build-timestamp: 2021-11-17 - 06:42:01 +0000 app.quarkus.io/build-timestamp: 2021-11-19 - 15:03:07 +0000
labels: labels:
app.kubernetes.io/name: automationservice app.kubernetes.io/name: automationservice
app.kubernetes.io/version: 0.0.1 app.kubernetes.io/version: 0.0.1
...@@ -27,8 +27,8 @@ apiVersion: apps/v1 ...@@ -27,8 +27,8 @@ apiVersion: apps/v1
kind: Deployment kind: Deployment
metadata: metadata:
annotations: annotations:
app.quarkus.io/commit-id: 43db942bd5641ae293df75b65cd1eefd40b8085e app.quarkus.io/commit-id: 6b96f471f66e6bb59357856c635f8d7e1ce98a5c
app.quarkus.io/build-timestamp: 2021-11-17 - 06:42:01 +0000 app.quarkus.io/build-timestamp: 2021-11-19 - 15:03:07 +0000
labels: labels:
app: automationservice app: automationservice
app.kubernetes.io/name: automationservice app.kubernetes.io/name: automationservice
...@@ -43,8 +43,8 @@ spec: ...@@ -43,8 +43,8 @@ spec:
template: template:
metadata: metadata:
annotations: annotations:
app.quarkus.io/commit-id: 43db942bd5641ae293df75b65cd1eefd40b8085e app.quarkus.io/commit-id: 6b96f471f66e6bb59357856c635f8d7e1ce98a5c
app.quarkus.io/build-timestamp: 2021-11-17 - 06:42:01 +0000 app.quarkus.io/build-timestamp: 2021-11-19 - 15:03:07 +0000
labels: labels:
app: automationservice app: automationservice
app.kubernetes.io/name: automationservice app.kubernetes.io/name: automationservice
...@@ -56,10 +56,10 @@ spec: ...@@ -56,10 +56,10 @@ spec:
valueFrom: valueFrom:
fieldRef: fieldRef:
fieldPath: metadata.namespace fieldPath: metadata.namespace
- name: CONTEXT_SERVICE_HOST
value: context
- name: DEVICE_SERVICE_HOST - name: DEVICE_SERVICE_HOST
value: device value: DeviceService
- name: CONTEXT_SERVICE_HOST
value: ContextService
image: registry.gitlab.com/teraflow-h2020/controller/automation:0.0.1 image: registry.gitlab.com/teraflow-h2020/controller/automation:0.0.1
imagePullPolicy: Always imagePullPolicy: Always
livenessProbe: livenessProbe:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment