-
Notifications
You must be signed in to change notification settings - Fork 356
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
Container SSA: warn if no smartproxy/state role #273
Container SSA: warn if no smartproxy/state role #273
Conversation
@moolitayer @zgalor Please take a look |
9ef0e2b
to
fcc5aa0
Compare
👍 LGTM |
Excellent addition!, I'll add test case for the integration tests once merged. |
fcc5aa0
to
b05fbfc
Compare
@enoodle I think you'll have to sync with @h-kataria @dclarizio and @roliveri to have this on all the SSA pages. @miq-bot assign enoodle |
@simon3z enoodle is an invalid assignee, ignoring... |
@@ -210,6 +211,14 @@ def process_check_compliance(model, ids) | |||
end | |||
end | |||
|
|||
def check_smart_roles | |||
%w(SmartProxy SmartState).each do |role| | |||
unless MiqServer.all.any? { |s| s.has_active_role?(role.downcase) } |
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.
I'm pretty sure we want to only iterate only the servers in our zone. @gmcculloug ?
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.
I could add && s.in_active_region?
. waiting on @gmcculloug to ack this.
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.
Checking the zone sounds like the right way to go, but I have not been involved much with SSA and will defer to @roliveri.
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.
@gmcculloug I think that's right. I don't recall, I believe we check for available proxies in zone.
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.
@roliveri I am sorry for resurrecting this from the dead ;-)
I was trying to find out but couldn't actually find where we are making this decision. I think it might be in [1] but I am not sure because it seems too general of a function name.
I am asking because I want to answer to BZ [2] with a definitive answer.
I think what they need is to allow Jobs created in the UI zone that have no active roles to be moved to other zones, is that possible?
[1] https://github.com/ManageIQ/manageiq/blob/master/app/models/job_proxy_dispatcher.rb#L174
[2] https://bugzilla.redhat.com/show_bug.cgi?id=1459702
def check_smart_roles | ||
%w(SmartProxy SmartState).each do |role| | ||
unless MiqServer.all.any? { |s| s.has_active_role?(role.downcase) } | ||
add_flash("There is no server with the #{role} role enables", :warning) |
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.
s/enables/enabled/
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.
👍
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.
Nice idea, I like the general direction.
And I completely agree we need something against this scenario which keeps happening 👍 |
b05fbfc
to
8dd8d8a
Compare
@miq-bot assign roliveri |
@simon3z Cannot apply the following label because they are not recognized: providers/containers |
@simon3z roliveri is an invalid assignee, ignoring... |
8dd8d8a
to
d23792b
Compare
@h-kataria can you take a quick look please? This looks like a great addition. |
@enoodle I like this . . . failing test right now though. |
@enoodle in my opinion we should not let user press SSA button if SmartProxy role is not enabled. Iit would be better to disable SSA button on list view & summary screen with a hover text that "There is no server with SmaprtProxy role enabled". You can move the whole logic to check for the enabled role in https://github.com/ManageIQ/manageiq-ui-classic/blob/master/app/helpers/application_helper/button/vm_instance_template_scan.rb or to an appropriate button helper class. |
d23792b
to
db01e3a
Compare
@h-kataria ok, will do. I just pushed something to make the test green but I will rework this logic for the button type. |
@enoodle does this disable SSA button on list view as well? |
@h-kataria I changed the button for |
@enoodle does this PR address issue mentioned here https://bugzilla.redhat.com/show_bug.cgi?id=1342790 |
@h-kataria yes, I was not aware or this BZ when I created this PR. |
@enoodle can you add a link to the BZ in your commit comment. |
e951b67
to
33dfb5b
Compare
rebased on master to try and fix Travis problems. |
my_zone = MiqServer.my_server.my_zone | ||
SMART_ROLES.each do |role| | ||
unless MiqServer.all.any? { |s| s.has_active_role?(role.downcase) && (s.my_zone == my_zone) } | ||
@error_message = "There is no server with the #{role} role enabled" |
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.
@enoodle @dclarizio does this need i18n?
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.
I believe so, I will fix it.
def check_smart_roles | ||
my_zone = MiqServer.my_server.my_zone | ||
SMART_ROLES.each do |role| | ||
unless MiqServer.all.any? { |s| s.has_active_role?(role.downcase) && (s.my_zone == my_zone) } |
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.
@enoodle if this is the only place where you're using SMART_ROLES
why don't you keep them downcase
'd in the constant?
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.
I also use it in the message below (line 10).
class ApplicationHelper::Button::SmartStateScan < ApplicationHelper::Button::Basic | ||
needs :@record | ||
|
||
SMART_ROLES = %w(SmartProxy SmartState).freeze |
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.
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.
We are using this button for the VM instances too so this should be in a general location. Is there a central SSA class?
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.
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.
The only place I could think of is in MiqServer::ServerSmartProxy
but I am also not sure about it.
Few comments on the PR but overall LGTM 👍 |
33dfb5b
to
713e0ae
Compare
@simon3z @dclarizio overall changes look good to me, not sure if @enoodle is looking into addressing comments from @simon3z to move the constant to somewhere else. |
I am waiting on ManageIQ/manageiq#14127 to address the constant for the smart roles. |
713e0ae
to
137b6f1
Compare
137b6f1
to
9436239
Compare
9436239
to
afa1657
Compare
Checked commits enoodle/manageiq-ui-classic@40e6071~...afa1657 with ruby 2.2.6, rubocop 0.47.1, and haml-lint 0.20.0 spec/helpers/application_helper/buttons/smart_state_scan.rb
spec/helpers/application_helper/buttons/vm_instance_scan_spec.rb
|
@simon3z, @dclarizio PTAL, I fixed @simon3z 's last comments about the smart proxy roles constant location. |
looks good. |
As it is very common to forget to set the SmartProxy role for SmartState Analysis for Container Images I got feedback that a warning if the role is not set is needed. This will prevent the initiation of the job, by disabling the SSA button and will show the user a message with the problem.
BZ: https://bugzilla.redhat.com/show_bug.cgi?id=1342790