Project

General

Profile

Bug #6240

When a feature is removed from a proxy, the relevant models still keep the association

Added by Stephen Benjamin over 6 years ago. Updated almost 6 years ago.

Status:
New
Priority:
Normal
Assignee:
-
Category:
Smart Proxy
Target version:
-
Difficulty:
Triaged:
No
Bugzilla link:
Pull request:
Fixed in Releases:
Found in Releases:

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 issues

Related to Foreman - Bug #6241: Models allow invalid proxy associationsClosed2014-06-16

History

#1 Updated by Stephen Benjamin over 6 years ago

  • Related to Bug #6241: Models allow invalid proxy associations added

#2 Updated by Stephen Benjamin over 6 years ago

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?

#3 Updated by Dominic Cleal over 6 years ago

I'd err towards disassociating it, as it'll probably be clearer without needing to re-save every related model.

#4 Updated by Stephen Benjamin almost 6 years ago

  • Bugzilla link set to 1170097

Also available in: Atom PDF