microsoft / navcontainerhelper

Official Microsoft repository for BcContainerHelper, a PowerShell module, which makes it easier to work with Business Central Containers on Docker.
MIT License
382 stars 246 forks source link

docker : At least 3Gb memory needs to be available to the Container #3720

Open frottke opened 1 day ago

frottke commented 1 day ago

Hi Freddy,

first of thank you for fixing #3718! :)

Resulting from #3718 we are now using HyperV-Isolation but unfortunately we now get a new error. This error was originally the reason to switch to process isolation a few months ago.

Thrown Error

At least 3Gb memory needs to be available to the Container.
At C:\Run\start.ps1:49 char:5
+     throw "At least 3Gb memory needs to be available to the Container ...
+     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : OperationStopped: (At least 3Gb me... the Contai
   ner.:String) [], RuntimeException
    + FullyQualifiedErrorId : At least 3Gb memory needs to be available to the
    Container.

Scripts used and config via AL-Go to create container and cause the issue

localdenv.ps1

localDevEnv.settings.json

{
    "memoryLimit": "0G",
    "installOnlyReferencedApps": false,
    "enableTaskScheduler": true,
    "doNotBuildTests": true,
    "doNotRunTests": true,
    "doNotRunBcptTests": true,
    "assignPremiumPlan": true,
    "vsixFile": "latest"
}

When changing memoryLimit to for example 16G it does work. When using process isolation the value "0G" was the solution that bccontainerhelper used the default which was perfect for our needs instead of the default value of AL-Go (8G) which is not sufficient for the installation of the dependencies ( around nine apps). Is there a "better" solution then setting it to 16GB?

Full output of scripts

  _                     _   _____             ______
 | |                   | | |  __ \           |  ____|
 | |     ___   ___ __ _| | | |  | | _____   __ |__   _ ____   __
 | |    / _ \ / __/ _` | | | |  | |/ _ \ \ / /  __| | '_ \ \ / /
 | |____ (_) | (__ (_| | | | |__| |  __/\ V /| |____| | | \ V /
 |______\___/ \___\__,_|_| |_____/ \___| \_/ |______|_| |_|\_/

Downloading Github-Helper.psm1 from https://raw.githubusercontent.com/microsoft/AL-Go-Actions/v5.3/Github-Helper.psm1
Downloading AL-Go-Helper.ps1 from https://raw.githubusercontent.com/microsoft/AL-Go-Actions/v5.3/AL-Go-Helper.ps1
Downloading Packages.json from https://raw.githubusercontent.com/microsoft/AL-Go-Actions/v5.3/Packages.json

This script will create a docker based local development environment for your project.

NOTE: You need to have Docker installed, configured and be able to create Business Central containers for this to work.
If this fails, you can setup a cloud based development environment by running cloudDevEnv.ps1

All apps and test apps will be compiled and published to the environment in the development scope.
The script will also modify launch.json to have a Local Sandbox configuration point to your environment.

Applying settings from C:\Users\username\Documents\Repositories\RepositoryName\.github\AL-Go-Settings.json
Applying settings from C:\Users\username\Documents\Repositories\RepositoryName\.AL-Go\settings.json
Applying settings from C:\Users\username\Documents\Repositories\RepositoryName\.github\localDevEnv.settings.json
No settings found in C:\Users\username\Documents\Repositories\RepositoryName\.AL-Go\localDevEnv.settings.json
No settings found in C:\Users\username\Documents\Repositories\RepositoryName\.AL-Go\username.settings.json
Checking System Requirements

Downloading BcContainerHelper latest version from Blob Storage
Using Expand-Archive
Import from C:\ProgramData\BcContainerHelper\6.0.25\BcContainerHelper\BcContainerHelper.ps1
BcContainerHelper version 6.0.25
Setting defaultNewContainerParameters = @{isolation=hyperv}
BC.HelperFunctions emits usage statistics telemetry to Microsoft
Running on Windows, PowerShell 7.4.5
Applying settings from C:\Users\username\Documents\Repositories\RepositoryName\.github\AL-Go-Settings.json
Applying settings from C:\Users\username\Documents\Repositories\RepositoryName\.AL-Go\settings.json
Applying settings from C:\Users\username\Documents\Repositories\RepositoryName\.github\localDevEnv.settings.json
No settings found in C:\Users\username\Documents\Repositories\RepositoryName\.AL-Go\localDevEnv.settings.json
No settings found in C:\Users\username\Documents\Repositories\RepositoryName\.AL-Go\username.settings.json
Checking type
Checking appFolders, testFolders and bcptTestFolders
Application Dependency 24.0.0.0
Checking artifact setting for project
Get-BCArtifactUrl Telemetry Correlation Id: c9baff57-74ed-4cac-bf6a-57494fc0c664
Downloading artifacts from https://bcartifacts-exdbf9fwegejdqak.b02.azurefd.net/onprem/24.1.18927.19498/de
Download-Artifacts Telemetry Correlation Id: 4719e012-0010-438e-8071-7e0d60e5e084
Updating app- and test Dependencies
Analyzing Test App Dependencies
Checking appDependencyProbingPaths
WARNING: No app folders found
Parameters
  _____                               _
 |  __ \                             | |
 | |__) |_ _ _ __ __ _ _ __ ___   ___| |_ ___ _ __ ___
 |  ___/ _` | '__/ _` | '_ ` _ \ / _ \ __/ _ \ '__/ __|
 | |  | (_| | | | (_| | | | | | |  __/ |_  __/ |  \__ \
 |_|   \__,_|_|  \__,_|_| |_| |_|\___|\__\___|_|  |___/

Pipeline name                   localDevEnv
Container name                  bcserver
Image name
ArtifactUrl                     https://bcartifacts-exdbf9fwegejdqak.b02.azurefd.net/onprem/24.1.18927.19498/de
BcAuthContext                   Not Specified
Environment
ReUseContainer                  False
KeepContainer                   True
useCompilerFolder               False
artifactCachePath
useDevEndpoint                  True
Auth                            UserPassword
CompanyName
MemoryLimit                     0G
FailOn                          error
TreatTestFailuresAsWarnings     False
Enable Task Scheduler           True
Assign Premium Plan             True
Install Test Runner             False
Install Test Framework          False
Install Test Libraries          False
Install Perf. Toolkit           False
InstallOnlyReferencedApps       False
generateDependencyArtifact      False
CopySymbolsFromContainer        False
enableCodeCop                   True
enableAppSourceCop              False
enableUICop                     True
enablePerTenantExtensionCop     False
enableCodeAnalyzersOnTestApps   False
doNotPerformUpgrade             False
doNotPublishApps                False
uninstallRemovedApps            False
escapeFromCops                  False
doNotBuildTests                 False
doNotRunTests                   True
doNotRunBcptTests               True
useDefaultAppSourceRuleSet      False
rulesetFile
generateErrorLog                False
enableExternalRulesets          False
azureDevOps                     False
gitLab                          False
gitHubActions                   False
vsixFile                        latest
License file                    Specified
CodeSignCertPfxFile             Not specified
CodeSignCertPfxPassword         Not specified
CodeSignCertIsSelfSigned        False
KeyVaultCertPfxFile             Not specified
KeyVaultCertPfxPassword         Not specified
KeyVaultClientId
BuildOutputFile
ContainerEventLogFile
TestResultsFile                 C:\Users\username\Documents\Repositories\RepositoryName\TestResults.xml
BcptTestResultsFile             C:\Users\username\Documents\Repositories\RepositoryName\bcptTestResults.json
TestResultsFormat               JUnit
AdditionalCountries
PackagesFolder                  .packages
OutputFolder
BuildArtifactFolder
CreateRuntimePackages           False
AppVersion
AppBuild                        0
AppRevision                     0
SourceRepositoryUrl
SourceCommit
BuildBy                         BcContainerHelper,6.0.25
BuildUrl
Install Apps
- dependencies
Install Test Apps
- None
Previous Apps
- None
Application folders
- None
Test application folders
- None
BCPT Test application folders
- None
BCPT Test suites
- None
Custom CodeCops
- None
Pulling generic image                                                                                                   

  _____       _ _ _                                          _        _
 |  __ \     | | (_)                                        (_)      (_)
 | |__) |   _| | |_ _ __   __ _    __ _  ___ _ __   ___ _ __ _  ___   _ _ __ ___   __ _  __ _  ___
 |  ___/ | | | | | | '_ \ / _` |  / _` |/ _ \ '_ \ / _ \ '__| |/ __| | | '_ ` _ \ / _` |/ _` |/ _ \
 | |   | |_| | | | | | | | (_| | | (_| |  __/ | | |  __/ |  | | (__  | | | | | | | (_| | (_| |  __/
 |_|    \__,_|_|_|_|_| |_|\__, |  \__, |\___|_| |_|\___|_|  |_|\___| |_|_| |_| |_|\__,_|\__, |\___|
                           __/ |   __/ |                                                 __/ |
                          |___/   |___/                                                 |___/

Pulling mcr.microsoft.com/businesscentral:ltsc2022

Pulling generic image took 1 seconds
Creating Container

   _____                _   _                _____            _        _
  / ____|              | | (_)              / ____|          | |      (_)
 | |     _ __ ___  __ _| |_ _ _ __   __ _  | |     ___  _ __ | |_ __ _ _ _ __   ___ _ __
 | |    | '__/ _ \/ _` | __| | '_ \ / _` | | |    / _ \| '_ \| __/ _` | | '_ \ / _ \ '__|
 | |____| | |  __/ (_| | |_| | | | | (_| | | |___| (_) | | | | || (_| | | | | |  __/ |
  \_____|_|  \___|\__,_|\__|_|_| |_|\__, |  \_____\___/|_| |_|\__\__,_|_|_| |_|\___|_|
                                     __/ |
                                    |___/

Creaing docker container
Default parameter isolation = hyperv
BcContainerHelper is version 6.0.25
BcContainerHelper is not running as administrator
Host is Microsoft Windows 11 Enterprise - 10.0.26100.2033
UsePsSession is True
UsePwshForBc24 is True
UseWinRmSession is allow
UseSslForWinRmSession is True
Docker Client Version is 27.2.0
Docker Server Version is 27.2.0
Removing Session bcserver
Removing container bcserver
Removing entries from hosts
Removing bcserver from container hosts file
Removing bcserver-* from container hosts file
Removing Desktop shortcuts
Removing C:\ProgramData\BcContainerHelper\Extensions\bcserver
Download-Artifacts Telemetry Correlation Id: d8ab1fe8-5c4c-493d-8350-bed5bfe2094a
Fetching all docker images
Fetching all docker volumes
Using image mcr.microsoft.com/businesscentral:ltsc2022
Download-Artifacts Telemetry Correlation Id: 0d419046-16e3-4d1d-bd50-8c07c446bc5d
Creating Container bcserver
Style: onprem
Multitenant: No
Version: 24.1.18927.19498
Platform: 24.0.19487.0
Generic Tag: 1.0.2.49
Container OS Version: 10.0.20348.2762 (ltsc2022)
Host OS Version: 10.0.26100.2033 (Unknown/Insider build)
Using hyperv isolation
Using locale de-DE
Disabling the standard eventlog dump to container log every 2 seconds (use -dumpEventLog to enable)
Downloading C:\ProgramData\BcContainerHelper\Extensions\bcserver\Microsoft.VisualStudio.Services.VSIXPackage.vsix
Using license file "hereWouldBeAnURL"
Downloading C:\ProgramData\BcContainerHelper\Extensions\bcserver\my\license.bclicense
Additional Parameters:
--volume "C:\Users\username\Documents\Repositories\RepositoryName:c:\sources"
--volume "C:/Users/username/Documents/Repositories/RepositoryName:c:\shared"
--expose 5986
--env customNavSettings=EnableTaskScheduler=True
Files in C:\ProgramData\BcContainerHelper\Extensions\bcserver\my:
- AdditionalOutput.ps1
- AdditionalSetup.ps1
- HelperFunctions.ps1
- license.bclicense
- MainLoop.ps1
- SetupNavUsers.ps1
- SetupVariables.ps1
- updatehosts.ps1
Creating container bcserver from image mcr.microsoft.com/businesscentral:ltsc2022
1acfe81e7de267b78956ea95b99e0626cf790b5979f4f8e947fb4516a926713b
Waiting for container bcserver to be ready
At least 3Gb memory needs to be available to the Container.
At C:\Run\start.ps1:49 char:5
+     throw "At least 3Gb memory needs to be available to the Container ...
+     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : OperationStopped: (At least 3Gb me... the Contai
   ner.:String) [], RuntimeException
    + FullyQualifiedErrorId : At least 3Gb memory needs to be available to the
    Container.
similar-issues-ai[bot] commented 1 day ago

We've found some similar issues:

If any of the above are duplicates, please consider closing this issue out and adding additional context in the original issue.

Note: You can give me feedback by 👍 or 👎 this comment.

freddydk commented 1 day ago

memoryLimit": "0G",

?

Shouldn't that be 10G?

frottke commented 1 day ago

It was intentional 0G to avoid the default value 8G from AL-Go. 0G with process isolation is "dynamic". Which means using the limit of the host os. Worked perfectly :)

freddydk commented 3 hours ago

OK - when using process isolation, the default should be "no memorylimit", hence "memoryLimit 0G" shouldn't be needed. When using hyperv - you need to set a maximum memory limit to make this work.

You should be able to create a settings file called .github/localdevenv.settings.json - which will only be applied during localdevenv and hence will not be applied during CI/CD.

and... reading your issue again - you already have this settings file.