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

Fixes #23536 - No errors when unattended=false #5687

Merged
merged 1 commit into from
Jun 26, 2018

Conversation

shiramax
Copy link
Contributor

Running 'rake apipie:cache:index' is no longer results in NoMethodError when unattended=false is set in the settings.yaml file.

@theforeman-bot
Copy link
Member

Issues: #23536

@theforeman-bot
Copy link
Member

There were the following issues with the commit message:

  • commit message for 78a8fcf is not wrapped at 72nd column

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

@theforeman-bot
Copy link
Member

There were the following issues with the commit message:

  • commit message for b9bd1dc is not wrapped at 72nd column

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

@shiramax shiramax changed the title Fixes #23536 - no error when unattended=false Fixes #23536 - No errors when unattended=false Jun 13, 2018
@shiramax shiramax changed the title Fixes #23536 - No errors when unattended=false Fixes #23536 - No errors when unattended=false Jun 13, 2018
@theforeman-bot
Copy link
Member

There were the following issues with the commit message:

  • commit message for bb6c3c5 is not wrapped at 72nd column

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

@xprazak2
Copy link
Contributor

Takes care of the issue for me. Could you please modify the commit message as the bot suggests?

Test failures are unrelated.

@tbrisker
Copy link
Member

@ShimShtein @lzap since i think you're most familiar with orchestration code, does it make sense to include orchestration module when unattended==false or would that lead to unexpected results?

@lzap
Copy link
Member

lzap commented Jun 15, 2018

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

@shiramax
Copy link
Contributor Author

@lzap thanks, I agree we need to re-think about the unattended mode,
I predict it will take some time until the unattended mode will be removed completely so I think that in the meantime it's best to add this PR.

lzap
lzap previously requested changes Jun 20, 2018
Copy link
Member

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

@iNecas
Copy link
Member

iNecas commented Jun 22, 2018

As the backtrace shows, the methods are used from here

:host_rebuild_steps => -> { Host::Managed.valid_rebuild_only_values.join(', ') }
, and they are used to generate values to be used in translations of docs strings of the apipie (such as here
param :only, Array, :desc => N_("Limit rebuild steps, valid steps are %{host_rebuild_steps}")
).

I agree using respond_to at corresponding place is safer to go ATM.

@shiramax
Copy link
Contributor Author

@iNecas @lzap @tbrisker @xprazak2 thanks, please review again :)

iNecas
iNecas previously approved these changes Jun 25, 2018
Copy link
Member

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

@@ -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)
Copy link
Member

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.

@@ -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)
Copy link
Member

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

@shiramax
Copy link
Contributor Author

@tbrisker thanks,
please review again :)

@@ -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)
Copy link
Member

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

@shiramax
Copy link
Contributor Author

thanks @tbrisker , it should be fine now.

Copy link
Member

@tbrisker tbrisker left a comment

Choose a reason for hiding this comment

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

Thanks @shiramax !

@lzap
Copy link
Member

lzap commented Jun 26, 2018

Terrible hack but thumbs up. I would love to kill unattended setting, but we need to plan this we still have users of this.

@tbrisker tbrisker merged commit c189204 into theforeman:develop Jun 26, 2018
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.

6 participants