Azure / Azurite

A lightweight server clone of Azure Storage that simulates most of the commands supported by it with minimal dependencies
MIT License
1.8k stars 320 forks source link

Provide healthcheck feature in Docker image #1666

Open dkarlovi opened 2 years ago

dkarlovi commented 2 years ago

Which service(blob, file, queue, table) does this issue concern?

Blob.

Which version of the Azurite was used?

3.19.0

Where do you get Azurite? (npm, DockerHub, NuGet, Visual Studio Code Extension)

DockerHub

What's the Node.js version?

In Docker image.

What problem was encountered?

When running in CI, the sequencing needs to be done correctly. This means the tests with the storage will try to use it at some point where it might or might not have already started.

When running with Docker, the common solution is to provide a healthcheck.

Steps to reproduce the issue?

Start Azurite in Docker and attempt to use it immediately from another process, the requests have a 50%-50% chance to fail since the process is not fully started yet.

Have you found a mitigation/solution?

Creating a healthcheck yourself.

Example Docker Compose file with healthcheck:

services:
    storage:
        image: mcr.microsoft.com/azure-storage/azurite:3.19.0
        healthcheck: 
            test: nc 127.0.0.1 10000 -z
            interval: 1s
            retries: 30
blueww commented 2 years ago

@dkarlovi

Thanks for raising this issue! It looks you have already found a way to resolve this.

Feel free to raise if any further Azurite support needed.

dkarlovi commented 2 years ago

Hey @blueww, you mistakenly tagged both of my created issues as questions, these are feature suggestions, there's no question asked here.

blueww commented 2 years ago

@dkarlovi

Would you please describe what's the detail change you would like Azurite to take?

Azurite welcome contribution! It would be great if you can raise a PR to add the new features to Azurite!

dkarlovi commented 2 years ago

@blueww in short, Azurite should be able to answer a query if it's fully running or not (as in, init ready, sockets opened, ready for queries).

This could be done with having a dedicated HTTP endpoint (ie. /_health) or answer to a signal (say, SIGUSR1 or both, to confirm it's fully booted (or not).

Then, either one of the mechanisms would be either added to Dockerfile, like so

HEALTHCHECK ["kill", "-s", "USR1", "1"]

and the Docker image users could rely on

depends_on:
    azurite_container:
        condition: service_healthy

without needing to do anything themselves.

blueww commented 2 years ago

@dkarlovi

Thanks for the clarification!

Azurite welcome contribution! It would be great if you could raise a PR to add the new features to Azurite!

bogdanobogeanu commented 1 year ago

Hello,

Was this implemented? Something like /_health, that dkarlovi mentioned? I want to implement azurite into a hybris container and to expose it from AWS via an Application load balancer and without a health check, target groups will remain unhealthy and the connections will not be routed to NLB and container.

dkarlovi commented 1 year ago

@bogdanobogeanu see https://github.com/Azure/Azurite/issues/1665#issuecomment-1236796659 as a poor-person's version of it.

LeonardHd commented 3 months ago

Have you found a mitigation/solution?

Creating a healthcheck yourself.

Example Docker Compose file with healthcheck:

services:
    storage:
        image: mcr.microsoft.com/azure-storage/azurite:3.19.0
        healthcheck: 
            test: nc 127.0.0.1 10000 -z
            interval: 1s
            retries: 30

@dkarlovi this worked for us thanks.

We had an issue with azurite not being ready when starting azurite via docker compose with -d. A health check would be great to have!