Azure / azure-cli

Azure Command-Line Interface
MIT License
3.99k stars 2.97k forks source link

az containerapp update does not fail when the yaml file points to a non-existent image #30053

Open sonofhammer opened 3 days ago

sonofhammer commented 3 days ago

Describe the bug

az container app update does not fail when yaml file points to a nonexistent container image.

To reproduce

  1. create a container app with a hello world image

az containerapp create -n 'example' -g 'my-rg' --yaml .\app.yaml

Example file:

environmentId: <INSERT ENVIRONMENT ID HERE>
properties:
  configuration:
    activeRevisionsMode: Single
    maxInactiveRevisions: 100
  template:
    containers:
    - image: mcr.microsoft.com/azuredocs/containerapps-helloworld:latest
      name: examplecontainerapp
      probes: []
      resources:
        cpu: 0.25
        ephemeralStorage: 1Gi
        memory: 0.5Gi
    revisionSuffix: ''
    scale:
      maxReplicas: 10
      minReplicas: 1
      rules:
      - http:
          metadata:
            concurrentRequests: '10'
        name: http-scaler
  1. modify the file and replace the image with a nonexistent image, for example:
...
template:
    containers:
    - image: mcr.microsoft.com/azuredocs/containerapps-helloworld:nonexistent
...
  1. run az containerapp update

az containerapp update -n 'example' -g 'my-rg' --yaml .\app.yaml

  1. observe that the az cli exits with zero but the output shows a provisioning state of "failed." Also, note that the container image property has not been updated.
    "provisioningState": "Failed",
    "runningStatus": "Running",
    "template": {
      "containers": [
        {
          "image": "mcr.microsoft.com/azuredocs/containerapps-helloworld:latest",
          "name": "examplecontainerapp",
          "probes": [],
          "resources": {
            "cpu": 0.25,
            "ephemeralStorage": "1Gi",
            "memory": "0.5Gi"
          }
        }
      ],
  1. using the same container app file with an image that doesn't exist run az containerapp create

az containerapp create -n 'example2' -g 'my-rg' --yaml .\app.yaml

  1. observe that the run fails with
Failed to provision revision for container app 'example2'. Error details: The following field(s) are either invalid or missing. Field 'template.containers.examplecontainerapp.image' is invalid with details: 'Invalid value: "mcr.microsoft.com/azuredocs/containerapps-helloworld:nonexistent": GET https:: MANIFEST_UNKNOWN: manifest tagged by "nonexistent" is not found; map[Tag:nonexistent]';

Related command

az containerapp update

Errors

n/a it doesn't error when it should

Issue script & Debug output

n/a. this is easily reproducible with a few command line calls.

Expected behavior

Desired resolution

az containerapp update should fail just like az containerapp create when the yaml file points to a container image that doesn't exist.

Environment Summary

azure-cli 2.61.0 *

core 2.61.0 * telemetry 1.1.0

Extensions: azure-devops 1.0.0 containerapp 0.3.50

Dependencies: msal 1.28.0 azure-mgmt-resource 23.1.1

Python location 'C:\Program Files\Microsoft SDKs\Azure\CLI2\python.exe' Extensions directory 'C:\Users\DaniilM.azure\cliextensions'

Python (Windows) 3.11.8 (tags/v3.11.8:db85d51, Feb 6 2024, 22:03:32) [MSC v.1937 64 bit (AMD64)]

Legal docs and information: aka.ms/AzureCliLegal

Additional context

No response

azure-client-tools-bot-prd[bot] commented 3 days ago

Hi @sonofhammer,

2.61.0 is not the latest Azure CLI(2.65.0).

If you haven't already attempted to do so, please upgrade to the latest Azure CLI version by following https://learn.microsoft.com/en-us/cli/azure/update-azure-cli.

yonzhan commented 3 days ago

Thank you for opening this issue, we will look into it.

microsoft-github-policy-service[bot] commented 3 days ago

Thanks for the feedback! We are routing this to the appropriate team for follow-up. cc @dkkapur.

microsoft-github-policy-service[bot] commented 3 days ago

Thanks for the feedback! We are routing this to the appropriate team for follow-up. cc @calvinsID.

sonofhammer commented 3 days ago

Behavior is the same on the latest version of az and extensions

azure-cli                         2.65.0

core                              2.65.0
telemetry                          1.1.0

Extensions:
azure-devops                       1.0.1
containerapp                     1.0.0b3

Dependencies:
msal                              1.31.0
azure-mgmt-resource               23.1.1

Python location 'C:\Program Files\Microsoft SDKs\Azure\CLI2\python.exe'
Extensions directory 'C:\Users\DaniilM\.azure\cliextensions'

Python (Windows) 3.11.8 (tags/v3.11.8:db85d51, Feb  6 2024, 22:03:32) [MSC v.1937 64 bit (AMD64)]
sonofhammer commented 3 days ago

I recognize that this may be more of a container app environment api issue than an az cli issue in and of itself.

sonofhammer commented 3 days ago

usecase where this is relevant

  1. I create a hello world app using terraform. This allows me to hook the app's managed identity up to anything it may need.
  2. i then manage the container image, its version and all container app settings using a yaml file in the pipeline. This allows me to deploy new versions of the image without having to mess with my terraform infra.

Sometimes I fatfinger the container image name, and i spend time debugging why the app hasn't updated even though the cli returned successfully.

tesar-tech commented 2 days ago

I also have/had this issue. I suspect that it is somehow related to the Azure container apps. Specifically to the registry from where it takes the image. I was experimenting with deleting the image version from registry and when the app tried to run (starting from 0 replicas) the image version wasn't there, which caused the error.

I was unable to change anything, either from cli or portal. Only deleting and creating the app again helped.