-
Notifications
You must be signed in to change notification settings - Fork 981
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 #9045 - added reschedule_migrations seed script #2098
Conversation
if User.anonymous_admin(false) && Puppetclass.count > 0 | ||
User.current = User.anonymous_admin | ||
Puppetclass.all.each(&:update_total_hosts) | ||
else |
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.
Why not leave a message for the user with puts
?
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.
Sure but it will end up in the Rails log. I think it's kinda useless. Do you happen to know how to display a nice message to the user?
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.
Added the puts anyway, won't hurt...
@lzap Rubocop is complaining, after that (and possibly the info message) 👍 |
Would it be better to move the code somewhere common (like app/services/) instead of calling migrations from seeds? |
Which code? The three lines hack? Do you think it is worth a new service file? I don't think so. There is zero reusability there. |
025e66b
to
4d779b2
Compare
Fixed Rubocop warning. |
I meant the contents of the rake task, but never mind, I thought you were calling that from db:seed, I see what's happening now. I'm really against merging this chaining of DB migrations from DB seeds. The upgrades that introduced the anonymous admin were back around Foreman 1.5/1.6, and the Puppet classes fix was around 1.7, so to merge this hack that's going to fire on every seed run is really not worth it at this point in time... |
@lzap , |
This is not outdated. Closing. |
This fixes the issue, but the drawback is it reschedules the puppetclass
correction after every single seed.
Alternative solution would be to create the anonymous admin if it's not present
directly in the codebase.