salt icon indicating copy to clipboard operation
salt copied to clipboard

states.keystone fails to create user-roles for more than 1 tenant/user (or remove them)

Open devweasel opened this issue 11 years ago • 9 comments

This is probably related to/a duplicate of the already closed issue #8912. Sorry for duplicating this, but apparently my initial comment on the closed issue got overlooked...

The above mentioned issue is still present in the current develop branch. To emphasize this using the example given by smithjm:

- roles:
  - service_tenant:
    - admin_role
    - user_role
  - admin_tenant:
    - admin_role

The roles are correctly set for service_tenant, but the admin_tenant gets completely ignored.

I suspect that there is something wrong with the tenant loop in the code (without having much programming knowledge that is, so i might be completely and utterly wrong too...). Line 176 states:

for tenant_role in roles[0]:

The [0] looks to me like it's somehow disabling the loop altogether and only processing the first list element...

Furthermore, the state doesn't seem to support the removal of roles. If i modify the state (after applying the original one) to read:

- roles:
  - service_tenant:
    - admin_role
  - admin_tenant:
    - admin_role

The role user_role doesn't get removed in service_tenant (while the admin_tenant still gets completely ignored)...

devweasel avatar Feb 27 '15 11:02 devweasel

Thanks for filing this new report @devweasel. Sorry we missed your earlier comment! We can just use this one for now.

I am not particularly familiar with this state or module, but it looks like your initial observations of the problem are correct and the line your referenced would be the right place to start. We'd gladly accept a pull request addressing this issue if you feel inclined. If not, that's ok too and we can grab this one.

rallytime avatar Feb 27 '15 19:02 rallytime

Here you are @rallytime; Sorry this took so long, understanding the basics of Git and your "Contributing" documentation (and what the heck a "pull request" was) took a bit longer than expected ;-)

devweasel avatar Mar 04 '15 16:03 devweasel

@devweasel, let me know if you had any difficulty understanding the contributing documentation. I've recently revised it and there are some markup errors, but I am also interested if there's anything else a smart person who doesn't yet know git (and github with its own complexities) might have to say.

jfindlay avatar Mar 04 '15 18:03 jfindlay

@devweasel Not a problem at all! Thanks very much for the contribution, and welcome! It looks great. And like @jfindlay said, any feedback you have about contributing docs are certainly welcome and we are happy to answer any questions you have.

rallytime avatar Mar 04 '15 20:03 rallytime

@jfindlay, actually the "Contributing" documentation is really good and straightforward, the only real issue i had was with the branching section:

git fetch upstream
git checkout 2014.7
git rebase upstream/2014.7
git checkout -b fix-broken-thing

The second command blew up in my face with

error: pathspec '2014.7' did not match any file(s) known to git.

As a newbie to all of this, the above error-message doesn't really mean something to me. After reading up a bit more on the concepts of "origin" and "upstream" i came to the conclusion that i probably had to do the checkout on "origin/2014.7", which in turn told me that i now was in a "detached HEAD state". This didn't really sound correct either (and a bit confusing to be honest), but i "bravely" ignored that and everything went fine after that. So my difficulties were presumably mostly ignorance of Git...

Just out of curiosity, though: Wouldn't the command

git checkout -b fix-broken-thing upstream/2014.7

do the same thing? If so, i - personally - would think that this command would be a bit more intuitive, because i don't end up in a detached state and the command states what i really want to do, namely create a new branch "fix-broken-thing" to do something based on the work done in "upstream/2014.7"...

devweasel avatar Mar 05 '15 15:03 devweasel

@devweasel, thank you. I am not a git master myself, so I don't know why if the local branch (2014.7) doesn't exist yet (sometimes?) git does not automatically set its upstream to upstream/2014.7. I suspect this happens because there are two remote repos by this point, which will likely contain the same branches and git cannot a priori resolve which is going to be the upstream for that branch. I'll update the documentation to include instead your more robust suggestion.

jfindlay avatar Mar 05 '15 18:03 jfindlay

If I am reading what @devweasel was saying correctly, I think what is happening is the git checkout 2014.7 line is failing because the 2014.7 branch doesn't exist locally yet. The second line (if you don't already have a 2014.7 branch) should be git branch 2014.7 upstream/2014.7. Then you can do git checkout 2014.7.

rallytime avatar Mar 05 '15 18:03 rallytime

Since the original issue has been fixed, I am going to close this issue - thanks again @devweasel!

@jfindlay Should a new issue be opened about the contributing docs issue that I mentioned above, or has that been addressed?

rallytime avatar Mar 10 '15 04:03 rallytime

@rallytime, I have not yet fixed that. I worked on it a little on Monday, but ran out of time. I expect to get to it today. I'll be sure to mention you and @devweasel in the pull request so that you can review it.

jfindlay avatar Mar 10 '15 08:03 jfindlay