HodorNV / ALOps

ALOps
59 stars 24 forks source link

Create Docker - Installation failed #715

Closed StijnBt closed 8 months ago

StijnBt commented 8 months ago

Describe the bug All our NextMajor pipelines are failing on the same error.

the used yaml please provide the yaml that you used. It helps you put the yaml like this:

Pipeline (partial)

# Only for product or customer cloud extensions
name: $(Build.BuildId)

trigger: none

schedules:
- cron: "0 22 2-8 * 6" # At 22:00 on every day-of-month from 2 through 8 and on Saturday
  displayName: ''
  branches:
    include:
      - next/major
  always: true

variables:
- group: 'ALOps'
- group: 'BC-NEXTMAJOR'

resources:
  repositories:
    - repository: Pipelines
      type: git
      name: '(INT) Minerva/PipeLines'
      ref: 'refs/heads/main'
    - repository: Isv
      type: git
      name: '(CUST) Customer/NAV365-ISV'
      ref: 'refs/heads/main'

stages:  
  - stage: Build
    displayName: 'Build & compile app'
    pool: $(bc-buildpool)
    jobs:
    - template: Build/BuildCompile.yml@Pipelines
      parameters:
        folders: ['General-Customizations/app','General-Customizations/app-cdc','test']
        preCreateDocker:
         - checkout: Isv
           persistCredentials: true
         - task: CopyFiles@2
           inputs:
            SourceFolder: '$(Pipeline.Workspace)\s\NAV365-ISV\'
            Contents: '*'
            TargetFolder: '$(System.ArtifactsDirectory)'
         - checkout: self
           persistCredentials: true
           clean: true
        preCompileApps:
          - task: CopyFiles@2
            displayName: 'Copy apps to artifacts folder'
            inputs:
              SourceFolder: '$(Pipeline.Workspace)\s\General-Customizations\app\Isv\'
              Contents: '*'
              TargetFolder: '$(System.ArtifactsDirectory)'
          - task: CopyFiles@2
            displayName: 'Copy  apps to artifacts folder'
            inputs:
              SourceFolder: '$(Pipeline.Workspace)\s\General-Customizations\app-cdc\Isv\'
              Contents: '*'
              TargetFolder: '$(System.ArtifactsDirectory)'
          - task: ALOpsAppPublish@1
            displayName: 'ALOps - Publish Extension: '
            inputs:
              batch_publish_folder: '$(System.ArtifactsDirectory)'
              usedocker: true

Template (partial)

parameters:
   addPreAction: []
   preCreateDocker: []
   postCreateDocker: []
   preBuildCompile: []
   preCompileApps: []
   postPublishApps: []
   postCompileApps: []
   beforeDockerRemove: []
   postBuildCompile: []
   addPostAction: []
   artifactcountry: ''
   folders: ['app','test']
   preprocessorsymbols: ''
   testfilter: '<>0'

# Custom steps can be added through params above: https://damienaicheh.github.io/azure/devops/2020/11/12/extend-azure-devops-yaml-pipelines-en.html

jobs:
- job: PreActions
  displayName: 'Pre actions'
  #condition: in(variables['bc-artifactversionselect'],'NextMinor','NextMajor')
  steps:
  - checkout: self
    clean: true
    persistCredentials: true
  - powershell: |
        $env:GIT_REDIRECT_STDERR = '2>&1' # Do not report git output as error... However error is also only text now
        git fetch
        git checkout main
        git pull origin main
        git checkout $env:branch
        git fetch
        git pull
        git pull origin main
        git push
    env:
        branch: 'next/$(Build.SourceBranchName)'
    condition: in(variables['bc-artifactversionselect'],'NextMinor','NextMajor')
    displayName: 'Update Next Branch From Main'
  - ${{ parameters.addPreAction }}

- job: DockerBuildCompile
  displayName: 'Docker build & compile'
  timeoutInMinutes: 240 # how long to run the job before automatically cancelling
  #condition: always()
  dependsOn:
    - PreActions
  steps:
  - ${{ parameters.preCreateDocker }}

  - task: ALOpsDockerCreate@1
    displayName: 'ALOPS - Create Docker'
    inputs:
      artifacttype: $(bc-artifacttype)
      artifactversion: $(bc-artifactversion)
      versionselect: $(bc-artifactversionselect)
      artifactcountry: "${{ coalesce( parameters.artifactcountry, '$(bc-artifactcountry)') }}"
      sastoken: $(bc-sastoken)

  - task: ALOpsDockerStart@1
    displayName: 'ALOPS - Start Docker'

the output

2024-01-08T10:43:09.8799290Z ##[section]Starting: ALOPS - Create Docker
2024-01-08T10:43:09.8897622Z ==============================================================================
2024-01-08T10:43:09.8897912Z Task         : ALOps Docker Create
2024-01-08T10:43:09.8898155Z Description  : Create Docker image from Business Central Artifacts
2024-01-08T10:43:09.8898366Z Version      : 1.461.5118
2024-01-08T10:43:09.8898544Z Author       : Hodor
2024-01-08T10:43:09.8898759Z Help         : Create Docker image based on NAV/BC Artifacts.
2024-01-08T10:43:09.8899017Z ==============================================================================
2024-01-08T10:43:10.6830651Z *** Validate configuration
2024-01-08T10:43:10.7711285Z *** Task Inputs:
2024-01-08T10:43:10.7768564Z 
2024-01-08T10:43:10.7883177Z name                      value                                                                                        
2024-01-08T10:43:10.7885070Z ----                      -----                                                                                        
2024-01-08T10:43:10.7887159Z artifactspecification     Specific                                                                                     
2024-01-08T10:43:10.7887932Z artifactversion                                                                                                        
2024-01-08T10:43:10.7889422Z artifacttype              Sandbox                                                                                      
2024-01-08T10:43:10.7890731Z artifactcountry           be                                                                                           
2024-01-08T10:43:10.7892196Z versionselect             NextMajor                                                                                    
2024-01-08T10:43:10.7893697Z artifacthint                                                                                                           
2024-01-08T10:43:10.7895105Z multitenant               False                                                                                        
2024-01-08T10:43:10.7896431Z memory                    8G                                                                                           
2024-01-08T10:43:10.7897753Z imageprefix               myImage                                                                                      
2024-01-08T10:43:10.7899078Z dockerregistry                                                                                                         
2024-01-08T10:43:10.7900538Z dockerusername                                                                                                         
2024-01-08T10:43:10.7901868Z dockerpassword                                                                                                         
2024-01-08T10:43:10.7903291Z storageaccount                                                                                                         
2024-01-08T10:43:10.7933332Z sastoken                  ?sv=2021-10-0xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
2024-01-08T10:43:10.7934509Z forcecreateimage          False                                                                                        
2024-01-08T10:43:10.7936439Z myscripts                                                                                                              
2024-01-08T10:43:10.7937882Z imagenametemplate         %IMAGE_PREFIX%:%ARTIFACT_TYPE%-%ARTIFACT_VERSION%-%ARTIFACT_COUNTRY%-%OS_VERSION%-%OS_LTSC%  
2024-01-08T10:43:10.7939232Z use_generic_image                                                                                                      
2024-01-08T10:43:10.7941086Z licensefile                                                                                                            
2024-01-08T10:43:10.7942710Z includetesttoolkit        False                                                                                        
2024-01-08T10:43:10.7944545Z includetestlibrariesonly  False                                                                                        
2024-01-08T10:43:10.7946653Z includetestframeworkonly  False                                                                                        
2024-01-08T10:43:10.7947570Z includeperformancetoolkit False                                                                                        
2024-01-08T10:43:10.7949061Z accept_insider_eula       False                                                                                        
2024-01-08T10:43:10.7949308Z 
2024-01-08T10:43:10.7976507Z 
2024-01-08T10:43:10.7985032Z 
2024-01-08T10:43:10.8152959Z *** For documentation, please visit   : https://www.alops.be/documentation
2024-01-08T10:43:10.8156506Z 
2024-01-08T10:43:11.2138791Z *** ALOps License:
2024-01-08T10:43:11.2158135Z   * Licensed To: Broad Horizon Belgie (Per Run License)
2024-01-08T10:43:11.2162558Z 
2024-01-08T10:43:11.2319648Z *** Importing required PS-Functions
2024-01-08T10:43:11.2552590Z *** Install/Update BCContainerHelper [https://github.com/microsoft/navcontainerhelper]
2024-01-08T10:43:11.2612651Z *** Check BcContainerHelper
2024-01-08T10:43:11.4516262Z *** Load BcContainerHelper
2024-01-08T10:43:11.5418936Z BcContainerHelper version 6.0.0
2024-01-08T10:43:11.9394082Z BC.HelperFunctions emits usage statistics telemetry to Microsoft
2024-01-08T10:43:14.4950841Z 
2024-01-08T10:43:14.4952375Z ModuleType Version    Name                                ExportedCommands                                             
2024-01-08T10:43:14.4953231Z ---------- -------    ----                                ----------------                                             
2024-01-08T10:43:14.4954574Z Script     6.0.0      BcContainerHelper                   {Add-FontsToBcContainer, Add-GitToAlProjectFolder, AddTele...
2024-01-08T10:43:14.4955314Z 
2024-01-08T10:43:14.4955694Z 
2024-01-08T10:43:14.4956137Z 
2024-01-08T10:43:14.4956401Z 
2024-01-08T10:43:14.5084337Z *** Get Artifact Url for Version [] / Country [be] / Type [Sandbox]: NextMajor
2024-01-08T10:43:14.5266572Z ##[command]"Get-BCArtifactUrl" 
2024-01-08T10:43:14.5267007Z Name                           Value                                                                                   
2024-01-08T10:43:14.5267633Z ----                           -----                                                                                   
2024-01-08T10:43:14.5268129Z sasToken                       ?sv=2021-10-0xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
2024-01-08T10:43:14.5268639Z select                         NextMajor                                                                               
2024-01-08T10:43:14.5269466Z type                           Sandbox                                                                                 
2024-01-08T10:43:14.5269958Z country                        be                                                                                      
2024-01-08T10:43:14.5270240Z 
2024-01-08T10:43:14.5270367Z 
2024-01-08T10:43:14.5270519Z 
2024-01-08T10:43:23.7809078Z After October 1st 2023, you can specify -accept_insiderEula to accept the insider EULA (https://go.microsoft.com/fwlink/?linkid=2245051) for Business Central Insider artifacts instead of providing a SAS token.
2024-01-08T10:43:27.6605153Z *** Artifact Url: [https://bcinsider.azureedge.net/sandbox/24.0.15154.0/be***]
2024-01-08T10:43:27.6613400Z *** Build new Image based on [https://bcinsider.azureedge.net/sandbox/24.0.15154.0/be***]
2024-01-08T10:43:27.6673426Z *** Artifact Type   : [sandbox]
2024-01-08T10:43:27.6680964Z *** Artifact Version: [24.0.15154.0]
2024-01-08T10:43:27.6687883Z *** Artifact Country: [be]
2024-01-08T10:43:27.7954446Z *** OS: [2019]
2024-01-08T10:43:28.8462129Z *** OS version: [10.0.17763.2928]
2024-01-08T10:43:28.8468972Z *** Image Template: [%IMAGE_PREFIX%:%ARTIFACT_TYPE%-%ARTIFACT_VERSION%-%ARTIFACT_COUNTRY%-%OS_VERSION%-%OS_LTSC%]
2024-01-08T10:43:28.8504948Z *** ImageName: [myimage:sandbox-24.0.15154.0-be-10.0.17763.2928-ltsc2019]
2024-01-08T10:43:28.8539985Z *** Set Pipeline variable $(ALOPS_BC_IMAGE) = 'myimage:sandbox-24.0.15154.0-be-10.0.17763.2928-ltsc2019'
2024-01-08T10:43:28.9049911Z Error: No such image: myimage:sandbox-24.0.15154.0-be-10.0.17763.2928-ltsc2019
2024-01-08T10:43:28.9136627Z *** No 'MyScripts' specified, skipping parse.
2024-01-08T10:43:28.9154734Z *** Create Image: myimage:sandbox-24.0.15154.0-be-10.0.17763.2928-ltsc2019
2024-01-08T10:43:28.9171857Z ##[command]"New-BcImage" 
2024-01-08T10:43:28.9172373Z Name                           Value                                                                                   
2024-01-08T10:43:28.9173146Z ----                           -----                                                                                   
2024-01-08T10:43:28.9173668Z includePerformanceToolkit      False                                                                                   
2024-01-08T10:43:28.9174234Z includeTestToolkit             False                                                                                   
2024-01-08T10:43:28.9174721Z memory                         8G                                                                                      
2024-01-08T10:43:28.9175267Z artifactUrl                    https://bcinsider.azureedge.net/sandbox/24.0.15154.0/be?sv=2021-10-04&ss=b&srt=sco&st...
2024-01-08T10:43:28.9175761Z multitenant                    False                                                                                   
2024-01-08T10:43:28.9176252Z imageName                      myimage:sandbox-24.0.15154.0-be-10.0.17763.2928-ltsc2019                                
2024-01-08T10:43:28.9176814Z includeTestLibrariesOnly       False                                                                                   
2024-01-08T10:43:28.9177827Z includeTestFrameworkOnly       False                                                                                   
2024-01-08T10:43:28.9178164Z 
2024-01-08T10:43:28.9178284Z 
2024-01-08T10:43:28.9178378Z 
2024-01-08T10:43:29.6647663Z Building image myimage:sandbox-24.0.15154.0-be-10.0.17763.2928-ltsc2019 based on mcr.microsoft.com/businesscentral:10.0.17763.2928 with https://bcinsider.azureedge.net/sandbox/24.0.15154.0/be
2024-01-08T10:43:29.6655987Z Pulling latest image mcr.microsoft.com/businesscentral:10.0.17763.2928
2024-01-08T10:43:30.0666432Z 10.0.17763.2928: Pulling from businesscentral
2024-01-08T10:43:30.0786669Z Digest: sha256:3597b4954425c838f3a8b80e1621f0ffdb689faf0d880c870841f55e62d76c1e
2024-01-08T10:43:30.0795905Z Status: Image is up to date for mcr.microsoft.com/businesscentral:10.0.17763.2928
2024-01-08T10:43:30.0924818Z mcr.microsoft.com/businesscentral:10.0.17763.2928
2024-01-08T10:43:30.1606923Z Generic Tag: 1.0.2.14
2024-01-08T10:43:30.2152225Z Container OS Version: 10.0.17763.2928 (ltsc2019)
2024-01-08T10:43:30.2162000Z Host OS Version: 10.0.17763.2928 (ltsc2019)
2024-01-08T10:43:30.2190568Z Using process isolation
2024-01-08T10:43:30.2256601Z Files in c:\bcartifacts.cache\ihrhw0p4.353\my:
2024-01-08T10:43:30.2316653Z Copying Platform Artifacts
2024-01-08T10:43:30.2373481Z c:\bcartifacts.cache\sandbox\24.0.15154.0\platform
2024-01-08T10:43:52.0495079Z Copying Database
2024-01-08T10:43:59.3914261Z Copying Licensefile
2024-01-08T10:43:59.4023609Z Copying ConfigurationPackages
2024-01-08T10:43:59.4035157Z C:\bcartifacts.cache\sandbox\24.0.15154.0\be\ConfigurationPackages
2024-01-08T10:43:59.4330766Z Copying Extensions
2024-01-08T10:43:59.4339943Z C:\bcartifacts.cache\sandbox\24.0.15154.0\be\Extensions
2024-01-08T10:44:01.0331290Z Copying Applications.BE
2024-01-08T10:44:01.0340675Z C:\bcartifacts.cache\sandbox\24.0.15154.0\be\Applications.BE
2024-01-08T10:44:01.8924524Z c:\bcartifacts.cache\ihrhw0p4.353
2024-01-08T10:44:51.5385724Z Sending build context to Docker daemon  2.698GB
2024-01-08T10:44:51.5392014Z 
2024-01-08T10:44:53.6386617Z Step 1/6 : FROM mcr.microsoft.com/businesscentral:10.0.17763.2928
2024-01-08T10:44:53.6395421Z  ---> a564ecbf3343
2024-01-08T10:44:53.6404714Z Step 2/6 : ENV DatabaseServer=localhost DatabaseInstance=SQLEXPRESS DatabaseName=CRONUS IsBcSandbox=Y artifactUrl=https://bcinsider.azureedge.net/sandbox/24.0.15154.0/be*** filesOnly=False
2024-01-08T10:44:54.4469855Z  ---> Running in b207958238ec
2024-01-08T10:45:02.3922694Z Removing intermediate container b207958238ec
2024-01-08T10:45:02.3931973Z  ---> f0737b3fd329
2024-01-08T10:45:02.3940463Z Step 3/6 : COPY my /run/
2024-01-08T10:45:03.6106496Z  ---> 660792028bd2
2024-01-08T10:45:03.6118023Z Step 4/6 : COPY NAVDVD /NAVDVD/
2024-01-08T10:48:28.1998003Z  ---> a5aa4ab05816
2024-01-08T10:48:28.2006920Z Step 5/6 : RUN \Run\start.ps1 -installOnly
2024-01-08T10:48:28.2780542Z  ---> Running in 963aa7181266
2024-01-08T10:48:32.5747419Z c:\run\my folder doesn't exist, creating it
2024-01-08T10:48:33.3606272Z Using installer from C:\Run\210-new
2024-01-08T10:48:33.4132305Z Installing Business Central
2024-01-08T10:48:33.4232325Z Installing from DVD
2024-01-08T10:48:33.4420335Z Starting Local SQL Server
2024-01-08T10:48:36.3201150Z Starting Internet Information Server
2024-01-08T10:48:36.6778498Z Copying Service Tier Files
2024-01-08T10:48:36.6853924Z C:\NAVDVD\ServiceTier\Program Files
2024-01-08T10:48:41.2521364Z C:\NAVDVD\ServiceTier\System64Folder
2024-01-08T10:48:42.4631629Z Copying PowerShell Scripts
2024-01-08T10:48:42.4642847Z C:\NAVDVD\WindowsPowerShellScripts\Cloud\NAVAdministration
2024-01-08T10:48:42.5055449Z C:\NAVDVD\WindowsPowerShellScripts\WebSearch
2024-01-08T10:48:42.5252274Z Copying Web Client Files
2024-01-08T10:48:42.5261847Z C:\NAVDVD\WebClient\Microsoft Dynamics NAV
2024-01-08T10:48:52.3336670Z Copying ModernDev Files
2024-01-08T10:48:52.3347441Z C:\NAVDVD
2024-01-08T10:48:52.3517747Z C:\NAVDVD\ModernDev\program files\Microsoft Dynamics NAV
2024-01-08T10:48:54.5732315Z Copying additional files
2024-01-08T10:48:54.5827948Z Copying ConfigurationPackages
2024-01-08T10:48:54.5838352Z C:\NAVDVD\ConfigurationPackages
2024-01-08T10:48:54.7383937Z Copying Test Assemblies
2024-01-08T10:48:54.7394363Z C:\NAVDVD\Test Assemblies
2024-01-08T10:48:54.7801289Z Copying Extensions
2024-01-08T10:48:54.7811486Z C:\NAVDVD\Extensions
2024-01-08T10:48:56.7179500Z Copying Applications
2024-01-08T10:48:56.7189126Z C:\NAVDVD\Applications
2024-01-08T10:49:01.2748101Z Copying Applications.BE
2024-01-08T10:49:01.2758329Z C:\NAVDVD\Applications.BE
2024-01-08T10:49:02.4326774Z Copying dependencies
2024-01-08T10:49:02.5839358Z Copying ReportBuilder
2024-01-08T10:49:26.0816222Z Importing PowerShell Modules
2024-01-08T10:49:27.4688427Z Restoring CRONUS Demo Database
2024-01-08T10:49:52.8156032Z Setting CompatibilityLevel for CRONUS on localhost\SQLEXPRESS
2024-01-08T10:49:53.7486258Z Modifying Business Central Service Tier Config File for Docker
2024-01-08T10:49:53.7968477Z Creating Business Central Service Tier
2024-01-08T10:49:53.8718601Z Installing SIP crypto provider: 'C:\Windows\System32\NavSip.dll'
2024-01-08T10:49:54.1287245Z Starting Business Central Service Tier
2024-01-08T10:49:54.1716116Z Service 'Dynamics 365 Business Central Server [BC] (MicrosoftDynamicsNavServer$BC)' cannot be started due to the following error: Cannot start service MicrosoftDynamicsNavServer$BC on computer '.'.
2024-01-08T10:49:54.2237239Z Installation failed
2024-01-08T10:49:54.2247345Z At C:\Run\start.ps1:393 char:9
2024-01-08T10:49:54.2255773Z +         throw "Installation failed"
2024-01-08T10:49:54.2267208Z +         ~~~~~~~~~~~~~~~~~~~~~~~~~~~
2024-01-08T10:49:54.2274719Z     + CategoryInfo          : OperationStopped: (Installation failed:String) [ 
2024-01-08T10:49:54.2283306Z    ], RuntimeException
2024-01-08T10:49:54.2290978Z     + FullyQualifiedErrorId : Installation failed
2024-01-08T10:49:54.2299981Z  
2024-01-08T10:50:04.0811345Z 
2024-01-08T10:50:06.4757278Z BcContainerHelper\New-BcImage Telemetry Correlation Id: b8079389-831b-4924-95fd-1cecf6017c64
2024-01-08T10:50:06.6084494Z ##[error]The command 'powershell -Command $ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue'; \Run\start.ps1 -installOnly' returned a non-zero code: 1
ExitCode: 1
Commandline: docker build --isolation=process --memory 8G --no-cache --tag myimage:sandbox-24.0.15154.0-be-10.0.17763.2928-ltsc2019 c:\bcartifacts.cache\ihrhw0p4.353
2024-01-08T10:50:06.6464117Z ##[section]Finishing: ALOPS - Create Docker

Expected behavior This would run as previous months

Screenshots image

Additional context Off topic question maybe... but the use of CRON triggers doen't lead to consistent trigger behaviour. Some pipelines always work fine... others never get triggered, despite having the exact same CRON trigger

waldo1001 commented 8 months ago

This is NextMajor (read: unstable), and purely based on BCCH. Can you try to update BCCH to the latest version on this agent?

StijnBt commented 8 months ago

Indeed, spot on! Thanks