Refactor #18176

Replace call to private clear_association_cache in Subnet#known_ips

Added by Dominic Cleal about 1 year ago. Updated about 1 year ago.

Status:Closed
Priority:Low
Assigned To:Dominic Cleal
Category:Rails
Target version:-
Difficulty: Bugzilla link:
Found in release: Pull request:https://github.com/theforeman/foreman/pull/4212
Story points-
Velocity based estimate-
Release1.15.0Release relationshipAuto

Description

The method clear_association_cache on models has been made private in Rails 5.0, it should be replaced where it's used in Subnet#known_ips:

NoMethodError: private method `clear_association_cache' called for #<Subnet::Ipv4:0x0000000b9d15d8>
Did you mean? clear_transaction_record_state
app/models/subnet.rb:190:in `known_ips'
app/services/ipam/db.rb:11:in `block in suggest_ip'
app/services/ipam/db.rb:9:in `suggest_ip'
test/unit/nic_test.rb:220:in `block (2 levels) in <class:NicTest>' (NoMethodError)
activemodel-5.0.0/lib/active_model/attribute_methods.rb:430

The method was public, but undocumented - for use only by Rails. It is now private (https://github.com/rails/rails/commit/9d56958).

The purpose appears to be to ensure known_ips always returns up to date lists of IPs when used for IPAM. e.g. if an interface is created with a given subnet and allocated an IP, a second interface created with the same subnet object won't be allocated the same IP.

Associated revisions

Revision 6a3b4abc
Added by Dominic Cleal about 1 year ago

fixes #18176 - replace clear_association_cache with reload

Reload is still necessary in Rails 5 as interfaces association will be
cached. The BMC test change is necessary to reload smart proxies
associated to the subnet after their features were altered - previously
clearing the entire subnet cache from `known_ips` also removed cached
smart proxies with outdated feature lists.

History

#1 Updated by The Foreman Bot about 1 year ago

  • Status changed from Assigned to Ready For Testing
  • Pull request https://github.com/theforeman/foreman/pull/4212 added

#2 Updated by Dominic Cleal about 1 year ago

  • Status changed from Ready For Testing to Closed
  • % Done changed from 0 to 100

#3 Updated by Dominic Cleal about 1 year ago

  • Release set to 1.15.0

Also available in: Atom PDF