-
Notifications
You must be signed in to change notification settings - Fork 987
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
Fixes #23536 - No errors when unattended=false #5687
Conversation
Issues: #23536 |
There were the following issues with the commit message:
If you don't have a ticket number, please create an issue in Redmine. More guidelines are available in Coding Standards or on the Foreman wiki. This message was auto-generated by Foreman's prprocessor |
There were the following issues with the commit message:
If you don't have a ticket number, please create an issue in Redmine. More guidelines are available in Coding Standards or on the Foreman wiki. This message was auto-generated by Foreman's prprocessor |
unattended=false
unattended=false
There were the following issues with the commit message:
If you don't have a ticket number, please create an issue in Redmine. More guidelines are available in Coding Standards or on the Foreman wiki. This message was auto-generated by Foreman's prprocessor |
Takes care of the issue for me. Could you please modify the commit message as the bot suggests? Test failures are unrelated. |
@ShimShtein @lzap since i think you're most familiar with orchestration code, does it make sense to include orchestration module when |
I think this is safe, but let's pause this for a moment and talk about removing this flag for once and forever: https://community.theforeman.org/t/rfc-remove-unattended-setting/10035 |
@lzap thanks, I agree we need to re-think about the unattended mode, |
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.
On second look, I think that safer approach is to simply use respond_to?
in valid_rebuild_only_values
and skip it when orchestration is not there.
I will let @iNecas comment on that, this is something from apipie and I don't exactly know what are these method lists used for.
This kind of change we can hardly cover with unit tests, we turn orchestration off for most of them (and orchestration has separate testing) @ohadlevy - only if we had end to end automated testing, that would do it.
As the backtrace shows, the methods are used from here foreman/config/initializers/apipie.rb Line 24 in d7c6774
I agree using |
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.
Tested and I can confirm it fixes the issue. The test failures are unrelated. Letting somebody else involved in the review to merge it, just in case there was more to do here.
app/models/host/managed.rb
Outdated
@@ -507,7 +508,7 @@ def self.registered_provision_methods | |||
end | |||
|
|||
def self.valid_rebuild_only_values | |||
Nic::Managed.rebuild_methods.values + Host::Managed.rebuild_methods.values | |||
Nic::Managed.rebuild_methods.values + Host::Managed.rebuild_methods.values if Host::Managed.respond_to?(:rebuild_methods) |
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 sure if this is on purpose or not, but the if clause here applies to the whole line. Perhaps return nil
early instead to make it clearer this is intentional?
does it make sense to only return Nic::Managed.rebuild_methods.values
if unattended=false
or not? since orchestration is included in Nic::Managed always, that method will work.
config/initializers/apipie.rb
Outdated
@@ -21,7 +21,7 @@ | |||
:providers_requiring_url => -> { ComputeResource.providers_requiring_url }, | |||
:default_nic_type => InterfaceTypeMapper::DEFAULT_TYPE.humanized_name.downcase, | |||
:template_kinds => -> { Rails.cache.fetch("template_kind_names", expires_in: 1.hour) {TemplateKind.pluck(:name).join(", ")} }, | |||
:host_rebuild_steps => -> { Host::Managed.valid_rebuild_only_values.join(', ') } | |||
:host_rebuild_steps => (-> { Host::Managed.valid_rebuild_only_values.join(', ') } if Host::Managed.valid_rebuild_only_values) |
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.
you can use Host::Managed.valid_rebuild_only_values&.join(', ')
instead of the condition to handle nil as well without calling the function twice
@tbrisker thanks, |
config/initializers/apipie.rb
Outdated
@@ -21,7 +21,7 @@ | |||
:providers_requiring_url => -> { ComputeResource.providers_requiring_url }, | |||
:default_nic_type => InterfaceTypeMapper::DEFAULT_TYPE.humanized_name.downcase, | |||
:template_kinds => -> { Rails.cache.fetch("template_kind_names", expires_in: 1.hour) {TemplateKind.pluck(:name).join(", ")} }, | |||
:host_rebuild_steps => -> { Host::Managed.valid_rebuild_only_values.join(', ') } | |||
:host_rebuild_steps => (-> { Host::Managed.valid_rebuild_only_values.join(', ') } || nil) |
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.
valid_rebuild_only_values
will always return an array now so the nil will never execute
thanks @tbrisker , it should be fine now. |
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.
Thanks @shiramax !
Terrible hack but thumbs up. I would love to kill unattended setting, but we need to plan this we still have users of this. |
Running 'rake apipie:cache:index' is no longer results in NoMethodError when
unattended=false
is set in the settings.yaml file.