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

Container SSA: warn if no smartproxy/state role #273

Merged

Conversation

enoodle
Copy link

@enoodle enoodle commented Jan 30, 2017

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.

no_smart_proxy_warning

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

@enoodle
Copy link
Author

enoodle commented Jan 30, 2017

@moolitayer @zgalor Please take a look

@enoodle enoodle force-pushed the no_smartproxy_warning_container_ssa branch from 9ef0e2b to fcc5aa0 Compare January 30, 2017 11:23
@zgalor
Copy link
Contributor

zgalor commented Jan 30, 2017

👍 LGTM

@gshefer
Copy link

gshefer commented Jan 30, 2017

Excellent addition!, I'll add test case for the integration tests once merged.

@enoodle enoodle force-pushed the no_smartproxy_warning_container_ssa branch from fcc5aa0 to b05fbfc Compare January 30, 2017 11:48
@enoodle
Copy link
Author

enoodle commented Jan 30, 2017

@simon3z

@simon3z
Copy link
Contributor

simon3z commented Jan 30, 2017

@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
@miq-bot add_label providers/containers

@miq-bot
Copy link
Member

miq-bot commented Jan 30, 2017

@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) }

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 ?

Copy link
Author

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.

Copy link
Member

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.

Copy link
Member

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.

Copy link
Author

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)

Choose a reason for hiding this comment

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

s/enables/enabled/

Copy link
Author

Choose a reason for hiding this comment

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

👍

Copy link

@moolitayer moolitayer left a 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.

@moolitayer
Copy link

And I completely agree we need something against this scenario which keeps happening 👍

@enoodle enoodle force-pushed the no_smartproxy_warning_container_ssa branch from b05fbfc to 8dd8d8a Compare January 30, 2017 16:20
@simon3z
Copy link
Contributor

simon3z commented Feb 17, 2017

@miq-bot assign roliveri

@miq-bot
Copy link
Member

miq-bot commented Feb 17, 2017

@simon3z Cannot apply the following label because they are not recognized: providers/containers

@miq-bot
Copy link
Member

miq-bot commented Feb 17, 2017

@simon3z roliveri is an invalid assignee, ignoring...

@enoodle enoodle force-pushed the no_smartproxy_warning_container_ssa branch from 8dd8d8a to d23792b Compare February 22, 2017 14:34
@dclarizio dclarizio assigned dclarizio and unassigned enoodle Feb 22, 2017
@dclarizio
Copy link

@h-kataria can you take a quick look please? This looks like a great addition.

@dclarizio
Copy link

@enoodle I like this . . . failing test right now though.

@h-kataria
Copy link
Contributor

@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.

@enoodle enoodle force-pushed the no_smartproxy_warning_container_ssa branch from d23792b to db01e3a Compare February 22, 2017 18:19
@enoodle enoodle changed the title Container SSA: warn if no smartproxy/state role [WIP] Container SSA: warn if no smartproxy/state role Feb 22, 2017
@enoodle
Copy link
Author

enoodle commented Feb 22, 2017

@h-kataria ok, will do. I just pushed something to make the test green but I will rework this logic for the button type.

@miq-bot miq-bot added the wip label Feb 22, 2017
@h-kataria
Copy link
Contributor

@enoodle does this disable SSA button on list view as well?

@enoodle
Copy link
Author

enoodle commented Feb 27, 2017

@h-kataria I changed the button for container_images_center.rb too, but apparently if the only button in a selection is disabled it won't show this button, so the whole "configuration" button is missing if the role is not set.

@h-kataria
Copy link
Contributor

@enoodle does this PR address issue mentioned here https://bugzilla.redhat.com/show_bug.cgi?id=1342790

@enoodle
Copy link
Author

enoodle commented Feb 28, 2017

@h-kataria yes, I was not aware or this BZ when I created this PR.

@h-kataria
Copy link
Contributor

@enoodle can you add a link to the BZ in your commit comment.

@enoodle enoodle force-pushed the no_smartproxy_warning_container_ssa branch from e951b67 to 33dfb5b Compare February 28, 2017 16:16
@enoodle
Copy link
Author

enoodle commented Feb 28, 2017

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"
Copy link
Contributor

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?

Copy link
Author

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) }
Copy link
Contributor

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?

Copy link
Author

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
Copy link
Contributor

Choose a reason for hiding this comment

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

@enoodle @roliveri should this constant live somewhere in the SmartState subsystem?

Copy link
Author

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?

Copy link
Contributor

Choose a reason for hiding this comment

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

@enoodle who are you asking? I assume you asked @roliveri (although I am sure you're more than qualified to look at the code and find a relevant place on your own).

Copy link
Author

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.

[1] https://github.com/ManageIQ/manageiq/blob/master/app/models/miq_server/server_smart_proxy.rb#L3

@simon3z
Copy link
Contributor

simon3z commented Mar 1, 2017

Few comments on the PR but overall LGTM 👍
@dclarizio @h-kataria can you review/merge?

@enoodle enoodle force-pushed the no_smartproxy_warning_container_ssa branch from 33dfb5b to 713e0ae Compare March 1, 2017 12:32
@h-kataria
Copy link
Contributor

@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.

@enoodle enoodle changed the title Container SSA: warn if no smartproxy/state role [WIP] Container SSA: warn if no smartproxy/state role Mar 2, 2017
@enoodle
Copy link
Author

enoodle commented Mar 2, 2017

I am waiting on ManageIQ/manageiq#14127 to address the constant for the smart roles.

@miq-bot miq-bot added the wip label Mar 2, 2017
@enoodle enoodle force-pushed the no_smartproxy_warning_container_ssa branch from 713e0ae to 137b6f1 Compare March 2, 2017 12:48
@enoodle enoodle changed the title [WIP] Container SSA: warn if no smartproxy/state role Container SSA: warn if no smartproxy/state role Mar 5, 2017
@enoodle enoodle closed this Mar 5, 2017
@enoodle enoodle reopened this Mar 5, 2017
@miq-bot miq-bot removed the wip label Mar 5, 2017
@enoodle enoodle force-pushed the no_smartproxy_warning_container_ssa branch from 137b6f1 to 9436239 Compare March 5, 2017 13:08
@enoodle enoodle force-pushed the no_smartproxy_warning_container_ssa branch from 9436239 to afa1657 Compare March 5, 2017 13:36
@miq-bot
Copy link
Member

miq-bot commented Mar 5, 2017

Checked commits enoodle/manageiq-ui-classic@40e6071~...afa1657 with ruby 2.2.6, rubocop 0.47.1, and haml-lint 0.20.0
7 files checked, 4 offenses detected

spec/helpers/application_helper/buttons/smart_state_scan.rb

spec/helpers/application_helper/buttons/vm_instance_scan_spec.rb

@enoodle
Copy link
Author

enoodle commented Mar 5, 2017

@simon3z, @dclarizio PTAL, I fixed @simon3z 's last comments about the smart proxy roles constant location.

@h-kataria
Copy link
Contributor

looks good.

@h-kataria h-kataria added this to the Sprint 56 Ending Mar 13, 2017 milestone Mar 6, 2017
@h-kataria h-kataria merged commit 99fc51b into ManageIQ:master Mar 6, 2017
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.

10 participants