fix: serialize concurrent property updates
Concurrent commands for the same app could each read a setting, change it, and write it back, so all of them exited successfully while silently dropping changes made by the others. Updates to app settings are now serialized so every change is kept, and readers never see a partially written value.
This commit is contained in:
42 files changed
+1698
-642
No files matched your search
@@ -160,11 +160,21 @@ func TriggerPostCertsRemove(appName string) error {
|
||||
return err
|
||||
}
|
||||
|
||||
return removePortMaps(appName, filterAppPortMaps(appName, "https", 443))
|
||||
return common.PropertyLock("ports", appName, func(p *common.LockedProperties) error {
|
||||
return removePortMapsWithLock(p, appName, filterAppPortMaps(appName, "https", 443))
|
||||
})
|
||||
}
|
||||
|
||||
// TriggerPostCertsUpdate sets port properties after SSL cert is added
|
||||
func TriggerPostCertsUpdate(appName string) error {
|
||||
return common.PropertyLock("ports", appName, func(p *common.LockedProperties) error {
|
||||
return postCertsUpdateWithLock(p, appName)
|
||||
})
|
||||
}
|
||||
|
||||
// postCertsUpdateWithLock adds https:443 port maps mirroring the app's http:80
|
||||
// port maps. The caller must hold the app's ports property lock.
|
||||
func postCertsUpdateWithLock(p *common.LockedProperties, appName string) error {
|
||||
port := common.PropertyGet("proxy", appName, "proxy-port")
|
||||
sslPort := common.PropertyGet("proxy", appName, "proxy-ssl-port")
|
||||
portMaps := getPortMaps(appName)
|
||||
@@ -201,7 +211,7 @@ func TriggerPostCertsUpdate(appName string) error {
|
||||
})
|
||||
}
|
||||
|
||||
if err := addPortMaps(appName, toAdd); err != nil {
|
||||
if err := addPortMapsWithLock(p, appName, toAdd); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user