cloudfoundry / dotnet-core-buildpack

Cloud Foundry buildpack for .NET Core on Linux
http://docs.cloudfoundry.org/buildpacks/
Apache License 2.0
91 stars 90 forks source link

Pushing a not self contained application doesn't work for buildpack 2.2.3 #202

Closed wormst closed 5 years ago

wormst commented 5 years ago

What version of Cloud Foundry and CF CLI are you using? (i.e. What is the output of running cf curl /v2/info && cf version? CF CLI version: 2.107.0 Cloud Foundry version: 6.37.0+a40009753.2018-05-25

What version of the buildpack you are using? 2.1.5 & 2.2.3

If you were attempting to accomplish a task, what was it you were attempting to do? Do a successful cf push with a dotnet app previously published with a flag --self-contained=false

Is your dotnet app unpublished, platform-dependant, or self-contained? Published, ubuntu-x64

What did you expect to happen? That in both cases (for both buildpacks) application will be successfully deployed.

What was the actual behavior? For buildpack 2.1.5 - success For buildpack 2.2.3 - exception was thrown: 2019-01-09T14:06:26.07-0500 [APP/PROC/WEB/1] ERR It was not possible to find any compatible framework version 2019-01-09T14:06:26.07-0500 [APP/PROC/WEB/1] ERR The specified framework 'Microsoft.AspNetCore.App', version '2.1.5' was not found. 2019-01-09T14:06:26.07-0500 [APP/PROC/WEB/1] ERR - Check application dependencies and target a framework version installed at: 2019-01-09T14:06:26.07-0500 [APP/PROC/WEB/1] ERR /home/vcap/app/ 2019-01-09T14:06:26.07-0500 [APP/PROC/WEB/1] ERR - Installing .NET Core prerequisites might help resolve this problem: 2019-01-09T14:06:26.07-0500 [APP/PROC/WEB/1] ERR http://go.microsoft.com/fwlink/?LinkID=798306&clcid=0x409 2019-01-09T14:06:26.07-0500 [APP/PROC/WEB/1] ERR - The .NET Core framework and SDK can be installed from: 2019-01-09T14:06:26.07-0500 [APP/PROC/WEB/1] ERR https://aka.ms/dotnet-download

Reproduction steps:

  1. Create dotnet core application with version 2.1 pointing to 2.1.5 ASP.NET Core nuget package
  2. Publish app: dotnet publish -r ubuntu-x64 --self-contained=false
  3. Do a cf push with that app against different version of buildpack installed in cf a) 2.1.5 (success) b) 2.2.3 (fail)

Please confirm where necessary:

cf-gitbot commented 5 years ago

We have created an issue in Pivotal Tracker to manage this:

https://www.pivotaltracker.com/story/show/163098157

The labels on this github issue will be updated when the story is started.

michalkisielewski commented 5 years ago

I found out that the issue does not appear if won't specify the framework during dotnet publish (without -r flag). What's the difference between 2.1.5 and 2.2.3 that it is working only on the first one?

sclevine commented 5 years ago

To support staging in offline environments, each buildpack release only contains a subset of the available versions of .NET Core. Generally, we make the last two patch versions of each supported version line of each type of .NET Core core dependency available in each release. The versions in each release are available here: https://buildpacks.cloudfoundry.org/#/buildpacks/dotnet/v2.2.3

To configure your app so that it does not lock to a particular framework version, see here: https://docs.cloudfoundry.org/buildpacks/dotnet-core/index.html#dotnet-runtime

That said, 2.2.3 contains Microsoft.AspNetCore.App version 2.1.5, so I'm not sure why you're seeing that error. Could you provide a sample app that fails to help us debug?

tylerphelan commented 5 years ago

@michalkisielewski we tested this with the steps you provided while including the -r flag with buildpack version 2.2.3 and it pushed successfully.

A sample app as well as the version of your .NET SDK and the full buildpack staging logs would be helpful to keep digging!

michalkisielewski commented 5 years ago

Hey, so these are the steps from my side to reproduce that:

  1. Create application using dotnet new webapi - this should produce csproj with <TargetFramework>netcoreapp2.2</TargetFramework> inside.
  2. Publish application using following command: dotnet publish -r ubuntu-x64 --self-contained=false -c Release
  3. Navigate to publish folder created from above and push the application with following command: cf push TestApp -b https://github.com/cloudfoundry/dotnet-core-buildpack/releases/download/v2.2.3/dotnet-core-buildpack-cflinuxfs2-v2.2.3.zip
  4. Observe results:
    
    Pushing app TestApp to [...] ...
    Getting app info...
    Creating app with these attributes...
    + name:        TestApp
    path:        [path]\TestApp\bin\Release\netcoreapp2.2\ubuntu-x64\publish
    + buildpack:   https://github.com/cloudfoundry/dotnet-core-buildpack/releases/download/v2.2.3/dotnet-core-buildpack-cflinuxfs2-v2.2.3.zip
    routes:
    +   testapp.[domain]

Creating app TestApp... Mapping routes... Comparing local files to remote cache... Packaging files to upload... Uploading files... 5.05 KiB / 5.05 KiB [=====================================================================================] 100.00% 1s

Waiting for API to complete processing files...

Staging app and tracing logs... Cell fd243838-a68b-498a-bcb4-5f0342e759eb creating container for instance cd43e772-e623-462a-aa66-8ef073381019 Cell fd243838-a68b-498a-bcb4-5f0342e759eb successfully created container for instance cd43e772-e623-462a-aa66-8ef073381019 Downloading app package... Downloaded app package (466.2K) Downloaded buildpack https://github.com/cloudfoundry/dotnet-core-buildpack/releases/download/v2.2.3/dotnet-core-buildpack-cflinuxfs2-v2.2.3.zip (4.8M) -----> Dotnet-Core Buildpack version 2.2.3 -----> Supplying Dotnet Core -----> Installing libunwind 1.2.1 Download [https://buildpacks.cloudfoundry.org/dependencies/libunwind/libunwind-1.2.1-cflinuxfs2-db7f7257.tar.gz] using the default SDK -----> Installing dotnet-sdk 2.2.100 Download [https://buildpacks.cloudfoundry.org/dependencies/dotnet-sdk/dotnet-sdk.2.2.100.linux-amd64-cflinuxfs2-a2545b4d.tar.xz] -----> Installing dotnet-runtime 2.2.0 Download [https://buildpacks.cloudfoundry.org/dependencies/dotnet-runtime/dotnet-runtime.2.2.0.linux-amd64-cflinuxfs2-b3b3e85c.tar.xz] -----> Finalizing Dotnet Core -----> Installing dotnet-aspnetcore 2.2.0 Download [https://buildpacks.cloudfoundry.org/dependencies/dotnet-aspnetcore/dotnet-aspnetcore.2.2.0.linux-amd64-cflinuxfs2-43bb9b05.tar.xz] -----> Installing dotnet-runtime 2.2.0 Download [https://buildpacks.cloudfoundry.org/dependencies/dotnet-runtime/dotnet-runtime.2.2.0.linux-amd64-cflinuxfs2-b3b3e85c.tar.xz] -----> Cleaning staging area Removing dotnet-sdk Exit status 0 Uploading droplet, build artifacts cache... Uploading build artifacts cache... Uploading droplet... Uploaded build artifacts cache (104.8M) Uploaded droplet (1.4M) Uploading complete Cell fd243838-a68b-498a-bcb4-5f0342e759eb stopping instance cd43e772-e623-462a-aa66-8ef073381019 Cell fd243838-a68b-498a-bcb4-5f0342e759eb destroying container for instance cd43e772-e623-462a-aa66-8ef073381019 Cell fd243838-a68b-498a-bcb4-5f0342e759eb successfully destroyed container for instance cd43e772-e623-462a-aa66-8ef073381019

Waiting for app to start... Start unsuccessful

TIP: use 'cf logs TestApp --recent' for more information FAILED



Logs from `cf logs TestApp --recent`:
```2019-01-10T17:14:45.63-0500 [STG/0] OUT Downloaded app package (466.2K)
   2019-01-10T17:14:46.92-0500 [STG/0] OUT -----> Dotnet-Core Buildpack version 2.2.3
   2019-01-10T17:14:46.93-0500 [STG/0] OUT -----> Supplying Dotnet Core
   2019-01-10T17:14:46.93-0500 [STG/0] OUT -----> Installing libunwind 1.2.1
   2019-01-10T17:14:46.93-0500 [STG/0] OUT        Download [https://buildpacks.cloudfoundry.org/dependencies/libunwind/libunwind-1.2.1-cflinuxfs2-db7f7257.tar.gz]
   2019-01-10T17:14:47.19-0500 [STG/0] OUT        using the default SDK
   2019-01-10T17:14:47.19-0500 [STG/0] OUT -----> Installing dotnet-sdk 2.2.100
   2019-01-10T17:14:47.19-0500 [STG/0] OUT        Download [https://buildpacks.cloudfoundry.org/dependencies/dotnet-sdk/dotnet-sdk.2.2.100.linux-amd64-cflinuxfs2-a2545b4d.tar.xz]
   2019-01-10T17:14:53.63-0500 [STG/0] OUT -----> Installing dotnet-runtime 2.2.0
   2019-01-10T17:14:53.63-0500 [STG/0] OUT        Download [https://buildpacks.cloudfoundry.org/dependencies/dotnet-runtime/dotnet-runtime.2.2.0.linux-amd64-cflinuxfs2-b3b3e85c.tar.xz]
   2019-01-10T17:14:56.00-0500 [STG/0] OUT -----> Finalizing Dotnet Core
   2019-01-10T17:14:56.00-0500 [STG/0] OUT -----> Installing dotnet-aspnetcore 2.2.0
   2019-01-10T17:14:56.00-0500 [STG/0] OUT        Download [https://buildpacks.cloudfoundry.org/dependencies/dotnet-aspnetcore/dotnet-aspnetcore.2.2.0.linux-amd64-cflinuxfs2-43bb9b05.tar.xz]
   2019-01-10T17:14:58.87-0500 [STG/0] OUT -----> Installing dotnet-runtime 2.2.0
   2019-01-10T17:14:58.87-0500 [STG/0] OUT        Download [https://buildpacks.cloudfoundry.org/dependencies/dotnet-runtime/dotnet-runtime.2.2.0.linux-amd64-cflinuxfs2-b3b3e85c.tar.xz]
   2019-01-10T17:15:01.20-0500 [STG/0] OUT -----> Cleaning staging area
   2019-01-10T17:15:01.20-0500 [STG/0] OUT        Removing dotnet-sdk
   2019-01-10T17:15:05.63-0500 [STG/0] OUT Exit status 0
   2019-01-10T17:15:05.63-0500 [STG/0] OUT Uploading droplet, build artifacts cache...
   2019-01-10T17:15:05.63-0500 [STG/0] OUT Uploading droplet...
   2019-01-10T17:15:05.63-0500 [STG/0] OUT Uploading build artifacts cache...
   2019-01-10T17:15:05.71-0500 [API/0] OUT Creating droplet for app with guid 06a34cfc-bc81-426d-8465-4208e36a260c
   2019-01-10T17:15:06.77-0500 [STG/0] OUT Uploaded droplet (1.4M)
   2019-01-10T17:15:07.98-0500 [STG/0] OUT Uploaded build artifacts cache (104.8M)
   2019-01-10T17:15:08.00-0500 [STG/0] OUT Uploading complete
   2019-01-10T17:15:08.02-0500 [STG/0] OUT Cell fd243838-a68b-498a-bcb4-5f0342e759eb stopping instance 29cff1f1-8a52-48a9-a8d4-304294e0c6d0
   2019-01-10T17:15:08.02-0500 [STG/0] OUT Cell fd243838-a68b-498a-bcb4-5f0342e759eb destroying container for instance 29cff1f1-8a52-48a9-a8d4-304294e0c6d0
   2019-01-10T17:15:08.35-0500 [CELL/0] OUT Cell 55ab658f-aa82-4bb1-a8a6-81f814e4ce65 creating container for instance eb2d180f-37bd-45a6-4858-69bd
   2019-01-10T17:15:08.37-0500 [STG/0] OUT Cell fd243838-a68b-498a-bcb4-5f0342e759eb successfully destroyed container for instance 29cff1f1-8a52-48a9-a8d4-304294e0c6d0
   2019-01-10T17:15:08.70-0500 [CELL/0] OUT Cell 55ab658f-aa82-4bb1-a8a6-81f814e4ce65 successfully created container for instance eb2d180f-37bd-45a6-4858-69bd
   2019-01-10T17:15:09.21-0500 [CELL/0] OUT Starting health monitoring of container
   2019-01-10T17:15:09.32-0500 [APP/PROC/WEB/0] ERR It was not possible to find any compatible framework version
   2019-01-10T17:15:09.32-0500 [APP/PROC/WEB/0] ERR The specified framework 'Microsoft.AspNetCore.App', version '2.2.0' was not found.
   2019-01-10T17:15:09.32-0500 [APP/PROC/WEB/0] ERR   - Check application dependencies and target a framework version installed at:
   2019-01-10T17:15:09.32-0500 [APP/PROC/WEB/0] ERR       /home/vcap/app/
   2019-01-10T17:15:09.32-0500 [APP/PROC/WEB/0] ERR   - Installing .NET Core prerequisites might help resolve this problem:
   2019-01-10T17:15:09.32-0500 [APP/PROC/WEB/0] ERR       http://go.microsoft.com/fwlink/?LinkID=798306&clcid=0x409
   2019-01-10T17:15:09.32-0500 [APP/PROC/WEB/0] ERR   - The .NET Core framework and SDK can be installed from:
   2019-01-10T17:15:09.32-0500 [APP/PROC/WEB/0] ERR       https://aka.ms/dotnet-download
   2019-01-10T17:15:09.33-0500 [APP/PROC/WEB/0] OUT Exit status 150
   2019-01-10T17:15:09.33-0500 [CELL/SSHD/0] OUT Exit status 0
   2019-01-10T17:15:09.39-0500 [API/0] OUT Process has crashed with type: "web"
   2019-01-10T17:15:09.39-0500 [CELL/0] OUT Cell 55ab658f-aa82-4bb1-a8a6-81f814e4ce65 stopping instance eb2d180f-37bd-45a6-4858-69bd
   2019-01-10T17:15:09.39-0500 [CELL/0] OUT Cell 55ab658f-aa82-4bb1-a8a6-81f814e4ce65 destroying container for instance eb2d180f-37bd-45a6-4858-69bd
   2019-01-10T17:15:09.40-0500 [API/0] OUT App instance exited with guid 06a34cfc-bc81-426d-8465-4208e36a260c payload: {"instance"=>"eb2d180f-37bd-45a6-4858-69bd", "index"=>0, "reason"=>"CRASHED", "exit_description"=>"APP/PROC/WEB: Exited with status 150", "crash_count"=>1, "crash_timestamp"=>1547158509341871282, "version"=>"093904e7-f34e-4506-85a5-444497f399a2"}```
mozts2005 commented 5 years ago

Someone correct me if I am wrong but the stem cells do not have the .Net core runtime installed on them. So @michalkisielewski you have to do a self Contained build for .NET apps to run.

Based on my read of your provided log the build runs just fine its that the droplet can never start as the .NET core run time is missing.

Next, updating the build pack to install said run time could be a security/Compatibility as the run time would install globaly Possibly affecting other droplets.

sclevine commented 5 years ago

@mozts2005 this is incorrect.

Cloud Foundry apps run inside of containers on a separate base image called a stack. This stack base image has a different set of operating system packages compared to the stemcell. Each Cloud Foundry app has an isolated (copy-on-write) version of the stack that other apps cannot see.

The .NET Core buildpack supports pushing source code, pre-published .NET core apps, and fully self-contained .NET Core apps. It installs the .NET Core runtime frameworks into the droplet, which is fully isolated from all other apps on the cell.

tylerphelan commented 5 years ago

@michalkisielewski thanks for the updates! We've recreated the error and are currently looking into it https://www.pivotaltracker.com/story/show/163098157

Does removing the -r flag work for you in the meantime? dotnet publish --self-contained=false -c Release

tylerphelan commented 5 years ago

@michalkisielewski it looks like this is a bug in .NET Core 2.2 where the frameworks are not being resolved correctly by the FDD executable: https://github.com/dotnet/cli/issues/10602.

This will be fixed in .NET Core 3.0, but until they release 3.0 GA or add a fix for 2.2 you will need to create FDD apps without executables:

dotnet publish --self-contained=false -c Release

or create a Self Contained app:

dotnet publish -r ubuntu-x64 -c Release
tylerphelan commented 5 years ago

@michalkisielewski it looks like this bug was fixed in Dotnet SDK 2.2.105 (https://github.com/dotnet/cli/issues/10602) which is available in dotnet-core-buildpack 2.2.8!

Let us know if you still see any problems.