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
4 changes: 4 additions & 0 deletions deploy/helm/mock-fleet/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,8 @@ The chart creates a static S3 CSI PV/PVC and mounts it into:
| `fleet.proxy.image.tag` | `""` | Proxy image tag. Defaults to the chart `appVersion` when empty. |
| `fleet.proxy.image.pullPolicy` | `IfNotPresent` | Proxy image pull policy. |
| `fleet.proxy.routing.mode` | `HOST` | Mock routing mode: `HOST` or `PATH`. |
| `fleet.proxy.logging.json` | `false` | Enable JSON console logging for the proxy. |
| `fleet.proxy.logging.level` | `INFO` | Proxy `com.github.letsrokk` log level; use `TRACE` to log proxied requests. |
| `fleet.proxy.replicas` | `2` | Proxy replica count when dev mode is disabled. |
| `fleet.proxy.service.type` | `ClusterIP` | Proxy service type. |
| `fleet.proxy.service.ports.http` | `80` | Proxy service HTTP port. |
Expand Down Expand Up @@ -120,6 +122,8 @@ The chart creates a static S3 CSI PV/PVC and mounts it into:
| `fleet.api.image.pullPolicy` | `IfNotPresent` | API image pull policy. |
| `fleet.api.podInactivityThreshold` | `1M` | Time before inactive mock pods are eligible for cleanup. |
| `fleet.api.podCreationTimeout` | `1M` | Time to wait for a spawned WireMock pod to become ready. |
| `fleet.api.logging.json` | `false` | Enable JSON console logging for the API. |
| `fleet.api.logging.level` | `INFO` | API `com.github.letsrokk` log level. |
| `fleet.api.replicas` | `2` | API replica count when dev mode is disabled; must be at least two for embedded Hazelcast redundancy. |
| `fleet.api.terminationGracePeriodSeconds` | `300` | Time allowed for graceful Hazelcast member shutdown and partition migration. |
| `fleet.api.updateStrategy.type` | `RollingUpdate` | API deployment update strategy. |
Expand Down
4 changes: 4 additions & 0 deletions deploy/helm/mock-fleet/templates/api-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,10 @@ spec:
value: {{ .Values.fleet.api.podInactivityThreshold | quote }}
- name: MOCK_FLEET_POD_CREATION_TIMEOUT
value: {{ .Values.fleet.api.podCreationTimeout | quote }}
- name: QUARKUS_LOG_CONSOLE_JSON
value: {{ .Values.fleet.api.logging.json | quote }}
- name: QUARKUS_LOG_CATEGORY_COM_GITHUB_LETSROKK_LEVEL
value: {{ .Values.fleet.api.logging.level | quote }}
- name: MOCK_FLEET_WIREMOCK_POD_NAME_PREFIX
value: {{ .Values.wiremock.podNamePrefix | quote }}
- name: MOCK_FLEET_WIREMOCK_CONTAINER_NAME
Expand Down
4 changes: 4 additions & 0 deletions deploy/helm/mock-fleet/templates/proxy-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@ spec:
value: {{ .Values.ingress.host | quote }}
- name: MOCK_FLEET_API_BASE_URL
value: {{ printf "http://%s" (include "mock-fleet.apiFullname" .) | quote }}
- name: QUARKUS_LOG_CONSOLE_JSON
value: {{ .Values.fleet.proxy.logging.json | quote }}
- name: QUARKUS_LOG_CATEGORY_COM_GITHUB_LETSROKK_LEVEL
value: {{ .Values.fleet.proxy.logging.level | quote }}
{{- if .Values.fleet.proxy.dev.enabled }}
- name: QUARKUS_LAUNCH_DEVMODE
value: {{ .Values.fleet.proxy.dev.quarkusLaunchDevmode | quote }}
Expand Down
8 changes: 8 additions & 0 deletions deploy/helm/mock-fleet/values.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,14 @@
"image": { "$ref": "#/definitions/image" },
"dev": { "$ref": "#/definitions/dev" },
"routing": { "type": "object" },
"logging": {
"type": "object",
"properties": {
"json": { "type": "boolean" },
"level": { "type": "string", "enum": ["TRACE", "DEBUG", "INFO", "WARN", "ERROR", "FATAL", "OFF"] }
},
"required": ["json", "level"]
},
"replicas": { "type": "integer", "minimum": 1 },
"service": { "type": "object" },
"probes": { "type": "object" },
Expand Down
6 changes: 6 additions & 0 deletions deploy/helm/mock-fleet/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ fleet:
pullPolicy: IfNotPresent
routing:
mode: HOST
logging:
json: false
level: INFO
replicas: 2
service:
type: ClusterIP
Expand Down Expand Up @@ -62,6 +65,9 @@ fleet:
pullPolicy: IfNotPresent
podInactivityThreshold: 1M
podCreationTimeout: 1M
logging:
json: false
level: INFO
replicas: 2
terminationGracePeriodSeconds: 30
updateStrategy:
Expand Down
4 changes: 4 additions & 0 deletions fleet-api/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,10 @@
<groupId>io.quarkus</groupId>
<artifactId>quarkus-config-yaml</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-logging-json</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-cache</artifactId>
Expand Down
11 changes: 7 additions & 4 deletions fleet-api/src/main/java/com/github/letsrokk/PodManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,8 @@ public MockPodRef spawnPod(String mockId) {
.create();

pod = waitForPodToBeRunning(pod, podCreationTimeout);
LOG.infof("Created pod '%s' for mock id '%s' in namespace '%s'.",
pod.getMetadata().getName(), mockId, namespace);
return podRef(pod);
}

Expand Down Expand Up @@ -188,10 +190,11 @@ public void cleanUpIdlePods() {
boolean deleted = deletePod(pod);

if (deleted) {
LOG.infof("Pod '%s' deleted successfully.", pod.podName());
LOG.infof("Pod '%s' deleted for mock id '%s' after %dms of inactivity.",
pod.podName(), mockId, diff);
podState.removePod(mockId);
} else {
LOG.warnf("Failed to delete Pod '%s'.", pod.podName());
LOG.warnf("Failed to delete inactive pod '%s' for mock id '%s'.", pod.podName(), mockId);
}
}
});
Expand All @@ -217,9 +220,9 @@ public void cleanUpOrphanedPods() {
if (isOrphaned) {
boolean deleted = deletePod(p);
if (deleted) {
LOG.infof("Pod '%s' deleted successfully.", podName);
LOG.infof("Orphaned pod '%s' deleted in namespace '%s'.", podName, namespace);
} else {
LOG.warnf("Failed to delete Pod '%s'.", podName);
LOG.warnf("Failed to delete orphaned pod '%s' in namespace '%s'.", podName, namespace);
}
}
});
Expand Down
7 changes: 7 additions & 0 deletions fleet-api/src/main/resources/application.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
quarkus:
log:
console:
json: ${QUARKUS_LOG_CONSOLE_JSON:false}
category:
"com.github.letsrokk":
min-level: TRACE
level: ${QUARKUS_LOG_CATEGORY_COM_GITHUB_LETSROKK_LEVEL:INFO}
smallrye-health:
root-path: /__fleet/api/health
container-image:
Expand Down
4 changes: 4 additions & 0 deletions fleet-proxy/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,10 @@
<groupId>io.quarkus</groupId>
<artifactId>quarkus-config-yaml</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-logging-json</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-smallrye-health</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ void forward(RoutingContext routingContext, String host, ResolvedRequest resolve
fleetApiClient.resolveUpstreamBaseUrl(resolvedRequest.mockId())
.map(URI::create)
.onSuccess(upstream -> {
LOG.debugf("Proxying %s %s for host '%s' and mock id '%s' to upstream %s as %s.",
LOG.tracef("Proxy request method=%s uri=%s host=%s mockId=%s upstream=%s upstreamUri=%s.",
routingContext.request().method(),
routingContext.request().uri(),
host,
Expand Down Expand Up @@ -103,6 +103,10 @@ private io.vertx.core.Future<Void> forward(URI upstream, String upstreamRequestU
}

private io.vertx.core.Future<Void> writeResponse(RoutingContext routingContext, HttpResponse<Buffer> response) {
LOG.tracef("Proxy response method=%s uri=%s status=%d.",
routingContext.request().method(),
routingContext.request().uri(),
response.statusCode());
routingContext.response().setStatusCode(response.statusCode());
response.headers().forEach(header -> routingContext.response().putHeader(header.getKey(), header.getValue()));
Buffer responseBody = response.body();
Expand Down
7 changes: 7 additions & 0 deletions fleet-proxy/src/main/resources/application.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
quarkus:
log:
console:
json: ${QUARKUS_LOG_CONSOLE_JSON:false}
category:
"com.github.letsrokk":
min-level: TRACE
level: ${QUARKUS_LOG_CATEGORY_COM_GITHUB_LETSROKK_LEVEL:INFO}
smallrye-health:
root-path: /__fleet/proxy/health
container-image:
Expand Down
Loading