-
Notifications
You must be signed in to change notification settings - Fork 899
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 logic for checking if a middleware server is immutable #14565
Conversation
c86224b
to
2db2b8e
Compare
@@ -33,6 +37,21 @@ def evaluate_alert(alert_id, event) | |||
end | |||
|
|||
def in_domain? | |||
!middleware_server_group.nil? | |||
middleware_server_group |
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 finding it hard to follow (maybe it's just me :)) - how does this return boolean?
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.
nil == false
, and everything else besides false
is truthy. Predicate methods do not need to return true/false explicitly, just a truthy and a falsey value. This is common pratice in ruby.
app/models/middleware_server.rb
Outdated
|
||
def immutable? | ||
hawkular? || | ||
['Immutable', 'Is Immutable'].any? do |key| |
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.
where does the 'Is Immutable' property come from?
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.
Wildfly/EAP agents present this key, while Hawkular servers use the 'Immutable' key.
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.
please add it as a comment in code for easier understanding by anyone who reads it
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.
done
2db2b8e
to
35a2146
Compare
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 learned a few things too ;)
Just need to check on other comment with: 'Immutable' and 'Is Immutable' but its covered either way now so that would just be an optimization.
app/models/middleware_server.rb
Outdated
# 'Immutable' key is used in Hawkular servers, while EAP/WildFly servers | ||
# use 'Is Immutable' as the key on properties. | ||
hawkular? || | ||
['Immutable', 'Is Immutable'].any? do |key| |
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 will confirm that we need to check for both: 'Immutable' and 'Is Immutable' . It has a bad smell (not from anything you have coded but just in general design consistency).
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.
@mtho11 is this PR pending your check regarding the different Immutable variables?
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.
Ok, confirmed second property is not necessary. I didn't think that looked right. 'Is Immutable' is an older artefact from a hawkfly build.
Hi, I've been added to this thread but not actually involved with development. |
35a2146
to
3b91e5d
Compare
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.
After fixes LGTM!
@abonas seems like it is mergeable, who should I assign? |
3b91e5d
to
9abda96
Compare
@cfcosta the tests looks red, please have a look |
@abonas the failure is related to a migration, and there's none on this PR :( |
hmmm... please rekick the tests then |
@mtho11 if you're good with this PR, please reassign to miq core for merging |
@miq-bot add_label fine/yes |
@bronaghs @blomquisg will be nice to have this merged before repo split |
@abonas - this PR states that it should be merged at the same time as ManageIQ/manageiq-ui-classic#839 which appears not be ready for merging. |
@bronaghs it is not dependant though. This one could be merged without ManageIQ/manageiq-ui-classic#839, but not the other way around. |
@cfcosta looks like this needs to be moved to new provider repo: https://github.com/ManageIQ/manageiq-providers-hawkular and new PR opened up there. |
app/models/middleware_server.rb
Outdated
end | ||
|
||
def immutable? | ||
hawkular? || properties['Immutable'] == 'true' |
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.
This should really be implemented by the subclass instead of checking hawkular?
here no? Seeing if hawkular?
on a base model feels like it is breaking the pluggability (/cc @durandom )
Why not have immutable?
return false
on the base model and have ManageIQ::Providers::Hawkular::MiddlewareManager::MiddlewareServer#immutable?
return properties['Immutable'] == 'true'
9abda96
to
cbcf23c
Compare
cbcf23c
to
4a43f7a
Compare
app/models/middleware_deployment.rb
Outdated
@@ -3,4 +3,6 @@ class MiddlewareDeployment < ApplicationRecord | |||
belongs_to :middleware_server, :foreign_key => "server_id" | |||
belongs_to :middleware_server_group, :foreign_key => "server_group_id", :optional => true | |||
acts_as_miq_taggable | |||
|
|||
delegate :hawkular?, :mutable?, :in_domain?, :to => :middleware_server |
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.
where is hawkular?
used?
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.
Fixed, thanks!
This is a companion to another commit on manageiq-ui-classic, which moves the logic to check if a server is mutable or not from an action on the UI to the MiddlewareServer itself.
4a43f7a
to
81e2d38
Compare
Checked commit cfcosta@81e2d38 with ruby 2.2.6, rubocop 0.47.1, and haml-lint 0.20.0 |
# | ||
# Just a convenience method over #immutable. | ||
def mutable? | ||
!immutable? |
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.
Not a big fan of this since we already have if
/unless
to avoid negating a conditional but I won't hold this up because of it
Add logic for checking if a middleware server is immutable (cherry picked from commit 3619952)
Fine backport details:
|
This is a companion to another commit on manageiq-ui-classic, which
moves the logic to check if a server is mutable or not from an action on
the UI to the MiddlewareServer itself. It is a refactor of manageiq-ui-classic#636, and should be merged together with ManageIQ/manageiq-ui-classic#839