Azure / azure-cli

Azure Command-Line Interface
MIT License
3.97k stars 2.95k forks source link

adding --top 10 removes the inProgress runs #23509

Open williamohara opened 2 years ago

williamohara commented 2 years ago

az feedback auto-generates most of the information requested below, as of CLI version 2.0.62

Related command az pipelines runs list

Describe the bug this command gives me the top ten runs in a nice table - only its missing the inProgress runs

az pipelines runs list --top 10 -o table

this command works as expected - it gives me 240 runs in a nice table - including the inProgress ones.

To Reproduce submit a run hit the command while the run is running wiht the --top 10 see lack of inProgress

Expected behavior expect to see the inProgress runs too

Environment summary linux, wsl on win 10 { "azure-cli": "2.32.0", "azure-cli-core": "2.32.0", "azure-cli-telemetry": "1.0.6", "extensions": { "aks-preview": "0.5.50", "azure-devops": "0.22.0" } }

Additional context

yonzhan commented 2 years ago

route to CXP team

ghost commented 2 years ago

Thanks for the feedback! We are routing this to the appropriate team for follow-up. cc @v-anvashist, @V-hmusukula.

Issue Details
> ### `az feedback` auto-generates most of the information requested below, as of CLI version 2.0.62 **Related command** az pipelines runs list **Describe the bug** this command gives me the top ten runs in a nice table - only its missing the inProgress runs az pipelines runs list --top 10 -o table this command works as expected - it gives me 240 runs in a nice table - including the inProgress ones. **To Reproduce** submit a run hit the command while the run is running wiht the --top 10 see lack of inProgress **Expected behavior** expect to see the inProgress runs too **Environment summary** linux, wsl on win 10 { "azure-cli": "2.32.0", "azure-cli-core": "2.32.0", "azure-cli-telemetry": "1.0.6", "extensions": { "aks-preview": "0.5.50", "azure-devops": "0.22.0" } } **Additional context**
Author: williamohara
Assignees: -
Labels: `Service Attention`, `customer-reported`, `DevOps`, `Pipelines`, `Auto-Assign`
Milestone: -
SumanthMarigowda commented 2 years ago

Removing CXP label for DevOps issue

Adding @v-anvashist, @V-hmusukula. Please look into this

v-soujanya commented 2 years ago

@williamohara, we tried to repro the issue, but we are not successful. Below are the commands we tried in our machine and both commands include the InProgress runs.

  1. az pipelines runs list image
  2. az pipelines runs list --top 10 -o table

image

Please let me know in which command are you facing the issue as we are not able to repro the issue.

williamohara commented 2 years ago

It looks like you are testing in PowerShell - I am in Ubuntu/Linux running on WSL here is my screen shot for az pipelines runs list -o table image

and then for az pipelines runs list -o table --top 10 ... image

williamohara commented 2 years ago

I am getting the same thing in my AZ CLI on PS ... This is strange that you aren't able to reproduce it. Could it have something to do with my pipeline jobs? Ican share my azure pipeline yamls if that helps. Just let me know

I have the latest version on PS and v2.32 on Ubuntu

image

williamohara commented 2 years ago

FYI - I upgraded and just tested with the latest version on WSL. I also tried experimenting with my config (setting default outputs) and still the same thing. i also added the project and organization params like you have in your command, same thing...

whenever i put in top 10 parameter it does not show inProgress runs

image

v-soujanya commented 2 years ago

@williamohara Please help us to get some clarification on the below points.

  1. Have you tried all the scenarios from your ubuntu machine?
  2. have you installed PS on ubuntu/windows? Because, we have checked in windows PowerShell.
williamohara commented 2 years ago

I have tried all scenarios from both PowerShell and Ubuntu. The images are attached in my previous comments

v-soujanya commented 2 years ago

@williamohara are you using PowerShell on ubuntu or PowerShell on windows?

williamohara commented 2 years ago

I am running Ubuntu on WSL. I have the Azure CLI installed on that instance and it does not work. - I also have the Azure CLI installed on my PowerShell as well and it does not work.

I am signing off now. Sorry it's late for me :(

williamohara commented 2 years ago

i just tested with a brand new pipeline for a brand new project in a brand new repository. the inProgress runs for that new application show up when I run az pipelines runs list --top 10.

  1. My new project is an application - its pipeline simply builds a docker container and puts it into ACS

  2. the pipelines that do not show up in the command az pipelines runs list --top 10 are my terraform pipelines that build infrastructure within AKS. My conclusion with this is that there is a problem with the CLI sorting the types of jobs I am running and then filtering them to the top 10. Because they show up when the --top 10 is not used

I have attached a file containing the json of this output az pipelines runs list without the --top10 filter - the very first one is a job that will show up without the --top 10 filter but when I run the command with the --top10 filter it will not show up. Perhaps you can run it through whatever filter functions you have manually to see if you can replicate the issue that way outputJson.txt

v-soujanya commented 2 years ago

@williamohara, we tried to repro the issue using terraform pipelines by following the below doc (creation of terraform pipelines etc). https://www.azuredevopslabs.com/labs/vstsextend/terraform/#:~:text=Overview,as%20custom%20in%2Dhouse%20solutions. we are able to see the InProgress run with --top 10 parameter also but all this activity we are performing on our windows machine as we don't have ubuntu/Linux currently. image image are we missing something in the setup of terraform pipeline?

williamohara commented 2 years ago

I use yaml files for all my pipelines. I have attached one, perhaps you could mimic one that is similar. I think the yaml is pretty well structured and easy to follow, but here is a rundown of it,

  1. All of my variables for my yamls are stored in my Azure DevOps Library
  2. I am installing terraform and initializing it
  3. I do the Tf plan stage and then read the output to determine if there are changes - if so I update a variable to true in a PowerShell script
  4. then I run terraform apply

I do the same thing all over again in a second stage hopefuly this helps

pool:
  vmImage: ubuntu-latest

resources:
- repo: self

# Setting up connection to terraform state file stored in Azure Storage. 
# variables are stored in the AzureDevops Library named 'Azure DevOps Variable Group Terraform'

variables:
- group: 'Azure DevOps Variable Group Terraform'

# these variables are used for this yaml's context only  
- name : anyTfChanges1
  value : false
- name : anyTfChanges2
  value: false

stages:
  - stage: clusterAndDbServerDeployStage1
    displayName: 'Deploy Cluster and Database Server'
    jobs:
    - job: runTerraformCoreInfraStage1
      displayName: 'Running Terraform Core-Infra Stage 1'
      steps:
      - task: TerraformInstaller@0
        displayName: 'Installing Terraform'
        inputs:
          terraformVersion: '1.2.7'
      - task: TerraformTaskV2@2
        displayName: 'Initializing Terraform for Stage 1'
        inputs:
          provider: 'azurerm'
          command: 'init'
          workingDirectory: '$(System.DefaultWorkingDirectory)/stage-1'
          backendServiceArm: '$(subscription)'
          backendAzureRmResourceGroupName: '$(resourceGroup)'
          backendAzureRmStorageAccountName: '$(storageAccount)'
          backendAzureRmContainerName: '$(container)'
          backendAzureRmKey: '$(tfstateCoreInfraStage1File)'
        env:
          AZDO_ORG_SERVICE_URL: $(azdoOrgServiceUrl)
          AZDO_PERSONAL_ACCESS_TOKEN: $(azdoPersonalAccessToken)
      - task: TerraformTaskV2@2
        displayName: 'Create Terraform Plan for Core-Infra Stage 1'
        inputs:
          provider: 'azurerm'
          command: 'plan'
          workingDirectory: '$(System.DefaultWorkingDirectory)/stage-1'
          commandOptions: '-out=tfplan'
          environmentServiceNameAzureRM: '$(subscription)'
        env:
          AZDO_ORG_SERVICE_URL: $(azdoOrgServiceUrl)
          AZDO_PERSONAL_ACCESS_TOKEN: $(azdoPersonalAccessToken)

      - task: PowerShell@2
        displayName: 'Updating anyTfChanges1 boolean to true if there are changes'
        inputs:
          targetType: 'inline'
          script: |
            # Write-Host "LASTEXITCODE : $LASTEXITCODE"
            $plan = $(terraform show -json tfplan | ConvertFrom-Json)
            $actions = $plan.resource_changes.change.actions
            Write-Host "Terraform actions : $actions"
            if (($actions -contains 'create') -or ($actions -contains 'delete') -or ($actions -contains 'update'))
            {
              Write-Host "Terraform will perform the following actions : $actions"
              Write-Host "##vso[task.setvariable variable=anyTfChanges1;]true"
            }
            else
            {
              Write-Host "There is no change detected in Terraform tfplan file"
              Write-Host "##vso[task.setvariable variable=anyTfChanges1;]false"
            }
          workingDirectory: '$(System.DefaultWorkingDirectory)/stage-1'
        env:
          AZDO_ORG_SERVICE_URL: $(azdoOrgServiceUrl)
          AZDO_PERSONAL_ACCESS_TOKEN: $(azdoPersonalAccessToken)
      - task: TerraformTaskV2@2
        displayName: 'Applying terraform if anyTfChanges1 is true'
        condition: eq(variables.anyTfChanges1, true)
        inputs:
          provider: 'azurerm'
          command: 'apply'
          workingDirectory: '$(System.DefaultWorkingDirectory)/stage-1'
          commandOptions: 'tfplan'
          environmentServiceNameAzureRM: '$(subscription)'
        env:
          AZDO_ORG_SERVICE_URL: $(azdoOrgServiceUrl)
          AZDO_PERSONAL_ACCESS_TOKEN: $(azdoPersonalAccessToken)      
  - stage: clusterAndDbServerDeployStage2
    displayName: 'Core Component Deploy to default Kubernetes namespace'
    jobs:
    - job: runTerraformCoreInfraStage2
      displayName: 'Running Terraform Core-Infra Stage 2'
      steps:
        #need redundant task to ensure that stages can run independently 
      - task: TerraformInstaller@0
        displayName: Installing Terraform
        inputs:
          terraformVersion: '1.2.7'
      - task: TerraformTaskV2@2
        displayName: 'Initializing Terraform for Stage 2'
        inputs:
          provider: 'azurerm'
          command: 'init'
          workingDirectory: '$(System.DefaultWorkingDirectory)/stage-2'
          backendServiceArm: '$(subscription)'
          backendAzureRmResourceGroupName: '$(resourceGroup)'
          backendAzureRmStorageAccountName: '$(storageAccount)'
          backendAzureRmContainerName: '$(container)'
          backendAzureRmKey: '$(tfstateCoreInfraStage2File)'
        env:
          AZDO_ORG_SERVICE_URL: $(azdoOrgServiceUrl)
          AZDO_PERSONAL_ACCESS_TOKEN: $(azdoPersonalAccessToken)   
      - task: TerraformTaskV2@2
        displayName: 'Create Terraform Plan for Core-Infra Stage 2'
        inputs:
          provider: 'azurerm'
          command: 'plan'
          workingDirectory: '$(System.DefaultWorkingDirectory)/stage-2'
          commandOptions: '-out=tfplan'
          environmentServiceNameAzureRM: '$(subscription)'
        env:
          AZDO_ORG_SERVICE_URL: $(azdoOrgServiceUrl)
          AZDO_PERSONAL_ACCESS_TOKEN: $(azdoPersonalAccessToken)
      - task: PowerShell@2
        displayName: 'Updating anyTfChanges2 boolean to true if there are changes'
        inputs:
          targetType: 'inline'
          script: |
            # Write-Host "LASTEXITCODE : $LASTEXITCODE"
            $plan = $(terraform show -json tfplan | ConvertFrom-Json)
            $actions = $plan.resource_changes.change.actions
            Write-Host "Terraform actions : $actions"
            if (($actions -contains 'create') -or ($actions -contains 'delete') -or ($actions -contains 'update'))
            {
              Write-Host "Terraform will perform the following actions : $actions"
              Write-Host "##vso[task.setvariable variable=anyTfChanges2;]true"
            }
            else
            {
              Write-Host "There is no change detected in Terraform tfplan file"
              Write-Host "##vso[task.setvariable variable=anyTfChanges2;]false"
            }
          workingDirectory: '$(System.DefaultWorkingDirectory)/stage-2'
        env:
          AZDO_ORG_SERVICE_URL: $(azdoOrgServiceUrl)
          AZDO_PERSONAL_ACCESS_TOKEN: $(azdoPersonalAccessToken)
      - task: TerraformTaskV2@2
        displayName: 'Applying terraform if anyTfChanges2 is true'
        condition: eq(variables.anyTfChanges2, true)
        inputs:
          provider: 'azurerm'
          command: 'apply'
          workingDirectory: '$(System.DefaultWorkingDirectory)/stage-2'
          commandOptions: 'tfplan'
          environmentServiceNameAzureRM: '$(subscription)'
        env:
          AZDO_ORG_SERVICE_URL: $(azdoOrgServiceUrl)
          AZDO_PERSONAL_ACCESS_TOKEN: $(azdoPersonalAccessToken)