-
Notifications
You must be signed in to change notification settings - Fork 71
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 #22458 - Add Katello service command #151
Conversation
bc8c5b9
to
663cbea
Compare
663cbea
to
7c5cf13
Compare
@iNecas can you move this ticket to foreman maintain? |
definitions/features/katello.rb
Outdated
'foreman-tasks' => 30, | ||
'goferd' => 30 | ||
} | ||
end |
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.
@iNecas @mbacovsky Should I split up these services into different features? They are being selected based if they exist on the sytem We could keep one master list of services and it shouldn't make a difference if its standalone foreman/foreman-proxy/etc. Curious to hear your thoughts.
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.
If we do go with one list, I also am wondering where the best home for it would be 😄
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.
What about every relevant feature (foreman, katello, pulp, tasks…) including some module (something like FeatureWithServices) and providing a method (e.g. services_info
) that would provide the partial hash for it's part. Alternatively to including some module, we could mark those features with some metadata tag.
We could then get the list of relevant services with something like features.find_all { |f| f.is_a? FeatureWithServices }.map(&:service_info).reduce(&:merge)
.
WIth this approach, I believe we can achieve better modularity of the scripts
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 like the idea of moving the services into the features. I used the same approach with config files in backup (each feature with configs has method config_files returning the list).
I also like the the idea of tagging the features and putting the master list together dynamically. For the config files the HasConfigFiles
tag would equal respond_to?(:config_files)
but for services it may be different, so +1 for tagging.
The question is how it would look like for features with more than one service such as Pulp. Do we want to create feature for each service?
I agree it may make sense to include some module FeatureWithServices making sure the feature comply with some service related interface that we can relay on.
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.
Having a feature per service would be probably an overkill: the pulp feature could just return something like this:
def services
{ 'pulp_workers' => 20,
'pulp_celerybeat' => 20,
'pulp_resource_manager' => 20,
'pulp_streamer' => 20 }
end
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 for the suggestions, I'll add services per feature in a module with methods to return them
Is there a way to say "what features does this machine have?" I imagine that would be helpful not only here but in the other katello scripts as well
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.
ForemanMaintain.available_features
should return that. You can also pass filtering params and filter based on class
, label
or tag
. So ForemanMaintain.available_features(:tag => 'HasServices')
should do the trick.
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 tried with the config files and this worked:
features = ForemanMaintain.available_features(:tags => :has_config_files)
when the features are tagged with
metadata do
tags :has_config_files
end
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.
@mbacovsky why a tag? Why not just have a method with a blank hash in ForemanMaintain::Feature
and override it in the features with services?
Then we could just do ForemanMaintain.available_features.map(&:services).reduce(&:merge)
A simliar strategy could be done for config files too
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 updated this part in my latest commit
# TODO: DRY up labels | ||
label_option | ||
tags_option | ||
interactive_option |
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.
@iNecas @mbacovsky what is the best way to not repeat these option methods each subcommand?
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.
Also do I need all of these? If I didn't include them I got an error (something about "assumeyes" not found iirc), but not sure if I need all of them
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.
Currently, we don't have any way to avoid this repetition. If we want to achieve then we will need to add wrapper on top of it but I am not sure how easy it will be.
It is giving error because when we called method run_scenario
from base class we have used assumeyes? method.
Note - For flag options, Clamp provides "#{flag-option-name}?" method.
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.
@johnpmitsch do you need label and tags? It worked for for me when removed. The interactive_option(s) are needed by runner but I'm not sure if --assumeyes and --whitelist makes sense in the scripts. I'd suggest to fix the runner to not depend on these and use it only when available.
Back to your question - if not removed it could be included in common predecessor for the service subcommands. For such case there is another notation for subcommand declaration https://github.com/mdub/clamp#declaring-subcommands.
One thing I noticed and am not sure about is the declaration of --exclude and --only options. The way it is done it allows you to call foreman-maintain service --only httpd status
and also foreman-maintain service status --only httpd
. Both ways work both make sense but I'd stick with one to avoid confusion. While I like the first notation (reminds me sysv init scripts notation) it is the second one our CLI is using quite uniformly.
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.
@mbacovsky thanks, I can try to remove the label and tags option. I agree that foreman-maintain service status --only httpd
would be good syntax and match our CLI usage already, I'll update to that 💯
@@ -0,0 +1,21 @@ | |||
#TODO: figure out why I need this? | |||
require_relative 'base.rb' |
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.
@iNecas @mbacovsky Is there a better way to do this? I would have thought the base class would be required already here, but it wasn't. Maybe I am missing something obvious 🤷♂️
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.
Yes, you don't need to require base class here. Instead of Base class, you just need to inherit List class from ForemanMaintain::Procedure. Example -
module Procedures::Services
class List < ForemanMaintain::Procedure
# code
end
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.
The base class is for the services procedures to share methods, and it inherits from ForemanMaintain::Procedure
. I'm fine with the require_relative here but I am just wondering if there is a better way such as adding something in `lib/foreman_maintain.rb
@ehelms was faster than me in moving the ticked. I however put you to developers of foreman-maintain in redmine, so you should be able to do the change on your own. |
@ntkathole thanks for the review! To confirm, were you able to test out on both 6.1 and 6.2? Also testing RHEL6? I did my best to test this out locally but would like someone to confirm that they tested this w/o issue |
@johnpmitsch Tested on sat 6.1, 6.2 and 6.3. For 6.2, when service are stopped, I faced an issue http://projects.theforeman.org/issues/22945 but, it is not related to this PR. RHEL 6 is not tested as afaik foreman-maintain don't support it (we use clone tool for migration). Please correct me here/ let me know if rhel6 testing is needed/ |
Since so far, we've been targeting with one release against multiple versions, and 6.1 and 6.2 are supported on rhel6, we should also test this scenario on rhel6 |
And yes, the regressions you mentioned is not related |
|
||
def services | ||
{ | ||
'postgresql' => 5, |
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.
Shouldn't postgresql be in foreman_database and candlepin_database features?
@johnpmitsch so far it looks good, I've tested it on recent Foreman + Katello and Sat 6.1 on RHEL 6. I' d like to give it a try on plain Foreman.
|
@johnpmitsch on Foreman without katello the -p option is not applicable. It may make sense to condition it by presence of feature(:katello). |
@johnpmitsch I've investigated the issue with |
@@ -43,6 +43,10 @@ def env_content_ids_with_null_content | |||
query(sql).map { |r| r['id'] } | |||
end | |||
|
|||
def services | |||
{ 'tomcat' => 20 } |
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.
tomcat6
should be listed for Sat 6.1. Also this does not feel like the right place for these services. I'd move them to candlepin or katello. For candlepin_database
the related service would be potgresql
.
cea5896
to
80a7757
Compare
@mbacovsky I've updated the hammer ping part to be restricted by @mbacovsky I added tomcat6 to the |
(sorry changes aren't in a separate commit, I have a bad amend + force push habit) 🚬 |
actually hold on reviewing plz, for some reason hammer ping is running all the time now |
@johnpmitsch +1 on adding the candlepin feature |
f0996f3
to
ee7ed4d
Compare
@mbacovsky updated the option_wrapper according to our discussion off thread and also moved the candlepin services to a new candlepin feature |
ee7ed4d
to
09d067b
Compare
@mbacovsky one update on the option_wrapper, I had to move away from passing in a default argument like i.e. for which is why we need something like I kept the argument there in case its needed, but it defaults to |
09d067b
to
2bc37ba
Compare
Katello-service is added as foreman-maintain service
@johnpmitsch, I've tested against plain Foreman and Sat 6.1 and all the issues were fixed. Thanks! One last thing I'd prefer to get fixed is moving postgres service to candlepin_database and foreman_database features as they are bound closer to the service than the :foreman_server is. We will need to do this anyway for adding support for remote DBs, so I'm okay to postpone till then if you prefer to no longer block this PR. |
ACK, given we address the postgres service later. Thanks @johnpmitsch, 🎆 👍 |
@iNecas, If there are no objections could you merge, please? |
Thanks @johnpmitsch, @mbacovsky and @ntkathole |
Todo