Skip to content
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

Cannot run via Docker on M1 Mac #1888

Closed
dabernathy89 opened this issue Oct 14, 2022 · 6 comments · Fixed by #1973
Closed

Cannot run via Docker on M1 Mac #1888

dabernathy89 opened this issue Oct 14, 2022 · 6 comments · Fixed by #1973
Assignees
Labels
generator Issues or improvements relater to generation capabilities. type:bug A broken experience
Milestone

Comments

@dabernathy89
Copy link

The command I'm running:

docker run --platform linux/amd64 -v ~/code/kiota-test/output:/app/output mcr.microsoft.com/openapi/kiota generate --language typescript -n PetsSdk --openapi https://petstore3.swagger.io/api/v3/openapi.json

The output:

Unhandled exception: System.IO.IOException: Function not implemented
   at System.IO.FileSystemWatcher.StartRaisingEvents()
   at System.IO.FileSystemWatcher.StartRaisingEventsIfNotDisposed()
   at System.IO.FileSystemWatcher.set_EnableRaisingEvents(Boolean value)
   at Microsoft.Extensions.FileProviders.Physical.PhysicalFilesWatcher.TryEnableFileSystemWatcher()
   at Microsoft.Extensions.FileProviders.Physical.PhysicalFilesWatcher.CreateFileChangeToken(String filter)
   at Microsoft.Extensions.FileProviders.PhysicalFileProvider.Watch(String filter)
   at Microsoft.Extensions.Configuration.FileConfigurationProvider.<.ctor>b__1_0()
   at Microsoft.Extensions.Primitives.ChangeToken.ChangeTokenRegistration`1..ctor(Func`1 changeTokenProducer, Action`1 changeTokenConsumer, TState state)
   at Microsoft.Extensions.Primitives.ChangeToken.OnChange(Func`1 changeTokenProducer, Action changeTokenConsumer)
   at Microsoft.Extensions.Configuration.FileConfigurationProvider..ctor(FileConfigurationSource source)
   at Microsoft.Extensions.Configuration.Json.JsonConfigurationProvider..ctor(JsonConfigurationSource source)
   at Microsoft.Extensions.Configuration.Json.JsonConfigurationSource.Build(IConfigurationBuilder builder)
   at Microsoft.Extensions.Configuration.ConfigurationBuilder.Build()
   at kiota.Handlers.BaseKiotaCommandHandler.<>c.<.ctor>b__23_0() in /app/kiota/src/kiota/Handlers/BaseKiotaCommandHandler.cs:line 21
   at System.Lazy`1.ViaFactory(LazyThreadSafetyMode mode)
   at System.Lazy`1.ExecutionAndPublication(LazyHelper executionAndPublication, Boolean useDefaultConstructor)
   at System.Lazy`1.CreateValue()
   at System.Lazy`1.get_Value()
   at kiota.Handlers.BaseKiotaCommandHandler.get_Configuration() in /app/kiota/src/kiota/Handlers/BaseKiotaCommandHandler.cs:line 18
   at kiota.Handlers.KiotaGenerationCommandHandler.AssignIfNotNullOrEmpty(String input, Action`2 assignment) in /app/kiota/src/kiota/Handlers/KiotaGenerationCommandHandler.cs:line 95
   at kiota.Handlers.KiotaGenerationCommandHandler.InvokeAsync(InvocationContext context) in /app/kiota/src/kiota/Handlers/KiotaGenerationCommandHandler.cs:line 48
   at System.CommandLine.Invocation.InvocationPipeline.<>c__DisplayClass4_0.<<BuildInvocationChain>b__0>d.MoveNext()
--- End of stack trace from previous location ---
   at System.CommandLine.Builder.CommandLineBuilderExtensions.<>c__DisplayClass17_0.<<UseParseErrorReporting>b__0>d.MoveNext()
--- End of stack trace from previous location ---
   at System.CommandLine.Builder.CommandLineBuilderExtensions.<>c__DisplayClass12_0.<<UseHelp>b__0>d.MoveNext()
--- End of stack trace from previous location ---
   at System.CommandLine.Builder.CommandLineBuilderExtensions.<>c__DisplayClass22_0.<<UseVersionOption>b__0>d.MoveNext()
--- End of stack trace from previous location ---
   at System.CommandLine.Builder.CommandLineBuilderExtensions.<>c__DisplayClass19_0.<<UseTypoCorrections>b__0>d.MoveNext()
--- End of stack trace from previous location ---
   at System.CommandLine.Builder.CommandLineBuilderExtensions.<>c.<<UseSuggestDirective>b__18_0>d.MoveNext()
--- End of stack trace from previous location ---
   at System.CommandLine.Builder.CommandLineBuilderExtensions.<>c__DisplayClass16_0.<<UseParseDirective>b__0>d.MoveNext()
--- End of stack trace from previous location ---
   at System.CommandLine.Builder.CommandLineBuilderExtensions.<>c.<<RegisterWithDotnetSuggest>b__5_0>d.MoveNext()
--- End of stack trace from previous location ---
   at System.CommandLine.Builder.CommandLineBuilderExtensions.<>c__DisplayClass8_0.<<UseExceptionHandler>b__0>d.MoveNext()
@baywet baywet self-assigned this Oct 16, 2022
@baywet baywet added type:bug A broken experience Needs: Author Feedback generator Issues or improvements relater to generation capabilities. labels Oct 16, 2022
@baywet
Copy link
Member

baywet commented Oct 16, 2022

Hi @dabernathy89,
Thanks for trying out Kiota and for letting us know.
Unfortunately, I don't have access to an M1 machine to run some tests, so if you're willing to help diagnose and solve this issue, it'd be greatly appreciated.

The dockerfile is located here, and the issue is most likely triggered by the reload on change setting here

My suggestion for you would be to set the value to false/remove it, build the image locally and see whether that solves the issue. I don't think we need reload on change enabled since Kiota is a CLI and all processes are short lived anyway.
If that works, would you be so kind to submit a pull request with the change please?

Thanks a lot!

@baywet baywet added this to Kiota Oct 16, 2022
@baywet baywet moved this to Todo in Kiota Oct 16, 2022
@baywet baywet moved this from Todo to In Progress in Kiota Oct 16, 2022
@ghost

This comment was marked as outdated.

@ghost ghost closed this as completed Oct 23, 2022
Repository owner moved this from In Progress to Done in Kiota Oct 23, 2022
@baywet
Copy link
Member

baywet commented Nov 8, 2022

Reopening this as it seems this is still an issue from internal feedback.
Yes disabling the reload on change helps (and we don't need it anyway), but it's not enough.

We also need to setup a multi-platform build of the image https://docs.docker.com/build/building/multi-platform/
Additionally, when running in a container with the --co switch, we should alter the target path to delete the content of the directory, not the directly itself (locked because mapped).

crit: Kiota.Builder.KiotaBuilder[0]
      error generating the client: Could not open/create output directory /app/./output, reason: Device or resource busy : '/app/output'

@baywet baywet reopened this Nov 8, 2022
Repository owner moved this from Done to In Progress in Kiota Nov 8, 2022
@baywet baywet mentioned this issue Nov 9, 2022
@baywet
Copy link
Member

baywet commented Nov 9, 2022

update: I have put a PR together to remove the barriers as well as enable multi-platform images. Before I merge it, if somebody with an M1 could try to run ghcr.io/baywet/kiota:latest and provide feedback here, it'd help.

@baywet baywet moved this from In Progress to Todo in Kiota Nov 22, 2022
@baywet baywet added this to the Kiota post-GA milestone Dec 6, 2022
@baywet
Copy link
Member

baywet commented Dec 30, 2022

Update: thanks to @kevinswiber 's help it seems that we're affected by this, and it's because the base dotnet image is not a true arm64 variant

The solution would be to either downgrade to net6 with all the compatibility and performance implications (new linq methods, vectorialization, etc...) or conditionally build on with a different base

more resources: https://www.docker.com/blog/multi-arch-build-and-images-the-simple-way/

@github-project-automation github-project-automation bot moved this from Todo to Done in Kiota Jan 4, 2023
@baywet
Copy link
Member

baywet commented Jan 4, 2023

update: @kevinswiber was instrumental to finding the solution to this issue. Just merged the corresponding PR, releasing soon. :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
generator Issues or improvements relater to generation capabilities. type:bug A broken experience
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

2 participants