fix(General): fix for cm-dev deployment
Build and Publish Docker Image / build-and-push (push) Waiting to run
Unit test coverage / pytest (push) Failing after 1m32s
/ build-and-push (push) Successful in 1m35s

This commit is contained in:
2025-07-08 18:38:40 +08:00
parent fde6f17b58
commit 771154facd
5 changed files with 13 additions and 12 deletions
+1 -1
View File
@@ -38,4 +38,4 @@ jobs:
file: ./Dockerfile file: ./Dockerfile
no-cache: true no-cache: true
push: true push: true
tags: ${{ env.REGISTRY_URL }}/${{ env.REPOSITORY }}:latest tags: ${{ env.REGISTRY_URL }}/${{ env.REPOSITORY }}:20250708-01
@@ -491,6 +491,9 @@ class CleverThisServiceAdapter:
_routes = self.routes.get(method, []) _routes = self.routes.get(method, [])
_path, _args = AMQDataParser.parse_get_url(message.path()) _path, _args = AMQDataParser.parse_get_url(message.path())
for _route in _routes: for _route in _routes:
# TODO: here the regex will match with path prefix,
# but it might not be a stable feature that we could rely on.
# Need to figure out something stable for the prefix path.
_match = _route.path_regex.match(_path) _match = _route.path_regex.match(_path)
if _match: if _match:
_args.update(_match.groupdict()) _args.update(_match.groupdict())
+2 -8
View File
@@ -125,10 +125,7 @@ class DataMessageHandler:
""" """
# Increment the counter for parallel executions and check resource availability # Increment the counter for parallel executions and check resource availability
self.backpressure_handler.increase_parallel_executions() self.backpressure_handler.increase_parallel_executions()
await self.backpressure_handler.check_resource_availability( await self.backpressure_handler.check_overload_condition()
self.backpressure_handler.current_parallel_executions,
self.backpressure_handler.parallel_workers,
)
logging_info( logging_info(
f"PARALLEL: Current Capacity [{self.backpressure_handler.current_parallel_executions}] of [{self.backpressure_handler.parallel_workers}]" f"PARALLEL: Current Capacity [{self.backpressure_handler.current_parallel_executions}] of [{self.backpressure_handler.parallel_workers}]"
) )
@@ -159,10 +156,7 @@ class DataMessageHandler:
logging_error(f"Request handler: {e}") logging_error(f"Request handler: {e}")
self.backpressure_handler.decrease_parallel_executions() self.backpressure_handler.decrease_parallel_executions()
await self.backpressure_handler.check_resource_availability( await self.backpressure_handler.check_overload_condition()
self.backpressure_handler.current_parallel_executions,
self.backpressure_handler.parallel_workers,
)
async def reconstitute_data_message( async def reconstitute_data_message(
self, message: AbstractIncomingMessage self, message: AbstractIncomingMessage
+3 -2
View File
@@ -94,6 +94,7 @@ internal_api_call_duration_histogram = meter.create_histogram(
app = FastAPI( app = FastAPI(
title="CleverMicro Document Service Demo", title="CleverMicro Document Service Demo",
description="A FastAPI application demonstrating OpenTelemetry integration with Jaeger and Prometheus.", description="A FastAPI application demonstrating OpenTelemetry integration with Jaeger and Prometheus.",
# root_path="/otdemo", # This won't affect router path
) )
# Instrument FastAPI: Automatically creates spans for incoming requests # Instrument FastAPI: Automatically creates spans for incoming requests
@@ -105,8 +106,6 @@ HTTPXClientInstrumentor().instrument()
UPLOAD_DIR = "/tmp/clevermicro_documents" UPLOAD_DIR = "/tmp/clevermicro_documents"
os.makedirs(UPLOAD_DIR, exist_ok=True) os.makedirs(UPLOAD_DIR, exist_ok=True)
otadapter = OTDemoAmqpAdapter(AMQConfiguration("otdemo/otdemo.properties"), app.routes)
@app.post("/api/v3/documents") @app.post("/api/v3/documents")
async def upload_document( async def upload_document(
@@ -223,6 +222,8 @@ async def get_documents():
return {"documents": documents} return {"documents": documents}
# Need to place below all route methods, otherwise the routes are incomplete
otadapter = OTDemoAmqpAdapter(AMQConfiguration("otdemo/otdemo.properties"), app.routes)
# --- How to Run the Demo --- # --- How to Run the Demo ---
# 1. Save the code: # 1. Save the code:
# Save the Python code above as `main.py` in a new directory. # Save the Python code above as `main.py` in a new directory.
+4 -1
View File
@@ -11,7 +11,10 @@ cm.amq-adapter.generator-id=1
# Route mapping. For route detail description see section 3.1 in Onboarding Guide for Python: # Route mapping. For route detail description see section 3.1 in Onboarding Guide for Python:
# https://docs.cleverthis.com/en/architecture/microservices/onboarding/python # https://docs.cleverthis.com/en/architecture/microservices/onboarding/python
# NOTE: this is a comma-separated list of route mappings (multiple, comma-separated routes are allowed here) # NOTE: this is a comma-separated list of route mappings (multiple, comma-separated routes are allowed here)
cm.amq-adapter.route-mapping=otdemo::otdemo:otdemo.localhost.#:5:0 # cm-dev route
cm.amq-adapter.route-mapping=otdemo:otdemo-exchange:otdemo-queue:api.cm.dev.cleverthis.com.test-python.#:5:0
# local route
#cm.amq-adapter.route-mapping=otdemo::otdemo:api.dev.localhost.otdemo.#:5:0
# Indicate if AMQ Adapter should respond with HTTP 401 Unauthorized if the request does not contain valid JWT token # Indicate if AMQ Adapter should respond with HTTP 401 Unauthorized if the request does not contain valid JWT token
cm.amq-adapter.require-authenticated-user=false cm.amq-adapter.require-authenticated-user=false