Skip to content
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

CosmosDB Linux Docker Image - Fails to start on Azure DevOps hosted agent #3010

Closed
DOMZE opened this issue Feb 1, 2022 · 3 comments
Closed

Comments

@DOMZE
Copy link

DOMZE commented Feb 1, 2022

Describe the bug
Using Azure DevOps and a ubuntu-latest hosted agent, when starting the container, the container returns right away the following:

This is an evaluation version.  There are [165] days left in the evaluation period.
Shutting Down
Shut Down

To Reproduce
Create an Azure DevOps pipeline with the following:

pool:
  name: Azure Pipelines
  vmImage: 'ubuntu-latest'
jobs:
- job: TestJob
  displayName: 'My Job'
  steps:
  - task: PowerShell@2
    name: showNetAdapters
    displayName: 'Show NetAdapters'
    inputs:
      pwsh: true
      targetType: inline
      script: |
        ifconfig
        $ipAddress = (hostname -I | awk '{print $1}')
        Write-Output "IpAddress = $ipAddress"
  - task: PowerShell@2
    name: startCosmosDb
    displayName: 'Start Azure Cosmos DB emulator'
    inputs:
      pwsh: true
      targetType: inline
      script: |
        $ipAddress = (hostname -I | awk '{print $1}')
        $containerId = (docker create -p 8081:8081 -p 10251:10251 -p 10252:10252 -p 10253:10253 -p 10254:10254 -m 3g --cpus=2.0 -e AZURE_COSMOS_EMULATOR_PARTITION_COUNT=10 -e AZURE_COSMOS_EMULATOR_ENABLE_DATA_PERSISTENCE=false -e AZURE_COSMOS_EMULATOR_IP_ADDRESS_OVERRIDE=$ipAddress mcr.microsoft.com/cosmosdb/linux/azure-cosmos-emulator)
        Write-Host "##vso[task.setvariable variable=cosmosDbContainerId]$containerId"
        docker start $containerId
        Start-Sleep -Seconds 5
        $isStarted = $false
        while ($isStarted -eq $false) {
            $logs = (docker logs $containerId)
            if ($logs.Contains('Started')) {
                Write-Output "Container $containerId started."
                $isStarted = $true
                break;
            }
            Write-Output "Waiting for container $containerId to start"
            Write-Output ($logs | Out-String)
            Start-Sleep -Seconds 5
        }
  - script: |
      echo 'ContainerId = $(cosmosDbContainerId)'
      docker logs $(cosmosDbContainerId)
    displayName: Diagnostics
  - script: |
      ipAddress="hostname -I | awk '{print $1}'"
      curl -k https://$ipAddress:8081/_explorer/emulator.pem > $(Agent.TempDirectory)/emulatorcert.crt
      cp $(Agent.TempDirectory)/emulatorcert.crt /usr/local/share/ca-certificates/
      update-ca-certificates
      echo "##vso[task.setvariable variable=cosmosDbEndpoint]https://$ipAddress:8081"
    displayName: 'Prepare emulator'
  - script: |
      if [ ! -z "$(cosmosDbContainerId)" ];
      then
        docker rm -f $(cosmosDbContainerId)
        rm -f /usr/local/share/ca-certificates/emulatorcert.crt
      fi
    displayName: 'Clean Azure Cosmos DB emulator'
    condition: always()

Expected behavior
The container should create the partitions and return "Started" at some point

Actual behavior
The container exits and the logs shows

This is an evaluation version.  There are [165] days left in the evaluation period.
Shutting Down
Shut Down

Additional context
Can't use older images (tags) to see if the code has changes since, as it fails the evaluation time check
Is there something I can add as environment variable to get more logs out to diagnose the problem?

@milismsft
Copy link

This is not an issue that the Cosmos DB SDK team can actually help with, since the failure is related to the respective Azure DevOps agent and not the Cosmos SDK or the Linux emulator (especially since the same script works when run locally).
Please instead open a support ticket with the Azure DevOps, feel free to mention our Cosmos DB Emulator team if they need to reach out for additional help.

@DOMZE
Copy link
Author

DOMZE commented Feb 18, 2022

@milismsft as mentioned by your colleague in actions/runner-images#5036 could you reopen this?

@milismsft
Copy link

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants