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 #17292 - take otp for freeipa before save @host object in db #5542

Merged
merged 1 commit into from
Mar 7, 2019

Conversation

pronix
Copy link
Contributor

@pronix pronix commented May 9, 2018

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

For render user data with otp for freeipa registrytion, host object should have otp before created job for render userdata.

@theforeman-bot
Copy link
Member

Do not merge! This patch has not been tested yet.

Can an existing organization member please verify this patch?

2 similar comments
@theforeman-bot
Copy link
Member

Do not merge! This patch has not been tested yet.

Can an existing organization member please verify this patch?

@theforeman-bot
Copy link
Member

Do not merge! This patch has not been tested yet.

Can an existing organization member please verify this patch?

@theforeman-bot
Copy link
Member

Issues: #17292

@theforeman-bot
Copy link
Member

There were the following issues with the commit message:

  • length of the first commit message line for 5896e41 exceeds 65 characters

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

@mmoll
Copy link
Contributor

mmoll commented May 9, 2018

ok to test

Copy link
Member

@timogoebel timogoebel left a comment

Choose a reason for hiding this comment

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

@pronix: Thanks. I left some comments. Do you mind adding a test for this as well? Thanks.

@@ -27,6 +27,7 @@ def del_realm

# Adds the host to the realm, and sets otp if we get one back
def set_realm(options = {})
return self.otp if self.otp.present? && !options[:update]
Copy link
Member

Choose a reason for hiding this comment

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

Why is this needed? Just as a gard, because the realm would be set twice otherwise (once from handle_realm_without_save and once from queue_realm_create)?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

it is also big difference when you have record in ipa and trying to update it, and when you trying to recreate token for existed record.

@@ -43,6 +43,7 @@ def queue_compute
end

def queue_compute_create
self.handle_realm_without_save
Copy link
Member

Choose a reason for hiding this comment

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

Isn't it enough to change the priority in queue_realm_create so that this runs earlier than the user data template rendering?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

you suggest set priority for queue_realm_create less then 1 ? because setUserData has priority 1

Copy link
Member

Choose a reason for hiding this comment

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

Well, I'd set the priority for the realm update to something lower then setUserdata but try to avoid negative numbers.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

so i should shift all tasks priority to +1 and insert on first place queue_realm_create.
correct ?

Copy link
Member

Choose a reason for hiding this comment

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

I think it should be enough to just increase the compute relates tasks, but in general: Yes.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ok. thanks. today will update.

@theforeman-bot
Copy link
Member

There were the following issues with the commit message:

  • 9e5236a must be in the format fixes #redmine_number - brief description

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

timogoebel
timogoebel previously approved these changes May 28, 2018
Copy link
Member

@timogoebel timogoebel left a comment

Choose a reason for hiding this comment

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

Looks good to me, but I haven't tested this.

@timogoebel
Copy link
Member

[test foreman]
[test katello]

@pronix
Copy link
Contributor Author

pronix commented May 29, 2018

@timogoebel looks like jenkins error. can you please retrigger it.

@mmoll
Copy link
Contributor

mmoll commented May 29, 2018

test failure unrelated 💚

@timogoebel
Copy link
Member

Code looks good to me, could somebody please jump in and help with testing this?

@eugen-natucci
Copy link

@timogoebel help with testing meaning writing tests? I want to participate.

@timogoebel
Copy link
Member

@jewgeni-prokhorenko: More like taking this patch and verifying it does not break provisioning and fixes the issue by manually testing this.

@pronix
Copy link
Contributor Author

pronix commented Jun 14, 2018

can i help with tests ?

@timogoebel
Copy link
Member

can i help with tests ?

Sure!

@alejojo
Copy link

alejojo commented Aug 8, 2018

Hi @timogoebel and @pronix,
I just tested with foreman 1.19.0-rc1 katello 3.8 and it fails with the following message:

Render user data template for donna-rosch.minet.net task failed with the following error: undefined method `handle_ca' for # Did you mean? handle_realm

@pronix
Copy link
Contributor Author

pronix commented Aug 8, 2018

hello
i not checked yet with 1.19
during weekend i will recheck it

@alejojo
Copy link

alejojo commented Aug 9, 2018

Hi @pronix,
I've removed the line 99:

 self.handle_ca

in compute.rb and it's working fine :D

@mmoll
Copy link
Contributor

mmoll commented Sep 7, 2018

@pronix What's the status here? Could you please rebase onto current develop?

@pronix
Copy link
Contributor Author

pronix commented Sep 7, 2018

hello @mmoll
it is in my plan during vacation after 2 weeks :)

@schlitzered
Copy link

i just tried the patch with my foreman 1.20 installation and it worked, would be great if this could be merged to foreman 1.20.1

@mmoll
Copy link
Contributor

mmoll commented Nov 22, 2018

a rebase and added tests are still needed.

@theforeman-bot
Copy link
Member

There were the following issues with the commit message:

  • e4e69e1 must be in the format fixes #redmine_number - brief description

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

@tinsjourney
Copy link

tinsjourney commented Mar 6, 2019

any update on this PR ?
tried the fix on 1.18.0.39 and it worked

@timogoebel
Copy link
Member

@theforeman/core: Could somebody review this? I would do it, but I don't have a testing environment for realm things.

@lzap
Copy link
Member

lzap commented Mar 7, 2019

Sorry it took so long. Now, I don't have realm setup as well, but I don't think it's super important to test if the patch fixes the realm issue. What's more important IMHO is test for regressions in compute resource, as you can see this patch changes priority numbers of these and this can have huge impact. I can do that.

Here is an idea - how about to clear priorities for once but forever? The problem is that we have them spread over the codebase and most of them are 1, 2, 3 numbers which makes everything pretty much "random". If you grep queue.create | grep priority you get most of these.

I suggest to create a new file app/services/orchestration/priority.rb with an explicit list of priority numbers as constants:

module Priority
  PRIORITY_CORE_DHCP_CREATE = 10
  PRIORITY_CORE_DHCP_DELETE = 9
  # etc for all orchestration "queue.create" calls

  # Katello
  PRIORITY_KATELLO_CV_CREATE = 30

This could be mixed in everywhere needed and then we would benefit from a single place with all priorities. We could do a breaking change and setup all orchestration order for once and forever so at least in core we have it in expected order and with some reasonable numbers like 100, 200, 300, 310, 320 so plugins could take advantage of that. I would file such a patch if folks are interested - @timogoebel and @tbrisker

Edit: I think it's worth to actually allow plugin authors to commit changes to the file so even plugins cant take advantage of seeing everything in one place. This is not tight coupling, this is just a list of numbers on a single place.

@lzap
Copy link
Member

lzap commented Mar 7, 2019

A simple example with libvirt VM works just fine:

[app|D|dc6|fe5] Scheduling new DHCP reservations for leigh-canupp.home.lan
[app|D|dc6|fe5] Enqueued task 'dhcp_create_192.168.99.194' to 'Host::Managed Main' queue
[app|D|dc6|fe5] Current organization set to MyOrg
[app|D|dc6|fe5] Current location set to MyLoc
[app|D|dc6|fe5] Current location set to none
[app|D|dc6|fe5] Current organization set to none
[app|D|dc6|fe5] Enqueued task 'Deploy TFTP PXELinux config for leigh-canupp.home.lan' to 'Host::Managed Main' queue
[app|D|dc6|fe5] Enqueued task 'Deploy TFTP PXEGrub2 config for leigh-canupp.home.lan' to 'Host::Managed Main' queue
[app|D|dc6|fe5] Enqueued task 'Deploy TFTP PXEGrub config for leigh-canupp.home.lan' to 'Host::Managed Main' queue
[app|D|dc6|fe5] Enqueued task 'Deploy TFTP iPXE config for leigh-canupp.home.lan' to 'Host::Managed Main' queue
[app|D|dc6|fe5] Enqueued task 'Fetch TFTP boot files for leigh-canupp.home.lan' to 'Host::Managed Main' queue
[app|D|dc6|fe5] Enqueued task 'Set up compute instance leigh-canupp.home.lan' to 'Host::Managed Main' queue
[app|D|dc6|fe5] Enqueued task 'Query instance details for leigh-canupp.home.lan' to 'Host::Managed Main' queue
[app|D|dc6|fe5] Observed create hook on leigh-canupp.home.lan
[app|D|dc6|fe5] Observed postcreate hook on leigh-canupp.home.lan
[app|D|dc6|fe5] Queuing 1 hooks for Host::Managed#postcreate

I am giving this a go, we are unlikely able to test all the plugins.

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.

Thanks.

@lzap lzap merged commit b48d799 into theforeman:develop Mar 7, 2019
@lzap
Copy link
Member

lzap commented Mar 7, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
9 participants