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

Fix/workaround for #7470 and #6041 #7471

Closed

Conversation

nitzanm
Copy link
Contributor

@nitzanm nitzanm commented Jun 24, 2020

#7470 happens because Traffic Manager Profile update is a PUT request. PUT, by definition, replaces the entire object. Since the list of Endpoints is part of the Profile object in Azure, it is cleared because the provider doesn't specify it in the PUT request.

Since our schema specifies Endpoints as separate objects than the Profile, we shouldn't be touching the endpoints when updating a Profile. There are two ways to do that:

  1. Replace the PUT with a PATCH. I don't like this because that allows for config drift, especially if Traffic Manager Profiles have new attributes in the future that the provider doesn't know about yet.
  2. Retrieve all endpoints and copy them into the PUT request so that they aren't affected. Is this beautiful? Absolutely not, but I don't see a better solution given the restrictions.

(fixes #6041)

@ghost ghost added the size/S label Jun 24, 2020
@nitzanm nitzanm changed the title Fix/workaround for #7470 Fix/workaround for #7470 and #6041 Jun 24, 2020
@nitzanm
Copy link
Contributor Author

nitzanm commented Jun 26, 2020

@tombuildsstuff could you possibly re-trigger the build? Looks like it failed with an error unrelated to my changes (while installing tooling), but I don't have permission to re-run it.

Copy link
Contributor

@ArcturusZhang ArcturusZhang left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @nitzanm thanks for your PR!

The root cause of issue #6041 should be we are using the PUT request for updating a resource, and as a separated virtual resource endpoint we will never specify those in the profile, therefore every time we apply, Azure will erase all the endpoints. Therefore, instead of making patches for the PUT request, it would be more elegant to update this resource using the PATCH request. And the profilesClient does have a function of Update which sends a PATCH request.

Could we please introduce a separated function for update and use the client.Update in it to fix this issue?
What do you think?

@IvanKirianov
Copy link

Hi guys,
When you are plan to merge this bugfix?
Thanks!

@ghost ghost removed the waiting-response label Jul 3, 2020
@nitzanm
Copy link
Contributor Author

nitzanm commented Jul 3, 2020

@ArcturusZhang I don't have a strong opinion on it either way; I'm OK with changing it to use PATCH instead. I'll try to get to it next week.

BTW: any idea why the CI build is failing? It looks to me like an environment error rather than something introduced by my code changes, but perhaps you have some insight?

@ArcturusZhang
Copy link
Contributor

Hi @ArcturusZhang actually you can ignore that CI failure since it is caused by some random connection issues. When you make a new commit, the CI could automatically get triggered again.

@rohinz
Copy link

rohinz commented Jul 14, 2020

Hi @ArcturusZhang actually you can ignore that CI failure since it is caused by some random connection issues. When you make a new commit, the CI could automatically get triggered again.

@nitzanm Can you give it a try?

@katbyte
Copy link
Collaborator

katbyte commented Aug 11, 2020

Hi @nitzanm, thanks for this PR. As comments have been addressed by #7846 i'm going to close this in favour of it

@katbyte katbyte closed this Aug 11, 2020
@katbyte katbyte added this to the v2.23.0 milestone Aug 11, 2020
katbyte pushed a commit that referenced this pull request Aug 11, 2020
… longer destroys all the endpoints (#7846)

Fixes #6041
Supersedes #7471

Special thanks to @nitzanm

I also updated the test cases, since the relative_name in dns_config block is a ForceNew attribute, therefore it makes no sense to change in an update test case.
@ghost
Copy link

ghost commented Aug 13, 2020

This has been released in version 2.23.0 of the provider. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading. As an example:

provider "azurerm" {
    version = "~> 2.23.0"
}
# ... other configuration ...

@ghost
Copy link

ghost commented Sep 10, 2020

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.

If you feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. If you feel I made an error 🤖 🙉 , please reach out to my human friends 👉 hashibot-feedback@hashicorp.com. Thanks!

@ghost ghost locked and limited conversation to collaborators Sep 10, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Changes to azurerm_traffic_manager_profile destroys endpoints
6 participants