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

Fix ownership to work across multiple regions. #11992

Merged
merged 3 commits into from
Oct 19, 2016

Conversation

Fryguy
Copy link
Member

@Fryguy Fryguy commented Oct 17, 2016

OwnershipMixin#user_or_group_owned was not region aware, and now it is.

This is only for the user...I did not make it work for the group yet.

@carbonin @gtanzillo Please review. I have not added tests yet, or even verified the existing tests covered it, but it works via rails c.

@kbrock Please also review. I totally ripped off your code from the virtual_attribute :owned_by_current_user, and I'm wondering if there is a way to share the code so I am not duplicating it. I can't figure out how, since the virtual_attribute uses a block and build off of a t (is that an arel_table?), but the code I wrote is a regular scope.

@Fryguy Fryguy added this to the Sprint 48 Ending Oct 24, 2016 milestone Oct 17, 2016
OwnershipMixin#user_or_group_owned was not region aware, and now it is.
@carbonin
Copy link
Member

It's okay that this doesn't take groups into account. We don't replicate miq_groups yet, so don't worry about it.

I think we talked about it, but do we have a plan for the evm_owner belongs_to relationship? Or is that not important?

@Fryguy
Copy link
Member Author

Fryguy commented Oct 17, 2016

We decided it wasn't important at the moment. I don't want to change it because all of the virtual_attributes would be affected, and that is where @kbrock got the enormous performance savings.

Copy link
Member

@carbonin carbonin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good.

@gtanzillo gtanzillo added the wip label Oct 18, 2016
@gtanzillo gtanzillo changed the title Fix ownership to work across multiple regions. [WIP] Fix ownership to work across multiple regions. Oct 18, 2016
@gtanzillo
Copy link
Member

Marking as WIP until tests are added.

@kbrock
Copy link
Member

kbrock commented Oct 18, 2016

Would be nice if we had a single user table across all regions. Or if we were able to link all of the same user together.

I do wonder if having the same userid in multiple regions makes you the same user.

@gtanzillo gtanzillo changed the title [WIP] Fix ownership to work across multiple regions. Fix ownership to work across multiple regions. Oct 19, 2016
@gtanzillo gtanzillo added euwe/yes and removed wip labels Oct 19, 2016
@gtanzillo
Copy link
Member

@Fryguy I added some tests, as we discussed. Please review when you get a chance.

Copy link
Member

@carbonin carbonin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a few comments on the specs.

it "returns resource owned by user" do
my_region_number = ApplicationRecord.my_region_number
remote_region_number = my_region_number + 1
remote_id = ApplicationRecord.region_to_range(remote_region_number).first
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would put these three lines in a let(:remote_id) block to DRY this up.

remote_region_number = my_region_number + 1
remote_id = ApplicationRecord.region_to_range(remote_region_number).first

remote_owning_user = FactoryGirl.create :user, :id => remote_id, :userid => "user_owner", :miq_groups => FactoryGirl.create_list(:miq_group, 1)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You could also make the remote_owning_user a let then assign the groups in this spec as that is what has actually changed.

…e and updated to enable generically testing ownership of Vm, Service and ServiceTemplate objects
@gtanzillo
Copy link
Member

@carbonin Thanks for the feedback. I've made the changes you suggested.

@miq-bot
Copy link
Member

miq-bot commented Oct 19, 2016

Checked commits Fryguy/manageiq@9b897c3~...fd2a3da with ruby 2.2.5, rubocop 0.37.2, and haml-lint 0.16.1
2 files checked, 4 offenses detected

app/models/mixins/ownership_mixin.rb

spec/support/examples_group/shared_examples_for_ownership_mixin.rb

@carbonin
Copy link
Member

👍

@carbonin carbonin merged commit 76f78dc into ManageIQ:master Oct 19, 2016
@kbrock
Copy link
Member

kbrock commented Oct 19, 2016

yay

chessbyte pushed a commit that referenced this pull request Oct 21, 2016
Fix ownership to work across multiple regions.
(cherry picked from commit 76f78dc)
@chessbyte
Copy link
Member

Euwe Backport details:

$ git log -1
commit 9aa85b9777099729dc7be82920e169e603531af2
Author: Nick Carboni <ncarboni@redhat.com>
Date:   Wed Oct 19 17:57:20 2016 -0400

    Merge pull request #11992 from Fryguy/evm_owner_regionally

    Fix ownership to work across multiple regions.
    (cherry picked from commit 76f78dcad8d00f4d8e12239daf14b6373f431a5c)

@Fryguy Fryguy deleted the evm_owner_regionally branch October 21, 2016 16:52
NickLaMuro added a commit to NickLaMuro/manageiq that referenced this pull request Nov 3, 2016
Includes the updates from ManageIQ#11992 and also includes the
(minimal) necessary updates to allow it to work:  updating the arel for
the evm_owner_userid virtual_column, which was handled by
virtual_delegates in the newer releases.
chessbyte added a commit that referenced this pull request Nov 7, 2016
jrafanie added a commit to jrafanie/manageiq that referenced this pull request Dec 16, 2016
https://bugzilla.redhat.com/show_bug.cgi?id=1401912

Note, we were only downcasing the userids in the users table,
so a mixed case logged in userid would never match.

This would cause a logged in self service user with mixed case
userid to not see vms they own.

This was broken here:
9b897c3

As part of:
ManageIQ#11992

We're fixing much like we did with groups here:
ManageIQ#12114
jrafanie added a commit to jrafanie/manageiq that referenced this pull request Jan 16, 2017
https://bugzilla.redhat.com/show_bug.cgi?id=1401912

Note, we were only downcasing the userids in the users table,
so a mixed case logged in userid would never match.

This would cause a logged in self service user with mixed case
userid to not see vms they own.

This was broken here:
9b897c3

As part of:
ManageIQ#11992

We're fixing much like we did with groups here:
ManageIQ#12114
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

6 participants