-
Notifications
You must be signed in to change notification settings - Fork 898
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
Keep container quota history by archiving #16722
Conversation
app/models/mixins/archived_mixin.rb
Outdated
@@ -16,6 +16,24 @@ def active? | |||
deleted_on.nil? | |||
end | |||
|
|||
module ClassMethods | |||
def were_active_at_time(time) |
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.
These were_active_at_time
and walk_history
don't belong in this PR, I'm just sketching what kind of history access we might want in the future...
I'll remove them when PR is ready (so brakeman travis failure on this will go away)
@zeari @yaacov @moolitayer This now seems to work in interactive testing, please review. |
fc8b192
to
9b25876
Compare
19c05a2
to
202a880
Compare
if attribute == "timestamp" | ||
type = model_class.type_for_attribute(attribute) | ||
type.cast(record_key(record, attribute)).utc.iso8601.to_s | ||
type.cast(value).utc.iso8601.to_s | ||
elsif %w(quota_desired quota_enforced quota_observed).include?(attribute) |
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.
ok, so this starts to look like I should refactor it :-) though a generic solution will be slower
also I am trying to experiment with just removing all of this comparing in ruby and just do things via upsert (so the comparing is done on PG side, which has it's own (fast) type casting)
UPDATE: what I describe here was split off to #17020.
I just pushed commit beggining of refactor I'm trying — add `@deserializable_keys` similar to `@serializable_keys`. What do you think of the direction?
I suspect anything serializable should be in deserialiazable set too, i.e. the 2 sets will be same, but I want isolated change for easier backporting (I know code here has already changed; I'll split this to separate PR).
But it's nagging me that such normalization would only happen at save time. I'm tempted to type.cast() at InventoryObject building time (or collection.push time) . Potential benefits:
P.S. I'm stuck on this too long, would like to chat/pair with you... |
Finally found a way to test this such that it fails if I don't normalize DB representation vs Ruby representation. I made parser emit instances of this:
well, that may be too wrong — if casting data from DB creates BigDecimal it may not match a BadDecimal instance (while in reality once you have BigDecimals from both sides, it's fine). But I'll try to write a core test involving some intentional mismatch like that... |
77e1543
to
9727b9b
Compare
@zeari @yaacov @agrare deps merged, please review this & ManageIQ/manageiq-providers-kubernetes#198 |
Checked commit cben@4c9aebb with ruby 2.3.3, rubocop 0.52.0, haml-lint 0.20.0, and yamllint 1.10.0 app/models/container_project.rb
app/models/container_quota.rb
app/models/container_quota_item.rb
app/models/ems_refresh/save_inventory_container.rb
app/models/manageiq/providers/container_manager.rb
|
@agrare @Fryguy Please review this and ManageIQ/manageiq-providers-kubernetes#198, we want these in next gaprindashvili-3(?) / 5.9.1 release. |
@cben how frequently do container quotas change? Are they something which are changed pretty infrequently? |
quota_desired & quota_enforced columns only change when an admin adds/changes/delete a quota — I'd discussed with @yaacov whether I should archive on quota_observed changes. We concluded this is still "more inventory than metric" in nature, would be nice to have history of it, and while it may increase archived size significantly, it should be acceptable (hand-waving, haven't tested at scale!). I'll do purging in separate PR. |
Keep container quota history by archiving (cherry picked from commit ffd2be0) https://bugzilla.redhat.com/show_bug.cgi?id=1559544
Gaprindashvili backport details:
|
Container projects have quotas (optionally scoped), and quota items for specific resources. Some users desire "chargeback by allocation" where the quota is what tenants pay for (whether they used it or not).
We're already collecting quotas, but we need to also retain full quota history — this PR implements this by (mis)using archiving.
See comments in models for design assumptions/choices.
https://bugzilla.redhat.com/show_bug.cgi?id=1504560
@miq-bot add-label enhancement, gaprindashvili/yes
Docs on quotas: https://kubernetes.io/docs/concepts/policy/resource-quotas/, https://docs.openshift.com/container-platform/3.9/admin_guide/quota.html