microsoft / AL-Go

The plug-and-play DevOps solution for Business Central app development on GitHub
MIT License
286 stars 121 forks source link

[Question]: What is the cause of the instability of deploying to an environment? #1193

Open tscottjendev opened 1 month ago

tscottjendev commented 1 month ago

Question

The deploy to environments step and "Publish To Environment" action seem to be very unstable. I have an artefact package that contains several apps. The deployment fails frequently, 8 of the last 10 runs (CI/CD or Publish to Environment) It may happen on the first app, the 3rd or in this case the 4th. All with the same error in the installation status is:

Operation was not found. The job for id '00000000-0000-0000-0000-000000000000' was not found. - Job Id : 00000000-0000-0000-0000-000000000000

The pipeline log is attached. job-logs.txt

rolandpthompson commented 2 weeks ago

Also seeing this frequently now - interestingly only seems to be the Production environment for me, my QA and FAT seem to work ok

tscottjendev commented 6 days ago

@freddydk Any feedback on this?

freddydk commented 6 days ago

Not yet - trying to get a repro scenario up running so that I can troubleshoot this.

freddydk commented 3 days ago

Managed to get a repro yesterday. The scenario involved used 11 AppSource Apps and 16 PTEs. My repro script was follows:

$allApps = @(
"C:\...\app1.app"
"C:\...\app2.app"
etc
)

$ErrorActionPreference = 'stop'

$environment = "<environment>"
if (-not (Get-Variable 'bcAuthContext')) {
    $bcAuthContext = New-BcAuthContext -includeDeviceLogin
}
$ptes = @()

$bcauthcontext = Renew-BcAuthContext $bcauthcontext
$allApps | ForEach-Object {
    $appJson = Get-AppJsonFromAppFile -appFile $_
    if ($appJson.idRanges.from -lt 100000) {
        $ptes += $_
    }
    else {
        Write-Host "$($appJson.publisher)_$($appJson.name)"
        Install-BcAppFromAppSource -bcAuthContext $bcauthcontext -environment $environment -languageId 'en-US' -appId $appJson.id -installOrUpdateNeededDependencies -acceptIsvEula
    }
}

$bcauthcontext = Renew-BcAuthContext $bcauthcontext
Publish-PerTenantExtensionApps -bcAuthContext $bcauthcontext -environment $environment -appFiles $ptes

When creating a brand new environment and running this script - it failed on the 5th PTE in the first attempt with a protocol violation on the server. I have fixed the publishing to ignore this error and I could run the above script 6 times with new environments and all was successful.

I expect that this should handle the instabilities described in this issue as well.

tscottjendev commented 3 days ago

Thanks Freddy.