-
Notifications
You must be signed in to change notification settings - Fork 897
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 check for invalid roles in server_role_names= #20731
Add check for invalid roles in server_role_names= #20731
Conversation
FWIW, I noticed this because I was trying to run_single_worker locally passing |
c85d1ac
to
5c54d11
Compare
I also found that miq_alert_spec was actually silently not setting the notifier role as it was specified. Since ServerRole was not seeded, then calling |
a9129ff
to
1024c1a
Compare
Updated to just fix the only caller that used |
@miq-bot cross_repo_tests manageiq-api, manageiq-ui-classic, manageiq-providers-amazon |
From Pull Request: ManageIQ/manageiq#20731
Checked commit Fryguy@1024c1a with ruby 2.6.3, rubocop 0.82.0, haml-lint 0.35.0, and yamllint spec/models/miq_server/role_management_spec.rb
|
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.
LGTM, I only have concern about the change in behavior and if we accidentally tried to assigned undefined roles in the past, it would silently be ignored. Now, it raises. It makes sense but I'm not sure if this is completely covered by tests.
So, the reason it ignored it previously is because in tests things were not seeded. So when it tried to set the role, it just ignored the "missing" roles. In a real production run, the server roles would be seeded. The only way it could fail now is if there is a typo, which seems unlikely because then it never would have worked. |
Merging, I agree, production code shouldn't accept undefined roles and it's more likely it's test code with not fully seeded roles that was hitting this so it's very unlikely to cause a production problem. |
@Fryguy is this kasparov/yes? |
This fixes an issue where invalid roles names are silently ignored. I think it was expected that
assign_role
call a little below would callServerRole.to_role
and raise this exception, however theServerRole.where
just before it will ignore the invalid roles on querying, and thus assign_role can never be called with a bad role name.I was thinking of fixing this to call .to_role, but I realize that method is a wasted abstraction and I plan to remove it in a follow up PR.
@jrafanie Please review