-
-
Notifications
You must be signed in to change notification settings - Fork 286
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Bug]: MsSql health check does not complete on newest container image #1220
Comments
We see the same problem at the moment. |
This is also affecting us when it's running inside our GitHub Actions for CI/CD. It's currently preventing us from doing any releases. |
I confirm that our tests using TestContainers and MsSQL stopped passing today 🤕 |
When looking at the image it seems that path for |
FYI someone has reported it on MSSQL-Docker: microsoft/mssql-docker#892 |
As mentioned in Slack, we likely need to adapt the default wait strategy (see https://github.com/testcontainers/testcontainers-dotnet/blob/develop/src/Testcontainers.MsSql/MsSqlBuilder.cs#L132-L145). Users can provide their own wait strategy configuration as a workaround. |
This started blocking our Azure DevOps pipeline yesterday. |
after @pascalberger comment en combined with @kiview i first ran into certificate issues:
but got it working for now by also adding the -C option:
|
This works when run locally, but still times out when run in an Azure DevOps pipeline:
This times out in both:
|
I have been able to replicate this locally by deleting the cached 2022-latest container image. After it downloads the latest image, it hangs indefinitely. Adding |
@tscrip that did it. We missed a test project so had a false negative. Thanks! |
This is also affecting .NET Aspire - dotnet/aspire#5057 |
.. with testcontainers because the path `/opt/mssql-tools/bin/sqlcmd` changed to `/opt/mssql-tools18/bin/sqlcmd`. But this hardcoded path is being used in testcontainers, causing it to fail. testcontainers/testcontainers-dotnet#1220 microsoft/mssql-docker#892
.. because the path `/opt/mssql-tools/bin/sqlcmd` changed to `/opt/mssql-tools18/bin/sqlcmd`. And this is being used in `samples/DatabaseContainers/DatabaseContainers.AppHost/sqlserverconfig/configure-db.sh`. testcontainers/testcontainers-dotnet#1220 microsoft/mssql-docker#892
…testcontainers (#5058) * [tests] Workaround sqlserver 2022-latest latest image failing .. with testcontainers because the path `/opt/mssql-tools/bin/sqlcmd` changed to `/opt/mssql-tools18/bin/sqlcmd`. But this hardcoded path is being used in testcontainers, causing it to fail. testcontainers/testcontainers-dotnet#1220 microsoft/mssql-docker#892 * add comment referencing the issue
* Workaround sqlserver 2022-latest latest image failing .. because the path `/opt/mssql-tools/bin/sqlcmd` changed to `/opt/mssql-tools18/bin/sqlcmd`. And this is being used in `samples/DatabaseContainers/DatabaseContainers.AppHost/sqlserverconfig/configure-db.sh`. testcontainers/testcontainers-dotnet#1220 microsoft/mssql-docker#892 * Fix sqlcmd invocation to trust the server certificate Fixes: ``` Sqlcmd: Error: Microsoft ODBC Driver 18 for SQL Server : TCP Provider: Error code 0x2749. Sqlcmd: Error: Microsoft ODBC Driver 18 for SQL Server : SSL Provider: [error:0A000086:SSL routines::certificate verify failed:self-signed certificate]. Sqlcmd: Error: Microsoft ODBC Driver 18 for SQL Server : A network-related or instance-specific error has occurred while establishing a connection to 2d77e8a3691a. Server is not found or not accessible. Check if instance name is correct and if SQL Server is configured to allow remote connections. For more information see SQL Server Books Online.. Sqlcmd: Error: Microsoft ODBC Driver 18 for SQL Server : Client unable to establish connection. For solutions related to encryption errors, see https://go.microsoft.com/fwlink/?linkid=2226722. ```
After reading all these comments, I would like to point out that we recommend pinning the image version. Using the Since it looks like the new path will remain (microsoft/mssql-docker#892 (comment)), we can update the default wait strategy for the new version. Overriding the wait strategy, as @Fireblade954 suggested, or pinning the version are workarounds to avoid this issue. We can probably do something similar to what we are doing in the MongoDB module to determine which binary (path) is available. |
* Workaround sqlserver 2022-latest latest image failing .. because the path `/opt/mssql-tools/bin/sqlcmd` changed to `/opt/mssql-tools18/bin/sqlcmd`. And this is being used in `samples/DatabaseContainers/DatabaseContainers.AppHost/sqlserverconfig/configure-db.sh`. testcontainers/testcontainers-dotnet#1220 microsoft/mssql-docker#892 * Fix sqlcmd invocation to trust the server certificate Fixes: ``` Sqlcmd: Error: Microsoft ODBC Driver 18 for SQL Server : TCP Provider: Error code 0x2749. Sqlcmd: Error: Microsoft ODBC Driver 18 for SQL Server : SSL Provider: [error:0A000086:SSL routines::certificate verify failed:self-signed certificate]. Sqlcmd: Error: Microsoft ODBC Driver 18 for SQL Server : A network-related or instance-specific error has occurred while establishing a connection to 2d77e8a3691a. Server is not found or not accessible. Check if instance name is correct and if SQL Server is configured to allow remote connections. For more information see SQL Server Books Online.. Sqlcmd: Error: Microsoft ODBC Driver 18 for SQL Server : Client unable to establish connection. For solutions related to encryption errors, see https://go.microsoft.com/fwlink/?linkid=2226722. ```
BTW this will also break the |
This works for us: .WithWaitStrategy(Wait.ForUnixContainer().UntilPortIsAvailable(1433)) |
This won't always work as the container might be ready but MSSQL might not be ready to receive requests. |
Thats true, although it fails very rarely, atleast for us, and it will usually work, regardless of old or new image from microsoft. I have now rewritten to use |
Testcontainers version
3.9.0
Using the latest Testcontainers version?
Yes
Host OS
Linux
Host arch
x64
.NET version
8.0.303
Docker version
Client: Version: 25.0.5 API version: 1.44 Go version: go1.21.10 Git commit: d260a54c81efcc3f00fe67dee78c94b16c2f8692 Built: Sun May 12 07:25:43 2024 OS/Arch: linux/amd64 Context: default Server: Engine: Version: 25.0.5 API version: 1.44 (minimum version 1.24) Go version: go1.21.10 Git commit: e63daec8672d77ac0b2b5c262ef525c7cf17fd20 Built: Sun May 12 07:25:43 2024 OS/Arch: linux/amd64 Experimental: false containerd: Version: v1.7.10 GitCommit: 4e1fe7492b9df85914c389d1f15a3ceedbb280ac runc: Version: 1.1.12 GitCommit: 51d5e94601ceffbbd85688df1c928ecccbfa4685 docker-init: Version: 0.19.0 GitCommit:
Docker info
What happened?
When using the
MsSql
package with the newest container image mcr.microsoft.com/mssql/server:2022-latest with a digest ofsha256:c1aa8afe9b06eab64c9774a4802dcd032205d1be785b1fd51e1c0151e7586b74
, the health check specified in the waiting strategy never completes, even though the logs of the SQL server container show it being ready, leading to a timeout.This behavior is not present when using a slightly older container image version, e.g. mcr.microsoft.com/mssql/server:2022-CU13-ubuntu-22.04 with a digest of
sha256:c4369c38385eba011c10906dc8892425831275bb035d5ce69656da8e29de50d8
.Relevant log output
Additional information
No response
The text was updated successfully, but these errors were encountered: