dotnet / docker-tools

This is a repo to house some common tools for our various docker repos.
MIT License
124 stars 46 forks source link

Regression of loading git2-106a5f2 library from libgit2sharp #1105

Closed mthalman closed 1 year ago

mthalman commented 1 year ago

The building a new version of Image Builder and running its publishImageInfo command results in the following exception:

-- Cloning GitHub repo
Unhandled exception: System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation.
 ---> System.TypeInitializationException: The type initializer for 'LibGit2Sharp.Core.NativeMethods' threw an exception.
 ---> System.DllNotFoundException: Unable to load shared library 'git2-106a5f2' or one of its dependencies. In order to help diagnose loading problems, consider setting the LD_DEBUG environment variable: Error loading shared library libgit2-106a5f2: No such file or directory
   at LibGit2Sharp.Core.NativeMethods.git_libgit2_init()
   at LibGit2Sharp.Core.NativeMethods.InitializeNativeLibrary()
   at LibGit2Sharp.Core.NativeMethods..cctor()
   --- End of inner exception stack trace ---
   at LibGit2Sharp.Core.NativeMethods.git_clone(git_repository*& repo, String origin_url, FilePath workdir_path, GitCloneOptions& opts)
   at LibGit2Sharp.Core.Proxy.git_clone(String url, String workdir, GitCloneOptions& opts)
   at LibGit2Sharp.Repository.Clone(String sourceUrl, String workdirPath, CloneOptions options)
   at Microsoft.DotNet.ImageBuilder.GitService.CloneRepository(String sourceUrl, String workdirPath, CloneOptions options) in /image-builder/src/GitService.cs:line 20
   at Microsoft.DotNet.ImageBuilder.Commands.PublishImageInfoCommand.ExecuteAsync() in /image-builder/src/Commands/PublishImageInfoCommand.cs:line 46
   at Microsoft.DotNet.ImageBuilder.Commands.Command`2.<GetCliCommand>b__9_0(TOptions options) in /image-builder/src/Commands/Command.TOptions.cs:line 46

Note that this shows up in the PR validation from rebuilding a new version of Image Builder: https://dev.azure.com/dnceng-public/public/_build/results?buildId=132680&view=logs&j=046815c1-7653-5dfd-0c09-c18aa9ed7f03&t=a1a5cb5d-ae12-5188-d4ce-56f5f8c7faa9

I'm guessing this is related to the update of the Alpine floating tag that is referenced in the Image Builder Dockerfile to be moved to Alpine 3.17: https://github.com/dotnet/dotnet-docker/discussions/4313. This is also related to https://github.com/dotnet/dotnet-docker/pull/2111 which requires specifying the appropriate RID to get the necessary native library. So something has changed which has broken how things were working before.

mthalman commented 1 year ago

It'd be interesting to know whether https://github.com/dotnet/docker-tools/pull/1104 resolves the issue too but I kind of doubt it.

mthalman commented 1 year ago

One thing to verify on this is whether it is related to change from Alpine 3.16 to Alpine 3.17. This can be validated by setting the Alpine tag to a version-specific tag:

https://github.com/dotnet/docker-tools/blob/d5bd95e0a886fe56d6abfc5e5b1f229edef03935/src/Microsoft.DotNet.ImageBuilder/Dockerfile.linux#L27

alpine would be changed to alpine3.16