Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[on hold] Verify, that grpc can be used for Openshift probes #1212

Closed
wants to merge 1 commit into from
Closed
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
@@ -0,0 +1,23 @@
package io.quarkus.ts.opentelemetry.reactive.grpc;

import io.quarkus.example.HealthCheckRequest;
import io.quarkus.example.HealthCheckResponse;
import io.quarkus.example.HealthService;
import io.quarkus.grpc.GrpcService;
import io.smallrye.mutiny.Multi;
import io.smallrye.mutiny.Uni;

@GrpcService
// todo this should return statuses, but it isn't failing the deployment
public class GrpcHealthService implements HealthService {

@Override
public Uni<HealthCheckResponse> check(HealthCheckRequest request) {
return Uni.createFrom().failure(new RuntimeException("Error!"));
}

@Override
public Multi<HealthCheckResponse> watch(HealthCheckRequest request) {
return Multi.createFrom().failure(new RuntimeException("Error!"));
}
}
25 changes: 25 additions & 0 deletions monitoring/opentelemetry-reactive/src/main/proto/health.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
syntax = "proto3";

option java_multiple_files = true;
option java_package = "io.quarkus.example";

package grpc.health.v1;;

message HealthCheckRequest {
string service = 1;
}

message HealthCheckResponse {
enum ServingStatus {
UNKNOWN = 0;
SERVING = 1;
NOT_SERVING = 2;
SERVICE_UNKNOWN = 3; // Used only by the Watch method.
}
ServingStatus status = 1;
}

service HealthService {
rpc Check(HealthCheckRequest) returns (HealthCheckResponse);
rpc Watch(HealthCheckRequest) returns (stream HealthCheckResponse);
}
Original file line number Diff line number Diff line change
@@ -7,4 +7,8 @@ io.quarkus.ts.opentelemetry.reactive.sse.ServerSentEventsPongClient/mp-rest/scop
# gRPC
quarkus.grpc.clients.pong.host=localhost

quarkus.application.name=pingpong
quarkus.application.name=pingpong

quarkus.openshift.readiness-probe.grpc-action=9000:grpc.health.v1.HealthService
quarkus.openshift.startup-probe.grpc-action=9000:grpc.health.v1.HealthService
quarkus.openshift.liveness-probe.grpc-action=9000:grpc.health.v1.HealthService
Original file line number Diff line number Diff line change
@@ -18,7 +18,7 @@
import io.quarkus.test.services.QuarkusApplication;

@QuarkusScenario
public class OpenTelemetryGrpcIT {
public class GrpcIT {

@JaegerContainer(useOtlpCollector = true)
static final JaegerService jaeger = new JaegerService();
@@ -61,5 +61,4 @@ protected void assertTraceIdWithPongService(String expected) {

assertEquals(expected, pongTraceId);
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
package io.quarkus.ts.opentelemetry.reactive;

import java.util.List;

import jakarta.inject.Inject;

import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;

import io.fabric8.kubernetes.api.model.Container;
import io.fabric8.kubernetes.api.model.GRPCAction;
import io.fabric8.kubernetes.api.model.Pod;
import io.fabric8.kubernetes.api.model.Probe;
import io.quarkus.test.bootstrap.inject.OpenShiftClient;
import io.quarkus.test.scenarios.OpenShiftDeploymentStrategy;
import io.quarkus.test.scenarios.OpenShiftScenario;

@OpenShiftScenario(deployment = OpenShiftDeploymentStrategy.UsingOpenShiftExtension)
public class OpenShiftGrpcIT extends GrpcIT {

@Inject
static OpenShiftClient oc;

@Test
void grpcProbes() {
List<Pod> pods = oc.podsInService(app);
Assertions.assertEquals(1, pods.size());
List<Container> containers = pods.get(0).getSpec().getContainers();
Assertions.assertEquals(1, containers.size());
Container container = containers.get(0);
validateProbe(container.getLivenessProbe());
validateProbe(container.getReadinessProbe());
}

private static void validateProbe(Probe probe) {
Assertions.assertNotNull(probe);
GRPCAction grpcAction = probe.getGrpc();
Assertions.assertNotNull(grpcAction);
Assertions.assertEquals("grpc.health.v1.HealthService", grpcAction.getService());
Assertions.assertEquals(9000, grpcAction.getPort());
michalvavrik marked this conversation as resolved.
Show resolved Hide resolved
}
}