WolfgangOfner / Ado-Agent-Keda

Run Azure DevOps Agent in Kubernetes using KEDA
2 stars 3 forks source link

Issue in running azurite in the docker image #1

Open Arash-Sabet opened 7 months ago

Arash-Sabet commented 7 months ago

Hi @WolfgangOfner

I read through your article about the keda agent and I have to say that it was amazing! Thanks for sharing it.

We have an integration test project running as a part of our Azure DevOps' pipeline that uses azurite to run a few tests. So, I modified the docker yaml file to include azurite in the image. Here it is the script to achieve this goal:

RUN sudo apt-get -y install nodejs
RUN sudo apt-get install -y nodejs npm
RUN sudo npm install -g azurite
RUN sudo npm fund
RUN sudo mkdir azurite
RUN sudo azurite --silent --location azuritefiles --debug azuritefiles\debug.log &

The image is built and run successfully and it does not exhibit a problem but the integration tests fail due to the error message below:

Connection refused (127.0.0.1:10000)

Apparently the azurite instance is not launched or its port is unavailable within the docker. Hard to tell which one is happening. Just wondering, do you happen to have a solution or advice to address this issue? Thanks.

WolfgangOfner commented 7 months ago

I have never used Azurite therefore I am not able to help you unfortunately.

Arash-Sabet commented 7 months ago

@WolfgangOfner Anything else similar to running another application within the docker image that you may have worked?

WolfgangOfner commented 7 months ago

You can have multiple applications running inside a docker container, for example with a script starting them, but I have never done that. For my integration tests, I usually use real Azure resources. I create them before the test starts and delete them after the test is finished.

Arash-Sabet commented 7 months ago

You can have multiple applications running inside a docker container, for example with a script starting them, but I have never done that. For my integration tests, I usually use real Azure resources. I create them before the test starts and delete them after the test is finished.

Yes, using azure resources is another approach too but we want to contain everything in the docker image to avoid creating expensive databases on cloud. Having another database within the image is another goal to achieve but communicating with it keeps failing likely due to the same reason as the communication with Azurite does. So, I picked a less complex application like Azurite in the code snippet.

WolfgangOfner commented 7 months ago

You could run a second container with your database or azurite in your pipeline. Take a look at: https://devblogs.microsoft.com/devops/using-containerized-services-in-your-pipeline

Arash-Sabet commented 7 months ago

Thanks @WolfgangOfner I'll have a look.

Arash-Sabet commented 6 months ago

@WolfgangOfner Finally I managed to run Azurite in the docker image and the integration tests requiring Azurite can access it and started passing. This is the script snippet for that:

RUN sudo azurite --blobHost 0.0.0.0 --queueHost 0.0.0.0 --tableHost 0.0.0.0 -s -l /usr/local/lib/node_modules/azurite -d /usr/local/lib/node_modules/azurite/debug.log &

This success happens when the docker image runs on a local machine (e.g. my laptop) and connected to the build agent. The strange thing is that the azurite's instance is no longer accessible when the image is pushed to the ACR and pulled by the k8s cluster. Hence, the integration tests requiring azurite has started failing. I monitored the events through the k8s Event blade on Azure's portal and realized that the updated images were pulled successfully. Any idea why it happens on k8s?

WolfgangOfner commented 6 months ago

Hmm no idea why it does not work in k8s. Do you get any error messages?

Arash-Sabet commented 6 months ago

Connection refused to "host.docker.internal:10000". I changed it to 127.0.0.1:10000 but no luck either.

WolfgangOfner commented 6 months ago

Where is the port 10000 coming from? You could try to allow all ports using the following command:

--blobPort 0 --queuePort 0 --tablePort 0

https://learn.microsoft.com/en-us/azure/storage/common/storage-use-azurite?tabs=github%2Cblob-storage#command-line-options

Arash-Sabet commented 6 months ago

Where is the port 10000 coming from? You could try to allow all ports using the following command:

--blobPort 0 --queuePort 0 --tablePort 0

https://learn.microsoft.com/en-us/azure/storage/common/storage-use-azurite?tabs=github%2Cblob-storage#command-line-options

The ports are 10000, 10001 and 10002 by default if one elects not to specify them.

Arash-Sabet commented 6 months ago

I have a feeling that azurite never launches! It's a difficult situation to address!