Skip to content

Alpine 3.19 runtime is not supported by 6.0.27 #5243

Closed

Description

@attilaersek

Describe the Bug

Alpine 3.19 is not supported by .net 6.0 version 6.0.27, and breaks platform specific code, like SqlClient.

Steps to Reproduce

dotnet --info

Runtime Environment is

Runtime Environment:
 OS Name:     alpine
 OS Version:  3.19
 OS Platform: Linux
 RID:         alpine.3.19-x64
 Base Path:   /usr/lib/dotnet/sdk/6.0.127/
cat /etc/os-release
NAME="Alpine Linux"
ID=alpine
VERSION_ID=3.19.1
PRETTY_NAME="Alpine Linux v3.19"
HOME_URL="https://alpinelinux.org/"
BUG_REPORT_URL="https://gitlab.alpinelinux.org/alpine/aports/-/issues"

However the dotnet supported runtimes list does not know about 3.19 version:

cat /usr/share/dotnet/shared/Microsoft.NETCore.App/6.0.27/Microsoft.NETCore.App.deps.json | jq '.runtimes["alpine
.3.18-x64"]'
[
  "alpine.3.18",
...
  "unix",
  "any",
  "base"
]

cat /usr/share/dotnet/shared/Microsoft.NETCore.App/6.0.27/Microsoft.NETCore.App.deps.json | jq '.runtimes["alpine
.3.19-x64"]'
null

Activity

  1. ghost added
    area-dockerfiles
    on Mar 6, 2024
  2. lbussell commented on Mar 6, 2024

    @lbussell
    Member

    Maybe related: dotnet/runtime#96155

    @tmds @agocke since you both responded on that issue, is this something that the DOTNET_RUNTIME_ID environment variable would fix? Would you expect that we set that environment variable in our container images for new OSes on .NET 6/7?

  3. tmds commented on Mar 7, 2024

    @tmds
    Member

    Yes, you should set the envvar in the images, and that should fix this issue.

  4. lbussell commented on Mar 7, 2024

    @lbussell
    Member

    [Triage] I'm unable to reproduce this issue with the latest .NET SDK on Alpine 3.19. I see the portable RID, not the Alpine 3.19 RID when I run dotnet --info on the latest .NET SDK:

    > docker pull mcr.microsoft.com/dotnet/sdk:6.0-alpine3.19
    > docker run --rm mcr.microsoft.com/dotnet/sdk:6.0-alpine3.19 dotnet --info
    
    Runtime Environment:
     OS Name:     alpine
     OS Version:  3.19
     OS Platform: Linux
     RID:         linux-musl-x64
     Base Path:   /usr/share/dotnet/sdk/6.0.419/
    

    I noticed that you are running the 6.0.127 version of the SDK. This repo has never shipped a 6.0.127 version of the SDK in a container image. We always ship the latest feature band that's available in container images.

    I also noticed that you didn't mention Docker at all in your issue - just want to check that you are running this in one of the official .NET containers (from mcr.microsoft.com/dotnet/*)?

  5. omajid commented on Mar 7, 2024

    @omajid
    Member
  6. attilaersek commented on Mar 7, 2024

    @attilaersek
    Author

    [Triage] I'm unable to reproduce this issue with the latest .NET SDK on Alpine 3.19. I see the portable RID, not the Alpine 3.19 RID when I run dotnet --info on the latest .NET SDK:

    > docker pull mcr.microsoft.com/dotnet/sdk:6.0-alpine3.19
    > docker run --rm mcr.microsoft.com/dotnet/sdk:6.0-alpine3.19 dotnet --info
    
    Runtime Environment:
     OS Name:     alpine
     OS Version:  3.19
     OS Platform: Linux
     RID:         linux-musl-x64
     Base Path:   /usr/share/dotnet/sdk/6.0.419/
    

    I noticed that you are running the 6.0.127 version of the SDK. This repo has never shipped a 6.0.127 version of the SDK in a container image. We always ship the latest feature band that's available in container images.

    I also noticed that you didn't mention Docker at all in your issue - just want to check that you are running this in one of the official .NET containers (from mcr.microsoft.com/dotnet/*)?

    I've encountered this issue with the latest runtime docker image.
    The SDK was just installed manually after exec into the container to check what's going on. Sorry for the confusion.

  7. attilaersek commented on Mar 7, 2024

    @attilaersek
    Author

    @lbussell please see the runtime mentioned in my report: 6.0.27.

  8. tmds commented on Mar 7, 2024

    @tmds
    Member

    We have a test for this here: https://github.com/redhat-developer/dotnet-regular-tests/tree/main/host-probes-rid-assets-legacy.

    You can run it in the container image using these commands:

    apk update
    apk add bash
    git clone https://github.com/redhat-developer/dotnet-regular-tests/
    cd dotnet-regular-tests/host-probes-rid-assets-legacy/
    ./test.sh 

    If you run it in mcr.microsoft.com/dotnet/sdk:6.0-alpine3.19, you'll see it fails.

    If you run it with DOTNET_RUNTIME_ID=linux-musl-x64 or DOTNET_RUNTIME_ID=alpine.3.18-x64 set, it will pass.

    The test creates nuget packages. To avoid picking up the packages from the previous run, it's simplest to use a fresh container each time you run it.

  9. ayakael commented on Mar 7, 2024

    @ayakael

    This looks like a bug on the Alpine Linux version of dotnet6. Some logics were backported from 7.0 to automatically add RIDs in the graph rather than adding them manually. It might not have worked, finally. Is this the Alpine Linux package, as added by apk add dotnet6-sdk?

    EDIT: Disregard this. it is actually not a problem on the packaged version of Alpine Linux. The logics that we patched in actually work, but because they were never merged upstream runtime should've continued updating the RID graph manually.

  10. tmds commented on Mar 8, 2024

    @tmds
    Member

    it is actually not a problem on the packaged version of Alpine Linux.

    Yes, the issue is in the upstream/Microsoft builds for .NET 6 witch rely on manual updates of the graph.

  11. attilaersek commented on Mar 8, 2024

    @attilaersek
    Author

    Reproduction:

    Dockerfile:

    FROM mcr.microsoft.com/dotnet/sdk:6.0.419-alpine3.19-amd64 as builder
    WORKDIR /app
    RUN dotnet new console && \ 
        dotnet add package System.Data.SqlClient && \
        echo "new System.Data.SqlClient.SqlConnection("").Open();" >> Program.cs && \
        dotnet publish --output publish
    FROM mcr.microsoft.com/dotnet/runtime:6.0.27-alpine3.19-amd64
    WORKDIR /app
    COPY --from=builder /app/publish .
    CMD dotnet app.dll

    Execution:

    docker build . -t test
    docker run -it --rm test

    output:

    Hello, World!
    Unhandled exception. System.PlatformNotSupportedException: System.Data.SqlClient is not supported on this platform.
       at System.Data.SqlClient.SqlConnection..ctor()
       at Program.<Main>$(String[] args) in /app/Program.cs:line 3

    I can confirm that setting the DOTNET_RUNTIME_ID=linux-musl-x64 solves the problem:

    docker run -e DOTNET_RUNTIME_ID=linux-musl-x64  -it --rm test
    Hello, World!
    Unhandled exception. System.InvalidOperationException: The ConnectionString property has not been initialized.
       at System.Data.SqlClient.SqlConnection.PermissionDemand()
  12. 2 remaining items

  13. agocke commented on Mar 9, 2024

    @agocke
    Member

    It's not clear to me why the RID graph isn't still being updated for 6.0

    Sorry, this one's on me for losing track. We've also had some reorg of ownership of various components.

    If bringing RID updates for 6.0 is the only answer, we can do so. That said, I find updating the RID graph in servicing very distasteful. The servicing bar is reserved for bug fixes and security fixes, not support for new platforms. Our willingness to do this in the past speaks to the limited options we had.

    If adding DOTNET_RUNTIME_ID is sufficient to provide support for .NET 6, I'd much rather we go with that solution.

  14. richlander commented on Mar 11, 2024

    @richlander
    Member

    I think the ENV may be sufficient. I suggest we start with that and see if we get feedback that motivates anything else.

  15. ayakael commented on Mar 11, 2024

    @ayakael

    I would expect that this issue would affect the portable build targetting alpine-linux available via dotnet.microsoft.com? If that is the case then RIDs should be updated for every alpine release, as that means that the portable build is broken on release. It is expected that .NET 6.0 will reach EOL just before release of Alpine 3.21. Perhaps we should pre-emptively add RIDs for 3.19 and 3.20?

  16. richlander commented on Mar 11, 2024

    @richlander
    Member

    Do you think there is a significant .NET user base of Alpine outside of containers? Honest question.

    We're not quite there yet, but our maintenance policy doesn't include support for new OS versions. If there are acceptable workarounds for new OSes, we'll be motivated to rely on those.

    https://github.com/dotnet/core/blob/main/release-policies.md#support-phases

  17. lbussell commented on Mar 11, 2024

    @lbussell
    Member

    If adding DOTNET_RUNTIME_ID is sufficient to provide support for .NET 6, I'd much rather we go with that solution.

    I don't have enough knowledge about the runtime to know if the environment variable will fix all scenarios or not. We are debating delaying adding this env var to containers in case we want to add the Alpine 3.19 to the .NET 6 RID graph. Because it would be a second breaking change to remove it after the fact.

    The servicing bar is reserved for bug fixes and security fixes

    Is this not a kind of bug fix? If we have added RIDs to .NET 6 all the way up through 3.18, I feel like we should continue, otherwise we break users like the author of this issue.

    From @ayakael:

    I would expect that this issue would affect the portable build targetting alpine-linux available via dotnet.microsoft.com?

    Yes, that is the build that we ship here in the Microsoft-created .NET container images.

  18. richlander commented on Mar 11, 2024

    @richlander
    Member

    Is this not a bug fix?

    No, it isn't a bug fix. There is no "bug".

    Support for new operating system versions will be provided ...

    This is what it is.

  19. ayakael commented on Mar 11, 2024

    @ayakael

    @richlander Good question, I don't know. But, indeed, as @lbussell has said, we've added RIDs all through 3.18, and did the same for Fedora. This is not a question of adding a new platform, but continuing to maintain a rather strange way of doing things that, fortunately, is not required starting with .NET 7 due to work by @tmds, among others.

  20. richlander commented on Mar 11, 2024

    @richlander
    Member

    I didn't realize that you can only specify portable RIDs with this ENV. That's challenging.

    One point of context is that we have a floating tag for Alpine. We can only update that to new Alpine versions if we're offering something compatible. We need to continue offering this floating tag because that's what customers expect.

    Runtime needs to continue updating the RID graph to this end.

  21. ayakael commented on Mar 11, 2024

    @ayakael
  22. moved this from Backlog to In Progress in .NET Dockeron Mar 13, 2024
  23. moved this from In Progress to Rollout in .NET Dockeron Mar 13, 2024
  24. lbussell commented on Apr 12, 2024

    @lbussell
    Member

    Just tried @attilaersek's repro with mcr.microsoft.com/dotnet/sdk:6.0.421-alpine3.19-amd64 and mcr.microsoft.com/dotnet/runtime:6.0.29-alpine3.19-amd64, the issue appears to be fixed:

    PS> docker run --rm test  
    Hello, World!
    Unhandled exception. System.InvalidOperationException: The ConnectionString property has not been initialized.
       at System.Data.SqlClient.SqlConnection.PermissionDemand()
    ...

    Thanks @agocke @ayakael @richlander for pushing this through!

  25. moved this from Rollout to Done in .NET Dockeron Apr 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-dockerfiles

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions