-
Notifications
You must be signed in to change notification settings - Fork 241
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Running Run-ALValidation from another container fails on New-BCContainer with error "Error trying to establish session, retrying in 5 seconds" #3582
Comments
Workaround for now is to run my\additionalsetup.ps1 e.g. through custom my\servicesettings.ps1 because this is runned from navinstall.ps1 which is running even for filesOnly container. But there is no way how to do that when running Run-ALValidation. |
Hmm, it seems more complicated. When I resolved the problem with connection, I have problem with another code running in the get-bccontainersession failing on error:
Because it is running script "prompt.ps1" |
navinstall runs with |
Ok, after few days of research, I have found the original source of the problem. This is the result: Problems:
Code to create the container inside run-alvalidation: $NewBcContainer = { Param([Hashtable]$parameters) New-BcContainer @parameters; Invoke-ScriptInBcContainer $parameters.ContainerName -scriptblock { $progressPreference = 'SilentlyContinue' } } Workaround: {
Param([Hashtable]$parameters)
$parameters += @{
"MyScripts" = @(@{'start.ps1'='. c:\run\HelperFunctions.ps1;. c:\run\SetupVariables.ps1;. c:\run\my\additionalsetup.ps1;remove-item "c:\run\my\start.ps1" -force;. (Join-Path $runPath $MyInvocation.MyCommand.Name)'})
}
New-BcContainer @parameters
Invoke-ScriptInBcContainer $parameters.ContainerName -scriptblock { $progressPreference = 'SilentlyContinue'}
} Solution: |
We switched to using containerized Azure DevOps agents and since that, running Run-ALValidation fails on New-BCContainer step with error "Error trying to establish session, retrying in 5 seconds".
After the research, I have found, that there is one step missing when filesOnly switch is combined with running the script inside container, because it will never run configuration for winrm because this.
Bare script to run inside container which lead to the problem:
Output of the script:
Then, when you try to connect/run script on the container (or anything what is getting the container session):
will lead to this error:
I was able to track the source of the problem to this line:
navcontainerhelper/ContainerHandling/New-NavContainer.ps1
Line 1591 in b241069
Because we are inside container, when this runs, this code will be executed and will fill the code into my\additionalsetup.ps1 file. But it will be not executed because we have filesOnly switch, which will prevent running navstart.ps1 which runs inside the my\additionalsetup.ps1. This lead to error because right after the new-bccontainer there is invoke-scriptinbccontainer (which runs get-bccontianersession inside). See
navcontainerhelper/AppHandling/Run-AlValidation.ps1
Line 286 in b241069
I can do workaround but I do not know how to fix the code, because I do not know the context why the code is written like that.
I am attaching even full output of the original run of the Run-ALValidation from our pipeline:
The text was updated successfully, but these errors were encountered: