microsoft / navcontainerhelper

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

Azure Pipeline Tasks stuck even though they are successful #2469

Closed JulianSchmidtkeGWS closed 2 years ago

JulianSchmidtkeGWS commented 2 years ago

This is related to https://github.com/microsoft/azure-pipelines-tasks/issues/15819 which is no longer assigned to anyone.

Describe the issue We have custom build Azure Pipelines with BCContainerhelper. About 10% of each Stage is cancled by the system, because it times out. The problem is, that the stage actually was successful but the tasks never exits. This only happens in Powershell tasks (FilePath and Inline) where BCContainerhelper is used. We use a custom vm-scaleset with bccontainerhelper and additional tools preinstalled. Other users report the same issue with normal VM_Agents.

Scripts used to create container and cause the issue This happens with our create-container, run-tests and sign-app scripts.

Example for Create Container:

YAML:

- task: PowerShell@2
  displayName: 'Create Container'
  timeoutInMinutes: 30
  env:
    insiderSASToken: $(InsiderSASToken)
  inputs:
    failOnStderr: false
    targetType: filePath
    filePath: '$(PipelinePath)/Create-Environment/Create-Container/Create-Container.ps1'
    arguments:
      -containerName "${{ parameters.containerName }}"
      -sharedFolder "${{ parameters.sharedFolder }}"
      -artifactUrl ${{ parameters.artifacturl }}
      -adminCredentials ${{ parameters.adminCredentials }}
      -includeTestToolkit $${{ parameters.includeTestToolkit }}
      -licensefile "$(License.SecureFilePath)"
      -pipelinePath ${{ parameters.pipelinePath }}

PS:

Param(
    [Parameter(Mandatory = $true)]
    [string] $containerName,

    [Parameter(Mandatory = $true)]
    [string] $sharedFolder,

    [Parameter(Mandatory = $false)]    
    [bool] $useDockerImage = $true,

    [Parameter(Mandatory = $true)]
    [string] $artifactUrl,

    [Parameter(Mandatory = $true)]
    [PSCredential] $adminCredentials,

    [Parameter(Mandatory = $true)]
    $includeTestToolkit = $false,

    [Parameter(Mandatory = $false)]
    [string] $licensefile,

    [Parameter(Mandatory = $false)]
    [string] $PipelinePath = "Pipeline",

    [Parameter(Mandatory = $false)]
    $useDns = $false
)

###### custom scripts that set the following:######
$FullImageName = "sandbox200de:TestToolkit"
$FullArtifactUrl = ""
######

$additionalParameters = @(
    "--volume ""$($sharedFolder):$($sharedFolder)""",
    "--env customNavSettings=EnableTaskScheduler=$false"
)

$params = @{
    accept_eula               = $true
    "containerName"           = $containerName
    "auth"                    = "NAVUserPassword"
    "Credential"              = $adminCredentials
    "imageName"               = $FullImageName
    "artifactUrl"             = $FullArtifactUrl
    "additionalParameters"    = $additionalParameters
    "licenseFile"             = $licensefile
    "shortcuts"               = "None"
    "includeTestToolkit"      = $includeTestToolkit
    "doNotUseRuntimePackages" = $true
    "assignPremiumPlan"       = $true
    "accept_outdated"         = $true
    "multitenant"             = $false
    "vsixFile"                = $(Get-LatestAlLanguageExtensionUrl)
}

Write-Host "##[debug] Starting to create container $containerName"
New-BCContainer @params

Full output of scripts

2022-05-17T08:25:06.5372388Z ##[section]Starting: Create Container
2022-05-17T08:25:06.5510942Z ==============================================================================
2022-05-17T08:25:06.5511431Z Task         : PowerShell
2022-05-17T08:25:06.5511903Z Description  : Run a PowerShell script on Linux, macOS, or Windows
2022-05-17T08:25:06.5512315Z Version      : 2.200.0
2022-05-17T08:25:06.5512658Z Author       : Microsoft Corporation
2022-05-17T08:25:06.5513241Z Help         : https://docs.microsoft.com/azure/devops/pipelines/tasks/utility/powershell
2022-05-17T08:25:06.5513841Z ==============================================================================
2022-05-17T08:25:08.1619085Z Generating script.
2022-05-17T08:25:08.1620944Z Formatted command: . 'C:\a\1\s\Pipeline\Create-Environment\Create-Container\Create-Container.ps1' -containerName "vmss-actr000358" -sharedFolder "C:\a" -useDockerImage $True -artifactUrl https://bcartifacts.azureedge.net/sandbox/20.0/de -adminCredentials ([PSCredential]::new("**", (ConvertTo-SecureString -String "***" -AsPlainText -Force))) -includeTestToolkit $True -licensefile "C:\a\_temp\fin.flf" -pipelinePath Pipeline -useDns $False
2022-05-17T08:25:08.1622935Z ========================== Starting Command Output ===========================
2022-05-17T08:25:08.1624130Z ##[command]"C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe" -NoLogo -NoProfile -NonInteractive -ExecutionPolicy Unrestricted -Command ". 'C:\a\_temp\61850810-b93e-4b3b-937a-e56ae3836f70.ps1'"
2022-05-17T08:25:08.3012021Z ##[debug] Creating needed parameters.
2022-05-17T08:25:08.3817847Z ##[debug]bcartifacts.azureedge.net-sandbox-20.0-de-Latest
2022-05-17T08:25:08.4968871Z Setting use7zipIfAvailable = True
2022-05-17T08:25:08.5017481Z Setting digestAlgorithm = SHA256
2022-05-17T08:25:08.5054598Z Setting baseUrl = https://businesscentral.dynamics.com
2022-05-17T08:25:08.5090829Z Setting DOCKER_SCAN_SUGGEST = False
2022-05-17T08:25:08.5138376Z Setting mapCountryCode = @{ae=w1; ar=w1; bd=w1; dz=w1; cl=w1; pr=w1; eg=w1; fo=dk; gl=dk; id=w1; ke=w1; lb=w1; lk=w1; lu=w1; ma=w1; mm=w1; mt=w1; my=w1; ng=w1; qa=w1; sa=w1; sg=w1; tn=w1; ua=w1; za=w1}
2022-05-17T08:25:08.5174591Z Setting useVolumeForMyFolder = False
2022-05-17T08:25:08.5218330Z Setting psSessionTimeout = 0
2022-05-17T08:25:08.5254585Z Setting MicrosoftTelemetryConnectionString = InstrumentationKey=5b44407e-9750-4a07-abe9-30c3b853821b;IngestionEndpoint=https://southcentralus-0.in.applicationinsights.azure.com/
2022-05-17T08:25:08.5290576Z Setting hostHelperFolder = C:\ProgramData\BcContainerHelper
2022-05-17T08:25:08.5326688Z Setting defaultContainerName = bcserver
2022-05-17T08:25:08.5362296Z Setting timeStampServer = http://timestamp.digicert.com
2022-05-17T08:25:08.5398276Z Setting bcartifactsCacheFolder = c:\bcartifacts.cache
2022-05-17T08:25:08.5433950Z Setting SendExtendedTelemetryToMicrosoft = False
2022-05-17T08:25:08.5469839Z Setting containerHelperFolder = C:\ProgramData\BcContainerHelper
2022-05-17T08:25:08.5506275Z Setting TraefikImage = traefik:v1.7-windowsservercore-1809
2022-05-17T08:25:08.5541763Z Setting apiBaseUrl = https://api.businesscentral.dynamics.com
2022-05-17T08:25:08.5577693Z Setting PartnerTelemetryConnectionString = 
2022-05-17T08:25:08.5614042Z Setting sandboxContainersAreMultitenantByDefault = False
2022-05-17T08:25:08.5650787Z Setting usePsSession = True
2022-05-17T08:25:08.5687385Z Setting genericImageName = mcr.microsoft.com/businesscentral:{0}
2022-05-17T08:25:08.5724129Z Setting ObjectIdForInternalUse = 88123
2022-05-17T08:25:08.5761443Z Setting useSharedEncryptionKeys = True
2022-05-17T08:25:08.5816948Z Setting TreatWarningsAsErrors = 
2022-05-17T08:25:08.5853134Z Setting TraefikUseDnsNameAsHostName = False
2022-05-17T08:25:08.5889487Z Setting genericImageNameFilesOnly = mcr.microsoft.com/businesscentral:{0}-filesonly
2022-05-17T08:25:08.5926189Z Setting defaultNewContainerParameters = 
2022-05-17T08:25:08.6948387Z BcContainerHelper version 3.0.6
2022-05-17T08:25:08.7047267Z BcContainerHelper emits usage statistics telemetry to Microsoft
2022-05-17T08:25:12.7408378Z ##[debug] Found Artifact: https://bcartifacts.azureedge.net/sandbox/20.0.37253.40705/de
2022-05-17T08:25:12.7494099Z ##[debug] FullImageName: sandbox200de:TestToolkit
2022-05-17T08:25:23.6663205Z ##[debug] Image Found: 9de799b04262
2022-05-17T08:25:23.8385171Z ##[debug] Use DNS is false -> Do not create Webservice
2022-05-17T08:25:23.8394149Z ##[debug] Starting to create container vmss-actr000358
2022-05-17T08:25:24.5288346Z BcContainerHelper is version 3.0.6
2022-05-17T08:25:24.5295985Z BcContainerHelper is running as administrator
2022-05-17T08:25:25.4823586Z Hyper-V is Disabled
2022-05-17T08:25:25.4851831Z Host is Microsoft Windows Server 2019 Datacenter - ltsc2019
2022-05-17T08:25:25.6523051Z Docker Client Version is 20.10.9
2022-05-17T08:25:25.6556836Z Docker Server Version is 20.10.9
2022-05-17T08:25:25.9991924Z Fetching all docker images
2022-05-17T08:25:26.0998987Z Fetching all docker volumes
2022-05-17T08:25:26.1660382Z Using image sandbox200de:testtoolkit
2022-05-17T08:25:26.2853453Z Creating Container vmss-actr000358
2022-05-17T08:25:26.2943031Z Style: sandbox
2022-05-17T08:25:26.2950696Z Multitenant: No
2022-05-17T08:25:26.2969647Z Version: 20.0.37253.39711
2022-05-17T08:25:26.2989707Z Platform: 20.0.37114.39631
2022-05-17T08:25:26.3013416Z Generic Tag: 1.0.2.1
2022-05-17T08:25:26.3041113Z Container OS Version: 10.0.17763.2803 (ltsc2019)
2022-05-17T08:25:26.3051499Z Host OS Version: 10.0.17763.2803 (ltsc2019)
2022-05-17T08:25:26.3138133Z Using process isolation
2022-05-17T08:25:26.3178660Z Using locale de-DE
2022-05-17T08:25:26.3222582Z Disabling the standard eventlog dump to container log every 2 seconds (use -dumpEventLog to enable)
2022-05-17T08:25:26.3512932Z Downloading C:\ProgramData\BcContainerHelper\Extensions\vmss-actr000358\Microsoft.VisualStudio.Services.VSIXPackage.vsix
2022-05-17T08:25:26.8145703Z Using license file C:\a\_temp\fin.flf
2022-05-17T08:25:26.8607657Z Additional Parameters:
2022-05-17T08:25:26.8622994Z --volume "C:\a:C:\a"
2022-05-17T08:25:26.8630460Z --env customNavSettings=EnableTaskScheduler=False
2022-05-17T08:25:26.8640032Z Files in C:\ProgramData\BcContainerHelper\Extensions\vmss-actr000358\my:
2022-05-17T08:25:26.8691809Z - AdditionalOutput.ps1
2022-05-17T08:25:26.8704402Z - license.flf
2022-05-17T08:25:26.8713233Z - MainLoop.ps1
2022-05-17T08:25:26.8723595Z - SetupNavUsers.ps1
2022-05-17T08:25:26.8738768Z - SetupVariables.ps1
2022-05-17T08:25:26.8746466Z - updatecontainerhosts.ps1
2022-05-17T08:25:26.8755883Z Creating container vmss-actr000358 from image sandbox200de:testtoolkit
2022-05-17T08:25:27.3124210Z a36b5e3f6f4497faedc65342a700d9158c017cc62664790c4f96cfb4208acdfd
2022-05-17T08:25:46.1358702Z Waiting for container vmss-actr000358 to be ready
2022-05-17T08:26:23.0412081Z Initializing...
2022-05-17T08:26:23.0413697Z Setting host.containerhelper.internal to 172.21.32.1 in container hosts file
2022-05-17T08:26:23.0414730Z Starting Container
2022-05-17T08:26:23.0415618Z Hostname is vmss-actr000358
2022-05-17T08:26:25.5785301Z PublicDnsName is vmss-actr000358
2022-05-17T08:26:25.5791402Z Using NavUserPassword Authentication
2022-05-17T08:26:33.0636535Z Starting Local SQL Server
2022-05-17T08:26:33.0637978Z WARNING: Waiting for service 'SQL Server (SQLEXPRESS) (MSSQL$SQLEXPRESS)' to 
2022-05-17T08:26:35.1979862Z start...
2022-05-17T08:26:35.1981231Z WARNING: Waiting for service 'SQL Server (SQLEXPRESS) (MSSQL$SQLEXPRESS)' to 
2022-05-17T08:26:37.8340878Z start...
2022-05-17T08:26:37.8341951Z WARNING: Waiting for service 'SQL Server (SQLEXPRESS) (MSSQL$SQLEXPRESS)' to 
2022-05-17T08:26:39.9683619Z start...
2022-05-17T08:26:39.9686638Z WARNING: Waiting for service 'SQL Server (SQLEXPRESS) (MSSQL$SQLEXPRESS)' to 
2022-05-17T08:26:41.0327202Z start...
2022-05-17T08:26:41.0330543Z WARNING: Waiting for service 'SQL Server (SQLEXPRESS) (MSSQL$SQLEXPRESS)' to 
2022-05-17T08:26:43.1693975Z start...
2022-05-17T08:26:43.1694704Z WARNING: Waiting for service 'SQL Server (SQLEXPRESS) (MSSQL$SQLEXPRESS)' to 
2022-05-17T08:26:45.4509763Z start...
2022-05-17T08:26:47.6161108Z Starting Internet Information Server
2022-05-17T08:26:53.3275579Z Creating Self Signed Certificate
2022-05-17T08:26:53.3276642Z Self Signed Certificate Thumbprint BDB37B4889D6923BC04B72FDF7037919A60DACE3
2022-05-17T08:26:53.3277609Z DNS identity vmss-actr000358
2022-05-17T08:26:53.3278128Z Modifying Service Tier Config File with Instance Specific Settings
2022-05-17T08:26:53.3278799Z Modifying Service Tier Config File with settings from environment variable
2022-05-17T08:26:55.4804603Z Setting EnableTaskScheduler to False
2022-05-17T08:29:01.7090104Z Starting Service Tier
2022-05-17T08:29:02.7763763Z Registering event sources
2022-05-17T08:29:37.6916894Z Creating DotNetCore Web Server Instance
2022-05-17T08:29:37.6919101Z Enabling Financials User Experience
2022-05-17T08:29:37.6929872Z Using license file 'c:\run\my\license.flf'
2022-05-17T08:29:40.9203431Z Import License
2022-05-17T08:29:44.1096647Z Creating http download site
2022-05-17T08:29:46.2586214Z Setting SA Password and enabling SA
2022-05-17T08:29:52.9243549Z Creating ** as SQL User and add to sysadmin
2022-05-17T08:29:57.2295797Z Creating SUPER user
2022-05-17T08:29:59.3600788Z Assign Premium plan for ***
2022-05-17T08:29:59.3605429Z Container IP Address: 172.21.47.3
2022-05-17T08:29:59.3606836Z Container Hostname  : vmss-actr000358
2022-05-17T08:29:59.3608020Z Container Dns Name  : vmss-actr000358
2022-05-17T08:29:59.3610762Z Web Client          : http://vmss-actr000358/BC/
2022-05-17T08:29:59.3613659Z Dev. Server         : http://vmss-actr000358
2022-05-17T08:29:59.3616253Z Dev. ServerInstance : BC
2022-05-17T08:29:59.3618696Z 
2022-05-17T08:29:59.3619694Z Files:
2022-05-17T08:29:59.3621344Z http://vmss-actr000358:8080/Microsoft.VisualStudio.Services.VSIXPackage.vsix
2022-05-17T08:29:59.3622143Z 
2022-05-17T08:29:59.3622938Z Container Total Physical Memory is 16.0Gb
2022-05-17T08:29:59.3623810Z Container Free Physical Memory is 12.0Gb
2022-05-17T08:29:59.3624492Z 
2022-05-17T08:29:59.3625477Z Initialization took 217 seconds
2022-05-17T08:29:59.3626346Z Ready for connections!
2022-05-17T08:29:59.8374970Z Reading CustomSettings.config from vmss-actr000358
2022-05-17T08:30:13.2125733Z Skipping app 'C:\Applications.DE\Microsoft_Permissions Mock_20.0.37253.39711.app' as it is already installed
2022-05-17T08:30:13.2710916Z Skipping app 'C:\Applications.DE\Microsoft_Test Runner_20.0.37253.39711.app' as it is already installed
2022-05-17T08:30:13.3284375Z Skipping app 'C:\Applications.DE\Microsoft_Any_20.0.37253.39711.app' as it is already installed
2022-05-17T08:30:13.3854927Z Skipping app 'C:\Applications.DE\Microsoft_Library Assert_20.0.37253.39711.app' as it is already installed
2022-05-17T08:30:13.4299045Z Skipping app 'C:\Applications.DE\Microsoft_Permissions Mock_20.0.37253.39711.app' as it is already installed
2022-05-17T08:30:13.4840357Z Skipping app 'C:\Applications.DE\Microsoft_Library Variable Storage_20.0.37253.39711.app' as it is already installed
2022-05-17T08:30:13.5432199Z Skipping app 'C:\Applications.DE\Microsoft_System Application Test Library_20.0.37253.39711.app' as it is already installed
2022-05-17T08:30:13.7010483Z Skipping app 'C:\Applications.DE\Microsoft_Tests-TestLibraries_20.0.37253.39711.app' as it is already installed
2022-05-17T08:30:13.7739328Z Skipping app 'C:\Applications.DE\Microsoft_Tests-Bank_20.0.37253.39711.app' as it is already installed
2022-05-17T08:30:13.8079849Z Skipping app 'C:\Applications.DE\Microsoft_Tests-Cash Flow_20.0.37253.39711.app' as it is already installed
2022-05-17T08:30:13.8571481Z Skipping app 'C:\Applications.DE\Microsoft_Tests-Cost Accounting_20.0.37253.39711.app' as it is already installed
2022-05-17T08:30:14.0324106Z Skipping app 'C:\Applications.DE\Microsoft_Tests-CRM integration_20.0.37253.39711.app' as it is already installed
2022-05-17T08:30:14.0791109Z Skipping app 'C:\Applications.DE\Microsoft_Tests-Data Exchange_20.0.37253.39711.app' as it is already installed
2022-05-17T08:30:14.3453953Z Skipping app 'C:\Applications.DE\Microsoft_Tests-Dimension_20.0.37253.39711.app' as it is already installed
2022-05-17T08:30:15.4199303Z Skipping app 'C:\Applications.DE\Microsoft_Tests-ERM_20.0.37253.39711.app' as it is already installed
2022-05-17T08:30:15.4654714Z Skipping app 'C:\Applications.DE\Microsoft_Tests-Fixed Asset_20.0.37253.39711.app' as it is already installed
2022-05-17T08:30:15.5337771Z Skipping app 'C:\Applications.DE\Microsoft_Tests-General Journal_20.0.37253.39711.app' as it is already installed
2022-05-17T08:30:15.6486678Z Skipping app 'C:\Applications.DE\Microsoft_Tests-Graph_20.0.37253.39711.app' as it is already installed
2022-05-17T08:30:15.6976122Z Skipping app 'C:\Applications.DE\Microsoft_Tests-Integration_20.0.37253.39711.app' as it is already installed
2022-05-17T08:30:15.7420937Z Skipping app 'C:\Applications.DE\Microsoft_Tests-Invoicing_20.0.37253.39711.app' as it is already installed
2022-05-17T08:30:15.8216055Z Skipping app 'C:\Applications.DE\Microsoft_Tests-Job_20.0.37253.39711.app' as it is already installed
2022-05-17T08:30:15.8965248Z Skipping app 'C:\Applications.DE\Microsoft_Tests-Local_20.0.37253.39711.app' as it is already installed
2022-05-17T08:30:15.9740623Z Skipping app 'C:\Applications.DE\Microsoft_Tests-Marketing_20.0.37253.39711.app' as it is already installed
2022-05-17T08:30:16.1535458Z Skipping app 'C:\Applications.DE\Microsoft_Tests-Misc_20.0.37253.39711.app' as it is already installed
2022-05-17T08:30:16.1820916Z Skipping app 'C:\Applications.DE\Microsoft_Tests-Monitor Sensitive Fields_20.0.37253.39711.app' as it is already installed
2022-05-17T08:30:16.2301616Z Skipping app 'C:\Applications.DE\Microsoft_Tests-Permissions_20.0.37253.39711.app' as it is already installed
2022-05-17T08:30:16.2759870Z Skipping app 'C:\Applications.DE\Microsoft_Tests-Physical Inventory_20.0.37253.39711.app' as it is already installed
2022-05-17T08:30:16.3516373Z Skipping app 'C:\Applications.DE\Microsoft_Tests-Prepayment_20.0.37253.39711.app' as it is already installed
2022-05-17T08:30:16.3988280Z Skipping app 'C:\Applications.DE\Microsoft_Tests-Rapid Start_20.0.37253.39711.app' as it is already installed
2022-05-17T08:30:16.4623930Z Skipping app 'C:\Applications.DE\Microsoft_Tests-Report_20.0.37253.39711.app' as it is already installed
2022-05-17T08:30:16.5292554Z Skipping app 'C:\Applications.DE\Microsoft_Tests-Resource_20.0.37253.39711.app' as it is already installed
2022-05-17T08:30:16.5736125Z Skipping app 'C:\Applications.DE\Microsoft_Tests-Reverse_20.0.37253.39711.app' as it is already installed
2022-05-17T08:30:17.7827212Z Skipping app 'C:\Applications.DE\Microsoft_Tests-SCM_20.0.37253.39711.app' as it is already installed
2022-05-17T08:30:17.9238249Z Skipping app 'C:\Applications.DE\Microsoft_Tests-SMB_20.0.37253.39711.app' as it is already installed
2022-05-17T08:30:17.9554157Z Skipping app 'C:\Applications.DE\Microsoft_Tests-Upgrade_20.0.37253.39711.app' as it is already installed
2022-05-17T08:30:18.0022966Z Skipping app 'C:\Applications.DE\Microsoft_Tests-User_20.0.37253.39711.app' as it is already installed
2022-05-17T08:30:18.0667739Z Skipping app 'C:\Applications.DE\Microsoft_Tests-VAT_20.0.37253.39711.app' as it is already installed
2022-05-17T08:30:18.1664216Z Skipping app 'C:\Applications.DE\Microsoft_Tests-Workflow_20.0.37253.39711.app' as it is already installed
2022-05-17T08:30:18.1677572Z TestToolkit successfully imported
2022-05-17T08:30:18.9839465Z Container vmss-actr000358 successfully created
2022-05-17T08:30:18.9845442Z 
2022-05-17T08:30:18.9852681Z Use:
2022-05-17T08:30:18.9869334Z Get-BcContainerEventLog -containerName vmss-actr000358 to retrieve a snapshot of the event log from the container
2022-05-17T08:30:18.9884010Z Get-BcContainerDebugInfo -containerName vmss-actr000358 to get debug information about the container
2022-05-17T08:30:18.9898447Z Enter-BcContainer -containerName vmss-actr000358 to open a PowerShell prompt inside the container
2022-05-17T08:30:18.9913165Z Remove-BcContainer -containerName vmss-actr000358 to remove the container again
2022-05-17T08:30:18.9927548Z docker logs vmss-actr000358 to retrieve information about URL's again
2022-05-17T08:55:16.6660022Z ##[error]The task has timed out.
2022-05-17T08:55:16.6674871Z ##[section]Finishing: Create Container

Screenshots It usually takes only a few minutes to create the container. Its not responding for 20+ min image

Additional context It happens in about 10% of our pipelines for different tasks always in combination with bccontainerhelper.

Another user has created an example pipeline that might reproduce it easier: https://github.com/microsoft/azure-pipelines-tasks/issues/15819#issuecomment-1083414837

We have tried different versions of bccontainerhelper and always have the same issue.

We tried to upgrade the VM Size (Cores and RAM) and have the same Issue

freddydk commented 2 years ago

If I am to assist with this, I would need somebody to setup a repo, where I can have access and perform various tests and run unlimited number of pipelines, for me to repro this.

JulianSchmidtkeGWS commented 2 years ago

Hi Freddy, thank you for your Reply. I have invited you to our DevOps.

JulianSchmidtkeGWS commented 2 years ago

Freddy and i could find the cause of this and https://github.com/microsoft/azure-pipelines-tasks/issues/15819 (PSSession not being canceled in the communication to the container) and fixed it for us by setting "UsePSSession" to false in the ContainerHelper Config.

Our VM Image is now created with this script added:

Import-Module BCContainerHelper
$bcContainerHelperConfig.UsePsSession = $false
$bcContainerHelperConfig | ConvertTo-Json | Set-Content "C:\ProgramData\BcContainerHelper\BcContainerHelper.config.json"

Thank you again, Freddy!

The main Problem of PSSession not working in the azure pipeline might still occur though.

freddydk commented 2 years ago

I always recomment that people ONLY set the settings they actually are changing in the settings file. This way - you force all current values into the settings file, which you might not want.

I would recommend this instead:

@{ "UsePsSession" = $false } | ConvertTo-Json | Set-Content "C:\ProgramData\BcContainerHelper\BcContainerHelper.config.json"
Import-Module BCContainerHelper

Thanks for the help Julian - I will write a blog post about the topic and link from various github issues to that.

freddydk commented 2 years ago

Also, next version of ContainerHelper will automatically turn off the use of PsSessions in Invoke-ScriptInBcContainer and use Docker Exec when running Azure DevOps Pipelines or GitHub Actions Workflows.

freddydk commented 2 years ago

I decided to revert this decision. As the use of docker exec does come with some performance impact, I decided to keep the behavior, where you need to add usePsSession to the config file.

JulianSchmidtkeGWS commented 2 years ago

Understandable. I have compared a few runs in our history and the performance impact does not seem too dramatic.

The biggest change is in our RunTests Task from 70-75min -> 78-80min in our biggest app. But that one tests each codeunit on its own which means that a request is sent for each codeunit (200+). Time to redesign that one on our end.

I hope the Azure Pipelines Team finds a good solution to use PSSession without the timeouts, but this works fine for us 👍

freddydk commented 2 years ago

Establishing a PsSession (first time you invoke a script in a container in that powershell session) - is around 1 second (on my machine) Subsequent invokes to that PsSession from the same PowerShell session is around 5 ms

Invoking a script using docker exec is around 0,9 second (every time)

So, if you have a lot of tasks (individual PowerShell sessions), the difference isn't big. If you use Run-AlPipeline, which does everything in one PowerShell session - the difference becomes huge (around 20% is what I saw)