-
Notifications
You must be signed in to change notification settings - Fork 4.7k
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
azurerm_windows[linux]_web_app_[slot]
- add docker setting to app_setting
block
#22484
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @xiaxyi - Thanks for this PR, I've left some comments below to more cleanly resolve the reported bugs, if you can take a look?
Thanks!
if appSettings == nil { | ||
appSettings = map[string]string{} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This avoids the crash, but unfortunately doesn't correctly address the bug of the values not being set, as the line
expanded.AppSettings = ExpandAppSettingsForCreate(appSettings)
is missing from this function.
if appSettings == nil { | ||
appSettings = map[string]string{} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As above, the missing values bug is due to the app settings not being written to the expand
via
expanded.AppSettings = ExpandAppSettingsForCreate(appSettings)
after the entries are added.
if appSettings == nil { | ||
appSettings = map[string]string{} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here, as above.
if appSettings == nil { | ||
appSettings = map[string]string{} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
again here
if appSettings == nil { | ||
appSettings = map[string]string{} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
and again here
if metadata.ResourceData.HasChange("app_settings") || metadata.ResourceData.HasChange("site_config.0.health_check_eviction_time_in_min") || metadata.ResourceData.HasChanges("site_config.0.application_stack") { | ||
if siteConfigAppSetting := existing.SiteConfig.AppSettings; siteConfigAppSetting != nil && len(*siteConfigAppSetting) > 0 { | ||
if state.AppSettings == nil { | ||
state.AppSettings = make(map[string]string) | ||
} | ||
for _, pair := range *siteConfigAppSetting { | ||
if pair.Name == nil || pair.Value == nil { | ||
continue | ||
} | ||
if *pair.Name == "DOCKER_REGISTRY_SERVER_URL" || | ||
*pair.Name == "DOCKER_REGISTRY_SERVER_USERNAME" || | ||
*pair.Name == "DOCKER_REGISTRY_SERVER_PASSWORD" { | ||
state.AppSettings[*pair.Name] = *pair.Value | ||
} | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
and here
if siteConfigAppSetting := siteConfig.AppSettings; siteConfigAppSetting != nil && len(*siteConfigAppSetting) > 0 { | ||
if webApp.AppSettings == nil { | ||
webApp.AppSettings = make(map[string]string) | ||
} | ||
for _, pair := range *siteConfigAppSetting { | ||
if pair.Name == nil || pair.Value == nil { | ||
continue | ||
} | ||
if *pair.Name == "DOCKER_REGISTRY_SERVER_URL" || | ||
*pair.Name == "DOCKER_REGISTRY_SERVER_USERNAME" || | ||
*pair.Name == "DOCKER_REGISTRY_SERVER_PASSWORD" { | ||
webApp.AppSettings[*pair.Name] = *pair.Value | ||
} | ||
} | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
and here
if metadata.ResourceData.HasChange("app_settings") || metadata.ResourceData.HasChange("site_config.0.health_check_eviction_time_in_min") || metadata.ResourceData.HasChanges("site_config.0.application_stack") { | ||
if siteConfigAppSetting := existing.SiteConfig.AppSettings; siteConfigAppSetting != nil && len(*siteConfigAppSetting) > 0 { | ||
if state.AppSettings == nil { | ||
state.AppSettings = make(map[string]string) | ||
} | ||
for _, pair := range *siteConfigAppSetting { | ||
if pair.Name == nil || pair.Value == nil { | ||
continue | ||
} | ||
if *pair.Name == "DOCKER_REGISTRY_SERVER_URL" || | ||
*pair.Name == "DOCKER_REGISTRY_SERVER_USERNAME" || | ||
*pair.Name == "DOCKER_REGISTRY_SERVER_PASSWORD" { | ||
state.AppSettings[*pair.Name] = *pair.Value | ||
} | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
again here
if siteConfigAppSetting := siteConfig.AppSettings; siteConfigAppSetting != nil && len(*siteConfigAppSetting) > 0 { | ||
if webAppSlot.AppSettings == nil { | ||
webAppSlot.AppSettings = make(map[string]string) | ||
} | ||
for _, pair := range *siteConfigAppSetting { | ||
if pair.Name == nil || pair.Value == nil { | ||
continue | ||
} | ||
if *pair.Name == "DOCKER_REGISTRY_SERVER_URL" || | ||
*pair.Name == "DOCKER_REGISTRY_SERVER_USERNAME" || | ||
*pair.Name == "DOCKER_REGISTRY_SERVER_PASSWORD" { | ||
webAppSlot.AppSettings[*pair.Name] = *pair.Value | ||
} | ||
} | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
and again here
if metadata.ResourceData.HasChange("app_settings") || metadata.ResourceData.HasChange("site_config.0.health_check_eviction_time_in_min") || metadata.ResourceData.HasChange("site_config.0.application_stack") { | ||
if siteConfigAppSetting := existing.SiteConfig.AppSettings; siteConfigAppSetting != nil && len(*siteConfigAppSetting) > 0 { | ||
if state.AppSettings == nil { | ||
state.AppSettings = make(map[string]string) | ||
} | ||
for _, pair := range *siteConfigAppSetting { | ||
if pair.Name == nil || pair.Value == nil { | ||
continue | ||
} | ||
if *pair.Name == "DOCKER_REGISTRY_SERVER_URL" || | ||
*pair.Name == "DOCKER_REGISTRY_SERVER_USERNAME" || | ||
*pair.Name == "DOCKER_REGISTRY_SERVER_PASSWORD" { | ||
state.AppSettings[*pair.Name] = *pair.Value | ||
} | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
and here
updated the comment in thread~ |
Are we in a position to merge this PR @jackofallops ? We are waiting for this fix |
Will it be possible to implement the changes suggested by jackofallops and get this merged? Docker based app services are pretty much broken for us at the moment due to this (after we upgraded to azurerm_linux_web_app from azure_app_service). |
We're in the same position as well, this bug is causing production issues as it keeps removing the DOCKER_* environment variables and this means it won't pull down the latest docker containers. |
My current work around look like this:
The 3 app settings are detected as changes on every plan+apply, which is very annoying, but it does work. When I need to initialize an environment from scratch, I have to run Terraform 3(!?) times, before the app settings stabilize. Quite inconvenient, but at least it works. |
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. |
Fixes
app_setting
exists in two places, one is undersite_config
while the other is undersite
, current, when user sets the docker related settings insite_config
such asdocker_registry_url
,docker_registry_username
anddocker_registry_password
, these settings are not being updated correctly inapp_setting
under Site. Theapp_setting
undersite_config
is not taking any effects...fix #22379
fix #22436
fix #22435
fix #22548