Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

application_gateway bug on request_routing_rule causes recreations #15841

Open
wc-whiteheadd opened this issue Mar 15, 2022 · 8 comments
Open

Comments

@wc-whiteheadd
Copy link

Currently the "azurerm_application_gateway" takes "request_routing_rule" which can have an optional field of priority. The problem with the priority field is that Azure defaults the value to 0 and the only values terraform allows are null or 1-2000. This seems fine until you want to add/remove any additional rules as Terraform now thinks all the rules are changing from 0 to NULL and makes you recreate them all again, rather than just the changes being added/removed.

I suspect this can easily be fixed by changing the validation logic to accept 0 on the priority field and defaulting NULL to 0 to match Azures logic.

@wc-whiteheadd
Copy link
Author

@myc2h6o Thanks for this, your explanation makes perfect sense!

I must admit though, i am not convinced this is a great idea for any production service, taking down a production service for a second while it re-adds all the rules, is certainly not a great option. Would it be possible to have seperate modules for adding the rules etc against an application gateway Id in the future to try and get around this?

@martinhelgesen
Copy link

Im in the same situation.

Will the rules actually get deleted and then re-added and cause downtime for all rules/listeners?
Or is it just the changeset that lists this way and Azure is smart enough to keep things intact during this operation and only actually change affected rules/listener?

@wenesak
Copy link

wenesak commented May 8, 2022

Same here we will start using Appp Gateway for multi app hosting, but based on my testing when I add additional request_routing_rules all of the existing ones get recreated causing a little downtime on all the apps, please fix !!!

@myc2h6o
Copy link
Contributor

myc2h6o commented May 9, 2022

I've done a small test with the application gateway routing requests to a raw nginx server on an ubuntu vm. When adding/modifying the request_routing_rules, there is no downtime during my test. By looking at the code, although the Terraform diff shows the removing/adding for the TypeSet, the provider doesn't remove all the routing rules, it just sends the PUT request to the service with the updated routing rules (in below code snippets). I've also tried modifying the rules on Azure Portal and the API request is same as it in the provider.

if d.HasChange("request_routing_rule") {
requestRoutingRules, err := expandApplicationGatewayRequestRoutingRules(d, id.ID())
if err != nil {
return fmt.Errorf("expanding `request_routing_rule`: %+v", err)
}
applicationGateway.ApplicationGatewayPropertiesFormat.RequestRoutingRules = requestRoutingRules
}

future, err := client.CreateOrUpdate(ctx, id.ResourceGroup, id.Name, applicationGateway)
if err != nil {
return fmt.Errorf("updating %s: %+v", id, err)
}


However, when gateway_ip_configuration.subnet_id changes, the application gateway will be stopped and restarted. It does cause a downtime when updating it (About 5 minutes in my test).

if newSubnetID != oldSubnetID {
stopApplicationGateway = true
}


@wenesak in your test did you update the gateway_ip_configuration.subnet_id? If not, I would recommend contacting Azure support to see if there is any issue on the service side.

@pkgw
Copy link

pkgw commented Sep 27, 2022

I've just experienced what I think is a related issue. After upgrading from v2 to v3 of the azurerm provider, I got change plans that look as if they wanted to recreate my request_routing_rule items, even after a terraform apply -refresh-only:

      - request_routing_rule {
          - name               = "anyhost-http-path-routing" -> null
          - priority           = 10010 -> null
          [more similar removals]
        }
      + request_routing_rule {
          + name                      = "anyhost-http-path-routing"
          [more similar additions, but no "priority"]
        }

My configuration file did not specify the priority setting. By explicitly adding a new priority setting to my request routing rules, the rule recreation simply disappeared. I would have expected that the change plan would have looked more like:

      ~ request_routing_rule {
          ~ priority           = 10010 -> null
          [NN unchanged items]
        }

This is with a Standard_v2 SKU.

@speak2beeb
Copy link

I'm also experiencing this today with azurerm version 3.89.0.
I'm gonna open up a ticket w/ Hashi.

@sujatha-tandem
Copy link

I am also experiencing the same issue with azurerm version 3.89.0. It is trying to recreate the routing rules in app gateway

@sujatha-tandem
Copy link

Any one have solution for this ?
@speak2beeb did harshicorp provide any solution ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

8 participants