astronomer / astro-cli

CLI that makes it easy to create, test and deploy Airflow DAGs to Astronomer
https://www.astronomer.io
Other
350 stars 70 forks source link

DEV - Inspecting worker queues using keys is giving a panic error #1584

Open shri-astro opened 7 months ago

shri-astro commented 7 months ago

The following command history indicates that on passing worker_queues.name to inspect the worker_queue name, the panic error is issued whereas for configuration and metadata sections the output seems to be as expected. This issue is seen in the latest version of CLI 1.24.1

shrividyahegde@Hegde ~ %  astro deployment inspect
Select a Deployment
 #     DEPLOYMENT NAME     RELEASE NAME            DEPLOYMENT ID                 DAG DEPLOY ENABLED     
 1     1                   true-bolometer-9207     cltcoqi2k09fw01jlu8le45h3     true                   

> 1
deployment:
    configuration:
        name: "1"
        description: ""
        runtime_version: 10.4.0
        dag_deploy_enabled: true
        ci_cd_enforcement: false
        scheduler_size: SMALL
        is_high_availability: false
        is_development_mode: false
        executor: CELERY
        scheduler_count: 1
        workspace_name: Automation CLI dev workspace
        deployment_type: STANDARD
        cloud_provider: GCP
        region: us-east4
        default_task_pod_cpu: "0.25"
        default_task_pod_memory: 0.5Gi
        resource_quota_cpu: "10"
        resource_quota_memory: 20Gi
        workload_identity: ""
    worker_queues:
        - name: default
          max_worker_count: 10
          min_worker_count: 0
          worker_concurrency: 5
          worker_type: A5
    metadata:
        deployment_id: cltcoqi2k09fw01jlu8le45h3
        workspace_id: cls8kdoks00bk01pcuus8lfhl
        cluster_id: N/A
        release_name: N/A
        airflow_version: 2.8.2
        current_tag: 10.4.0
        status: HEALTHY
        created_at: 2024-03-04T08:34:35.28Z
        updated_at: 2024-03-04T08:34:35.28Z
        deployment_url: cloud.astronomer-dev.io/cls8kdoks00bk01pcuus8lfhl/deployments/cltcoqi2k09fw01jlu8le45h3/overview
        webserver_url: cls8jv7rv005n01nwea4m87p5.astronomer-dev.run/d8le45h3?orgId=org_9zXCd6J5uyO30beS

shrividyahegde@Hegde ~ % astro deployment inspect --deployment-name 1 -k worker_queues.name
panic: interface conversion: interface {} is []map[string]interface {}, not map[string]interface {}

goroutine 1 [running]:
github.com/astronomer/astro-cli/cloud/deployment/inspect.getSpecificField(0x103f4c2a0?, {0x16cf0f9c8, 0x12})
    /go/src/github.com/astronomer/astro-cli/cloud/deployment/inspect/inspect.go:433 +0x1ec
github.com/astronomer/astro-cli/cloud/deployment/inspect.Inspect({0x1400015b6c0, 0x19}, {0x16cf0f9c3?, 0x0?}, {0x0?, 0x0?}, {0x103bc279d, 0x4}, {0x10417f230, 0x14000336c20}, ...)
    /go/src/github.com/astronomer/astro-cli/cloud/deployment/inspect/inspect.go:151 +0x514
github.com/astronomer/astro-cli/cmd/cloud.deploymentInspect(0x0?, {0x140002f5340, 0x0, 0x0?}, {0x10415e868, 0x14000128020})
    /go/src/github.com/astronomer/astro-cli/cmd/cloud/deployment_inspect.go:51 +0x110
github.com/astronomer/astro-cli/cmd/cloud.newDeploymentInspectCmd.func1(0x14000096f00?, {0x140002f5340?, 0x4?, 0x103bc28c9?})
    /go/src/github.com/astronomer/astro-cli/cmd/cloud/deployment_inspect.go:25 +0x28
github.com/spf13/cobra.(*Command).execute(0x1400009cf00, {0x140002f5300, 0x4, 0x4})
    /go/pkg/mod/github.com/spf13/cobra@v1.7.0/command.go:940 +0x66c
github.com/spf13/cobra.(*Command).ExecuteC(0x140001d8300)
    /go/pkg/mod/github.com/spf13/cobra@v1.7.0/command.go:1068 +0x320
github.com/spf13/cobra.(*Command).Execute(0x104176718?)
    /go/pkg/mod/github.com/spf13/cobra@v1.7.0/command.go:992 +0x1c
main.main()
    /go/src/github.com/astronomer/astro-cli/main.go:21 +0x38
shrividyahegde@Hegde ~ % astro version
Astro CLI Version: 1.24.1

What CLI Version did you experience this bug? 1.24.1

This CLI bug is related to which Astronomer Platform? Astro

shri-astro commented 7 months ago

Also for the description field or anyfield where the value is "", the error message is issued saying the key isn't found.

shrividyahegde@Hegde ~ % astro deployment inspect --deployment-name 1 -k configuration.description
Error: requested key configuration.description not found in deployment
sunkickr commented 7 months ago

I think in the first one you have to do:

astro deployment inspect --deployment-name 1 -k worker_queues[0].name

and for the second it will produce that error if the field is blank

shri-astro commented 4 months ago

On the latest version, for the worker queue inspect issue the following commands were tried and the error message was seen

shrividyahegde@Hegde ~ % astro deployment inspect --deployment-name nest                         
deployment:
    configuration:
        name: nest
        description: ""
        runtime_version: 11.4.0
        dag_deploy_enabled: true
        ci_cd_enforcement: false
        scheduler_size: SMALL
        is_high_availability: false
        is_development_mode: false
        executor: CELERY
        scheduler_count: 1
        workspace_name: Test ws
        deployment_type: STANDARD
        cloud_provider: AWS
        region: us-east-1
        default_task_pod_cpu: "0.25"
        default_task_pod_memory: 0.5Gi
        resource_quota_cpu: "10"
        resource_quota_memory: 20Gi
        workload_identity: ""
    worker_queues:
        - name: default
          max_worker_count: 10
          min_worker_count: 0
          worker_concurrency: 5
          worker_type: A5
        - name: something
          max_worker_count: 10
          min_worker_count: 0
          worker_concurrency: 5
          worker_type: A5
    metadata:
        deployment_id: clwszytzq00u201mtqoe05vn7
        workspace_id: cltmwnl4902of01ji1p7b8bji
        cluster_id: N/A
        release_name: N/A
        airflow_version: 2.9.1
        current_tag: 11.4.0
        status: HEALTHY
        created_at: 2024-05-30T08:32:25.68Z
        updated_at: 2024-05-30T08:41:27.882Z
        deployment_url: cloud.astronomer-dev.io/cltmwnl4902of01ji1p7b8bji/deployments/clwszytzq00u201mtqoe05vn7/overview
        webserver_url: cltmwmi0202no01jiijl6bn6q.astronomer-dev.run/doe05vn7?orgId=org_Mn8ZCdWsv9wyexSl
        airflow_api_url: cltmwmi0202no01jiijl6bn6q.astronomer-dev.run/doe05vn7/api/v1
    alert_emails:
        - shrividya.hegde@astronomer.io

shrividyahegde@Hegde ~ % astro deployment inspect --deployment-name nest -k worker_queues[1].name
zsh: no matches found: worker_queues[1].name
shrividyahegde@Hegde ~ % astro deployment inspect --deployment-name nest -k deployment.worker_queues[1].name
zsh: no matches found: deployment.worker_queues[1].name
dym-ok commented 2 months ago

Hey @shri-astro Try enclosing your key expression into single quotes '', currently zsh tries to interpret it.