microsoft / azure-container-apps

Roadmap and issues for Azure Container Apps
MIT License
361 stars 29 forks source link

Unable to set revision label using Azure CLI when running in Single Revision Mode #983

Open tjementum opened 10 months ago

tjementum commented 10 months ago

Please provide us with the following information:

This issue is a: (mark with an x)

Issue description

I'm trying to make the application version visible on my revisions page. I see two options:

  1. Revision suffix
  2. Label

But I have a problem:

CleanShot 2023-11-09 at 13 57 58

Actual behavior [What actually happened.] This last az containerapp revision label add should set the label 2023-10-31-7 on the revision named account-management-api--2023-10-31-7. But as this screenshot shows the label is latest:

CleanShot 2023-11-09 at 14 00 06

Also, if I call az containerapp show --name account-management-api ... to inspect the container app I get this response:

{
  "name": "account-management-api",
  "properties": {
    "configuration": {
      ...
      "activeRevisionsMode": "Single",
      "ingress": {
        ...
        "traffic": [
          {
            "label": "latest",
            "latestRevision": true,
            "weight": 100
          },
          {
            "label": "2023-10-31-7",
            "revisionName": "account-management-api--2023-10-31-7",
            "weight": 0
          }
        ]
      }
    },
    "latestReadyRevisionName": "account-management-api--2023-10-31-7",
    "template": {
      ...
      "revisionSuffix": "2023-10-31-7",
    }
  }

Notice that "traffic" has two revisions, where the revision named account-management-api--2023-10-31-7 with label 2023-10-31-7 has 0% traffic, and the one with 100% traffic has the latest label. This is clearly wrong. Remember I'm running in Single Revision mode.

Expected behavior [What you expected to happen.]

I'm expecting that this command will set the label of the active revision

az containerapp revision label add --name account-management-api --label 2023-10-31-7 --revision account-management-api--2023-10-31-7

Even better. I would love if the az containerapp update... would take a --label parameter, so this can be done in one operation.

Steps to reproduce

I believe the reproduction steps are clear from above. Otherwise, a full reproducible example of a real-world solution can be found here PlatformPlatform (I will likely make a workaround, so check this commit).

howang-ms commented 9 months ago

In the first screenshot below, it shows latest, because I currently don't have the actual version when deploying Bicep. Thank you for the feedback, we will check and see how to make the improvement.

Notice that "traffic" has two revisions, where the revision named account-management-api--2023-10-31-7 with label 2023-10-31-7 has 0% traffic, and the one with 100% traffic has the latest label. This is clearly wrong. Remember I'm running in Single Revision mode.

This is actually by design. The latestRevision is a special revision and you can attach a label with it. At the same time, you can have the label for other revisions (even if it is the latest revsion) too. The single revision mode means you will only have one active revision and take 100% traffic at a time, but having other revisions with 0 weight is allowed.

tjementum commented 9 months ago

Hi Howang,

Thanks for the answer... much appreciated 😃

I think I failed to describe the problem clearly. So let me try to explain my goal.

I'm trying to ensure the "active" revision has a label that shows the version number. I would love that to be an integrated part of Azure Container App.

The very first time I deploy the container app using Bicep I use the image with the latest tag from my container registry, and set latest as a label. I've actually changed that to initial in my setup to make it clear. I think that is what made my post confusing?

After the initial deployment using Bicep, I update the container image using Azure CLI, I set the suffix to the version number. I use date as the version number e.g. 2023-11-30-7. I ALSO change the label of the just deployed revision to 2023-11-30-7. These are the two commands I run:

az containerapp update --name account-management-api ... --revision-suffix 2023-10-31-7
az containerapp revision label add --name account-management-api --label 2023-10-31-7 --revision account-management-api--2023-10-31-7

Would you agree this should set the label of the revision with suffix 2023-10-31-7 to 2023-10-31-7? If you look at my screenshot the revision with suffix 2023-10-31-7 has the label latest (coming from my initial Bicep deployment). IMO, this is clearly wrong, and hence the bug report.

If this is by design, then how can I change the label of the active revision using Azure CLI, so it shows e.g. the version number?

karpikpl commented 7 months ago

Hey @tjementum - were you able to solve this?

Would you be able to share your bicep solution?

PS: In my infrastructure deployment I've implemented a way for Bicep to read the currently active container image version, so it does not rollback to latest.

I think there's a bug in ACA where you cannot set label on a revision that has traffic weight 0 - both in single or multiple revision mode.

tjementum commented 6 months ago

Would you be able to share your bicep solution?

I gave up using labels, but instead named my revisions with version numbers, see screenshot.

I'm building an Open-Source project that shows how to create a SaaS product, so you can find the entire solution here: https://github.com/platformplatform/PlatformPlatform.

If you follow the very simple "Getting started" steps, you should be able to get this up and running.

CleanShot 2024-02-17 at 13 13 34@2x

masonhuemmer commented 1 month ago

Is there any update to this? The ACA commands for labels do not work with traffic weight is set to 0%.

karpikpl commented 1 month ago

I was able to make it work but the issue is still there. If you read current state of ACA (not trivial) and then build your manifest accordingly, you can make it work

properties:
  configuration:
    ingress:
      traffic:
      - latestRevision: true
        label: preview
        weight: 0
      - revisionName: __CURRENT_PRODUCTION_REVISION__
        weight: 100
        label: production

but it would be nice if it worked out of the box and you could have "preview" slots

tjementum commented 1 month ago

I was able to make it work but the issue is still there.

Seems like you are using multiple revisions. The original problem is for single revisions.