Skip to content
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

Add tenant for matching assigned chargeback rate #9005

Merged
merged 2 commits into from May 31, 2016

Conversation

lpichler
Copy link
Contributor

@lpichler lpichler commented May 27, 2016

https://bugzilla.redhat.com/show_bug.cgi?id=1337657

we are not considering current tenant when we want to determine assigned rate,
so

I am making suggestion for you @aljesusg, what do you think ?

cc @gtanzillo

@lpichler
Copy link
Contributor Author

@miq-bot add-label wip

@miq-bot miq-bot added the wip label May 27, 2016
@lpichler lpichler force-pushed the consider_tenant_to_chargeback branch from 50f0b26 to 963065b Compare May 27, 2016 09:14
@lpichler
Copy link
Contributor Author

@miq-bot add-label blocker

@aljesusg
Copy link
Member

@lpichler Why we should add the current tenant of user?

@lpichler
Copy link
Contributor Author

@aljesusg

  1. we have assigned certain rate for certain tenant as you did.
  2. then when we are generating chargeback report we need to determine which rate should be used -> and it is according to current tenant.

and selection is here:
https://github.com/ManageIQ/manageiq/blob/master/app/models/mixins/assignment_mixin.rb#L155

alist are assigments and we need to select the one and I think that it should be according current_tenant

Maybe we should think we what we will do if for the current tenant there is no such assigment

Does it make sense to you ?

@aljesusg
Copy link
Member

Yeah you're right :) . Thanks @lpichler

@lpichler
Copy link
Contributor Author

I realized another thing. @aljesusg or maybe it should not be a current user.
because who is the current user when reporting workers are running ? and probably does not make sense because existing code deriving it from metric_rollup table (variable perf) here
https://github.com/ManageIQ/manageiq/blob/master/app/models/chargeback.rb#L79

so I think that we should determine tenant for somehow from metric rollup records (perf)
MetricRollup doesn't direclty belongs to tenant but MetricRollup does have
resource (perf.resource) what is for example provider, host ... and this recause has tenant

So my other proposal is to use perf.resource.tenant

parents = [perf.parent_host, perf.parent_ems_cluster, perf.parent_storage, perf.parent_ems, @enterprise, perf.resource.tenant].compact

@gtanzillo What do you think about using perf.resource.tenant for determing rates ?

It seems ok to me because there is basically the same thing
https://github.com/ManageIQ/manageiq/blob/master/app/models/mixins/assignment_mixin.rb#L110
but we are using options[:parents] instead of ASSIGNMENT_PARENT_ASSOCIATIONS so we should add it to parents

but drawback can be perfomance, but logically it sounds good to me.

Thanks!

@gtanzillo
Copy link
Member

@lpichler @aljesusg Yes, I think it should take the rates from the tenant that owns the resource.

@lpichler lpichler force-pushed the consider_tenant_to_chargeback branch from 963065b to 46a709c Compare May 31, 2016 09:10
@lpichler lpichler changed the title [WIP] Add current tenant for matching assigned chargeback rate Add tenant for matching assigned chargeback rate May 31, 2016
@lpichler lpichler force-pushed the consider_tenant_to_chargeback branch from 46a709c to 75b08e3 Compare May 31, 2016 10:53
@lpichler
Copy link
Contributor Author

@miq-bot remove-label wip

@miq-bot miq-bot removed the wip label May 31, 2016
@lpichler
Copy link
Contributor Author

I added resource's tenant to parents with spec.

@aljesusg @gtanzillo please review

@miq-bot
Copy link
Member

miq-bot commented May 31, 2016

Checked commits lpichler/manageiq@3ca68f6~...75b08e3 with ruby 2.2.4, rubocop 0.37.2, and haml-lint 0.16.1
3 files checked, 0 offenses detected
Everything looks good. ⭐

@gtanzillo
Copy link
Member

👍 Looks good!

@gtanzillo gtanzillo added this to the Sprint 41 Ending May 30, 2016 milestone May 31, 2016
@gtanzillo gtanzillo merged commit ccca15a into ManageIQ:master May 31, 2016
chessbyte pushed a commit that referenced this pull request May 31, 2016
Add tenant for matching assigned chargeback rate
(cherry picked from commit ccca15a)
@lpichler lpichler deleted the consider_tenant_to_chargeback branch October 2, 2016 17:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants