Azure / Azure-Spring-Apps

Azure Spring Cloud
MIT License
8 stars 5 forks source link

Autoscale settings are lost with new Production deployment #48

Open bryandx opened 1 year ago

bryandx commented 1 year ago

I've been having issues with custom autoscaling configuration. When creating the autoscaling configuration it sets the targetResourceUri to the current Production deployment of the application. When a new deployment for the application is created and set to the Production deployment, the autoscaling configuration is lost. I have example files of the JSON from the configuration attached. The file named instashare-web-autoascale-deployv1-bydeployment.json.txt is the autoscale configuration that was configured and saved for deployment 'deploy-v1'. File named instashare-web-autoascale-deployv2.json.txt is the JSON after 'deploy-v2' was created and set to Production. Notice that all original configuration was lost.

It seems like autoscaling should have a targetResourceUri of the Spring App and not a specific deployment because we're going to continually be creating new deployments and we shouldn't have to keep re-creating autoscaling configuration each time we create a new deployment.

I used terraform resource azurerm_monitor_autoscale_setting to test out setting the targetResourceUri to a Spring App resource (not a specific deployment) and applying that terraform change resulted in an error: │ Error: creating Monitor Autoscale Setting: (Name "instashare-web-autoscale" / Resource Group "rg-lzcorpspring-prod-cus-01"): insights.AutoscaleSettingsClient#CreateOrUpdate: Failure responding to request: StatusCode=400 -- Original Error: autorest/azure: Service returned an error. Status=400 Code="ResourceNotSupported" Message="The target resource id '/subscriptions/9aa02046-18ee-4de0-bd58-3c9586f39df2/resourceGroups/rg-lzcorpspring-prod-cus-01/providers/Microsoft.AppPlatform/spring/spring-lzcorpspring-prod-cus-01/apps/instashare-web' is not supported." I've attached the full terraform apply output with errors in the file terraform-spring-app-autoscale-fail.txt

It also seems like the Metric Source should be the Spring App resource and not the current Production deployment resource at that point of time. And the Dimension should just include the Instance value. The deployment should just be the current running Production deployment resource at runtime. When configuring autoscaling, I changed the Metric Source to the overall Spring Apps Service and then picked the app and all deployment values as one configuration approach - see file instashare-web-autoascale-deployv1-byapp.json.txt. But I wasn't sure if that approach would actually pickup the Staging deployment metrics if it was actually running? The other configuration approach was to pick the app and a specific deployment (see file instashare-web-autoascale-deployv1-bydeployment.json.txt) but that doesn't seem correct because, per the point of this Issue, that would seem to break when the next production deployment is created.

To Reproduce Steps to reproduce the behavior:

  1. Create a production deployment of a Spring App
  2. Create custom autoscale configuration for that deployment
  3. Create a new production deployment of the same Spring App
  4. Notice that the custom autoscale configuration is not gone for the Spring App in the Portal and it is set to Manual scale

Expected behavior The autoscaling config should remain on each new deployment of the application

Can we contact you for additional details? Y/N Y

instashare-web-autoascale-deployv1-bydeployment.json.txt

instashare-web-autoascale-deployv2.json.txt

instashare-web-autoascale-deployv1-byapp.json.txt

terraform-spring-app-autoscale-fail.txt

Sneezry commented 1 year ago

Hi @bryandx, this is expected behavior. The autoscale setting is tied to the Deployment rather than the App. So, you'll need to create a new autoscale setting for the new Deployment using the same rules before swapping out the Deployment.

Please note that App is an abstract concept, and Deployment is the actual resource that provides the operating environment for running business applications. Most of the actions taken to operate a business application occur on the Deployment, including scaling, stop and restart.

vermegi commented 4 months ago

I have another customer reporting the same 'issue'. As in, yes, this might be expected behavior, but it creates additional maintenance steps for customers that create a new deployment for each deploy they execute. Could we maybe get a setting that pins the scale out rules to the app and then applies those on all deployments?

vermegi commented 4 months ago

I also just found this: https://github.com/Azure/Azure-Spring-Apps/issues/40 Can something similar like the service connector on app level be done for the scale rules?