Add readiness check for S3

This commit is contained in:
Lauri Võsandi 2022-07-28 09:19:14 +03:00
parent 3472e494f4
commit 3d1aa220dd

View File

@ -483,6 +483,16 @@ async def stream_wrapper(request):
@app.route("/readyz") @app.route("/readyz")
async def ready_check(request): async def ready_check(request):
# Check if S3 is accessible
session = aioboto3.Session()
async with session.resource("s3",
aws_access_key_id=AWS_ACCESS_KEY_ID,
aws_secret_access_key=AWS_SECRET_ACCESS_KEY,
endpoint_url=S3_ENDPOINT_URL) as s3:
bucket = await s3.Bucket(S3_BUCKET_NAME)
await bucket.upload_fileobj(io.BytesIO(b"test"), "test")
# Check if Mongo is accessible
try: try:
async for i in app.ctx.coll.find().limit(1): async for i in app.ctx.coll.find().limit(1):
break break