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
Proxy config affecting change events #1244
Conversation
d044c8c
to
2390376
Compare
1ecfa29
to
9fc9a4d
Compare
041236e
to
da87374
Compare
Codecov Report
@@ Coverage Diff @@
## master #1244 +/- ##
========================================
- Coverage 93.1% 92.1% -1%
========================================
Files 2487 2413 -74
Lines 82372 79114 -3258
========================================
- Hits 76693 72870 -3823
- Misses 5679 6244 +565
Continue to review full report at Codecov.
|
|
||
def issue_proxy_affecting_change_events | ||
changes_attributes = previous_changes.keys | ||
return if changes_attributes.include?('created_at') |
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.
return if changes_attributes.include?('created_at') | |
return if created_at_changed? || (changes_attributes & PROXY_CONFIG_AFFECTING_ATTRIBUTES).empty? |
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.
No, it's not changed_attributes
, it's changes_attributes
, a variable defined in the line before.
da87374
to
27f544b
Compare
alias affecting_change_history find_or_create_proxy_config_affecting_change | ||
private :find_or_create_proxy_config_affecting_change | ||
|
||
def pending_affecting_changes? |
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.
Using this method (probably in the view) creates records right?
If yes, can we avoid that somehow?
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.
Well, if we have a proxy config, then we can also have an affecting change history I think. It also saves us from having to migrate data.
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.
fair enough
27f544b
to
8bb65a0
Compare
schema for psql and oracle
8bb65a0
to
bf69759
Compare
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.
Still needs the schema for Oracle and PostgreSQL though
|
||
def issue_proxy_affecting_change_events | ||
changes_attributes = previous_changes.keys | ||
return if changes_attributes.include?('created_at') || (changes_attributes & PROXY_CONFIG_AFFECTING_ATTRIBUTES).empty? |
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.
So you can use previously_changed?
https://github.com/3scale/porta/blob/d21f8d5e7a6dc740db6652e0604dcf0b639edb52/lib/previously_changed.rb
after_commit :issue_proxy_affecting_change_events, on: :update | ||
|
||
def issue_proxy_affecting_change_events | ||
changes_attributes = previous_changes.keys |
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.
So you can use previously_changed?
https://github.com/3scale/porta/blob/d21f8d5e7a6dc740db6652e0604dcf0b639edb52/lib/previously_changed.rb
Which will be introduced in rails 5.0
bfceb47
to
bf69759
Compare
What this PR does / why we need it:
It defines a new event to be issued whenever an object that is part of a proxy config changes (or gets created, or destroyed). This event will asynchronously touch a tracking record in a separate table, also introduced, that holds a 1-1 relationship with proxy.
Which issue(s) this PR fixes
This will make possible for the UI to highlight for the user a potential outdated proxy config, thus being relevant to #1235.
Closes THREESCALE-3555
TODOs
after_commit
, for each proxy potentially affected)ProxyRule
(Metric
deletion will kickProxyRule
deletion, so already covered)Policy
Proxy
(Maybe only a few attributes –policies_config
)GatewayConfiguration
Special notes for your reviewer
Not sure if we should issue one event per proxy (passing proxy and affecting object) or just one event per change, passing only the affecting object and let the creation of the event to handle the logics of triggering one background job per proxy. In the latter case, the event would have to be aware of the different types of affecting objects (so it can get to the proxies).
To sum up (very roughly exemplifying):
Option A
Option B
Update: going with Option B.
I won't tag this as APIAP-only because I think this can be used for non-APIAP accounts as well.