Bug #6240
open
When a feature is removed from a proxy, the relevant models still keep the association
Added by Stephen Benjamin over 10 years ago.
Updated about 10 years ago.
Description
For example, when the DNS feature is removed from the proxy, the association on the domain stays in place in the database, however a user can't view it in the UI. Foreman will also still try to talk to the DNS proxy, even though the proxy doesn't support the feature anymore.
To reproduce:
1. Create a new DNS proxy
2. Assign the proxy to a Domain
3. Remove the DNS feature from the proxy
4. Create a new host in that domain
- Related to Bug #6241: Models allow invalid proxy associations added
We can't really fail when refreshing the features of a proxy, we just have to take what the proxy offers, so I see two ways to fix this:
(1) When a feature is removed, go to the models and disassociate the proxy.
(2) In the select for the proxy, find all proxies with Feature AND include the current proxy id even if it doesn't have that feature, so at least we're not hiding the association anymore. So like this for DNS proxy on Domains:
SmartProxy.joins(:features).where("features.name = ? OR smart_proxies.id = ?", "DNS", @domain.dns_id)
Now at this point if the user tries to save the model with the invalid proxy, then we can fail by saying that the selected proxy doesn't have that feature anymore (add validations as per #6241).
Does that make sense?
I'd err towards disassociating it, as it'll probably be clearer without needing to re-save every related model.
- Bugzilla link set to 1170097
Also available in: Atom
PDF