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 functions app website_contenteshare unwanted changes #10494

Conversation

uolter
Copy link
Contributor

@uolter uolter commented Feb 7, 2021

This PR wants to fix the issue described here.

#10499

Maybe some tests are missed or there might be better approaches.

@uolter
Copy link
Contributor Author

uolter commented Apr 7, 2021

@jackofallops I noticed you label my PR with breaking-change. Can you provide me some details?
I'd like to try to fix it in a better way.
Due to this issue #10499 the current version is also unusable.

@katbyte
Copy link
Collaborator

katbyte commented Apr 23, 2021

@uolter - I believe he's marked it as such because the underlying metadata setting is used by deployed apps, thus anyone not using slots could face a breaking change if this is swapped out without warning.

Ideally we would not want to change the behaviour so a fix that doesn't change the existing behaviour but fixes the specific problem would be ideal.

@uolter
Copy link
Contributor Author

uolter commented May 2, 2021

@uolter - I believe he's marked it as such because the underlying metadata setting is used by deployed apps, thus anyone not using slots could face a breaking change if this is swapped out without warning.

Ideally we would not want to change the behaviour so a fix that doesn't change the existing behaviour but fixes the specific problem would be ideal.

@katbyte I've tried a different approach not changing the current behavior, but so far no clue.
It looks to me - and correct me if I am wrong - it was a bad idea to remove the app settings WEBSITE_CONTENTSHARE
inside the read function.
https://github.com/terraform-providers/terraform-provider-azurerm/blob/057c68ea3e5e0935815433d86366ffbeb77df76e/azurerm/internal/services/web/function_app_resource.go#L687

delete(appSettings, "WEBSITE_CONTENTSHARE")

Why not let the user explicitly define that setting inside *.tf code ?

 app_settings = {
        FUNCTIONS_WORKER_RUNTIME = "node"
        WEBSITE_NODE_DEFAULT_VERSION = "~14"
        ...........
        WEBSITE_CONTENTSHARE = "staging-content"
    }
....
....
 lifecycle {
        ignore_changes = [
          app_settings["WEBSITE_CONTENTSHARE"],
        ]
    }

Forcing the creation of that setting inside the Create and Update with fixed values breaks the behavior in functions with slots when swapping. Which is very damaging and risky. It happened to me in production twice before understanding there was a bug.
How can I prevent that inside the resourceFunctionAppUpdate the WEBSITE_CONTENTSHARE does not change (in respect of what I see in the portal after swapping slots ) ?

@katbyte
Copy link
Collaborator

katbyte commented May 4, 2021

@uolter - i'm not sure there is a way to make this fix without a breaking change to the behaviour of how this resource works, it may have to way until 3.0.

@realrubberduckdev
Copy link

Hi @uolter , the ignore_changes idea in your example above, is that supposed to work now? It doesn't seem to ignore and still changes WEBSITE_CONTENTSHARE for me.

 lifecycle {
        ignore_changes = [
          app_settings["WEBSITE_CONTENTSHARE"],
        ]
    }

The only case Terraform doesn't change the value is if I ignore all.

 lifecycle {
        ignore_changes = [
          all
        ]
    }

But that will mean we cannot make changes via terraform anymore, so not really a solution.

@uolter
Copy link
Contributor Author

uolter commented Jun 4, 2021

Hi @uolter , the ignore_changes idea in your example above, is that supposed to work now? It doesn't seem to ignore and still changes WEBSITE_CONTENTSHARE for me.

 lifecycle {
        ignore_changes = [
          app_settings["WEBSITE_CONTENTSHARE"],
        ]
    }

The only case Terraform doesn't change the value is if I ignore all.

 lifecycle {
        ignore_changes = [
          all
        ]
    }

But that will mean we cannot make changes via terraform anymore, so not really a solution.

Hi @realrubberduckdev , it works to me, but I am working with a custom provider with changes described in this PR: https://github.com/terraform-providers/terraform-provider-azurerm/blob/057c68ea3e5e0935815433d86366ffbeb77df76e/azurerm/internal/services/web/function_app_resource.go#L687
However, it's a breaking change. It's not backwards compatible.
As I said it works to me and I do not risk anymore to break production when I run an apply after a swap I started from the portal or via azure devops pipeline.

@jackofallops
Copy link
Member

Thanks @uolter for the PR, and apologies for the delay in getting back to it, however I'm going to close this in favour of #13349 which should handle the breaking cases by leaving existing configurations intact, but appropriately create the setting where necessary.

@katbyte katbyte added this to the v2.77.0 milestone Sep 16, 2021
katbyte pushed a commit that referenced this pull request Sep 16, 2021
…tings` for `WEBSITE_CONTENTSHARE` (#13349)

fixes #10499
fixes #12914
supersedes #10494
@github-actions
Copy link

This functionality has been released in v2.77.0 of the Terraform Provider. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading.

For further feature requests or bug reports with this functionality, please create a new GitHub issue following the template. Thank you!

@github-actions
Copy link

I'm going to lock this pull request because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active contributions.
If you have found a problem that seems related to this change, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Oct 18, 2021
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.

4 participants