-
Notifications
You must be signed in to change notification settings - Fork 64
[WIP] Connection Healthcheck option #295
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
Open
sideangleside
wants to merge
1
commit into
Katello:master
Choose a base branch
from
sideangleside:connection-check
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1013,6 +1013,27 @@ def check_rhn_registration(): | |
| return False | ||
|
|
||
|
|
||
| def validate_connection(): | ||
| """Validate that servers are up """ | ||
| print_generic("Beginning service status and response-time check on port %s " % API_PORT) | ||
| print_generic("Ensuring services are online and accessible on within %s milliseconds" % options.service_timeout) | ||
| url = "https://" + options.foreman_fqdn + ":" + API_PORT + "/katello/api/ping" | ||
| features = get_json(url)['services'] | ||
| svc_list = ["candlepin", "pulp", "pulp_auth", "candlepin_auth", "foreman_tasks"] | ||
| for service in svc_list: | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. the next 10 lines are pretty repetitive, how about: for service in svc_list:
service_error = None
if features[service]['status'] != 'ok':
service_error = "service %s reports a state of %s" % (service, features[service]['status'])
elif int(features[service]['duration_ms']) >= options.service_timeout:
service_error = "service %s reponds in %s ms which exceeds maximum of %s ms" % (service, features[service]['duration_ms'], str(options.service_timeout))
if service_error:
print_error("Error detected in the Service Health Check. Cleaning up install")
clean_katello_agent()
print_error(service_error)
sys.exit(3) |
||
| if features[service]['status'] != 'ok': | ||
| print_error("Error detected in the Service Health Check. Cleaning up install") | ||
| clean_katello_agent() | ||
| print_error("service %s reports a state of %s" % (service, features[service]['status'])) | ||
| sys.exit(3) | ||
| if int(features[service]['duration_ms']) >= options.service_timeout: | ||
| print_error("Error detected in the Service Health Check. Cleaning up install") | ||
| clean_katello_agent() | ||
| print_error("service %s reponds in %s ms which exceeds maximum of %s ms" % (service, features[service]['duration_ms'], str(options.service_timeout))) | ||
| sys.exit(3) | ||
| print_success("Service status and response-time check finished") | ||
|
|
||
|
|
||
| def enable_repos(): | ||
| """Enable necessary repositories using subscription-manager.""" | ||
| repostoenable = " ".join(['--enable=%s' % i for i in options.enablerepos.split(',')]) | ||
|
|
@@ -1164,7 +1185,7 @@ def exec_service(service, command, failonerror=True): | |
| else: | ||
| DEFAULT_DOWNLOAD_METHOD = 'http' | ||
|
|
||
| SKIP_STEPS = ['foreman', 'puppet', 'migration', 'prereq-update', 'katello-agent', 'remove-obsolete-packages', 'puppet-enable', 'katello-host-tools'] | ||
| SKIP_STEPS = ['foreman', 'puppet', 'migration', 'prereq-update', 'katello-agent', 'remove-obsolete-packages', 'puppet-enable', 'katello-host-tools', 'connection-check'] | ||
|
|
||
| # > Define and parse the options | ||
| usage_string = "Usage: %prog -l admin -s foreman.example.com -o 'Default Organization' -L 'Default Location' -g My_Hostgroup -a My_Activation_Key" | ||
|
|
@@ -1221,6 +1242,7 @@ def exec_service(service, command, failonerror=True): | |
| parser.add_option("--ignore-registration-failures", dest="ignore_registration_failures", action="store_true", help="Continue running even if registration via subscription-manager/rhn-migrate-classic-to-rhsm returns a non-zero return code.") | ||
| parser.add_option("--preserve-rhsm-proxy", dest="preserve_rhsm_proxy", action="store_true", help="Preserve proxy settings in /etc/rhsm/rhsm.conf when migrating RHSM -> RHSM") | ||
| parser.add_option("--install-katello-agent", dest="install_katello_agent", action="store_true", help="Installs the Katello Agent", default=False) | ||
| parser.add_option("--service-timeout", dest="service_timeout", type="int", help="Time (in milliseconds) that server services must respond to be healthy prior to registration. Defaults to %default", metavar="service_timeout", default=1000) | ||
| (options, args) = parser.parse_args() | ||
|
|
||
| if options.no_foreman: | ||
|
|
@@ -1339,6 +1361,7 @@ def exec_service(service, command, failonerror=True): | |
| print("PUPPET CA PORT - %s" % options.puppet_ca_port) | ||
| print("IGNORE REGISTRATION FAILURES - %s" % options.ignore_registration_failures) | ||
| print("PRESERVE RHSM PROXY CONFIGURATION - %s" % options.preserve_rhsm_proxy) | ||
| print("SERVICE TIMEOUT - %s" % options.service_timeout) | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. KATELLO SERVICE TIMEOUT |
||
| print("REX - %s" % options.remote_exec) | ||
| if options.remote_exec: | ||
| print("REX USER - %s" % options.remote_exec_user) | ||
|
|
@@ -1415,6 +1438,8 @@ def exec_service(service, command, failonerror=True): | |
| get_bootstrap_rpm(clean=options.force) | ||
| generate_katello_facts() | ||
| API_PORT = get_api_port() | ||
| if 'connection-check' not in options.skip: | ||
| validate_connection() | ||
| if 'foreman' not in options.skip: | ||
| create_host() | ||
| configure_subscription_manager() | ||
|
|
@@ -1443,6 +1468,8 @@ def exec_service(service, command, failonerror=True): | |
| if 'katello-agent' in options.skip: | ||
| print_warning("Skipping the installation of the Katello Agent is now the default behavior. passing --skip katello-agent is deprecated") | ||
| API_PORT = get_api_port() | ||
| if 'connection-check' not in options.skip: | ||
| validate_connection() | ||
| smart_proxy_id = return_matching_foreman_key('smart_proxies', 'name="%s"' % options.foreman_fqdn, 'id', False) | ||
| current_host_id = return_matching_foreman_key('hosts', 'name="%s"' % FQDN, 'id', False) | ||
| capsule_features = get_capsule_features(smart_proxy_id) | ||
|
|
@@ -1509,6 +1536,8 @@ def exec_service(service, command, failonerror=True): | |
| get_bootstrap_rpm(clean=options.force) | ||
| generate_katello_facts() | ||
| API_PORT = get_api_port() | ||
| if 'connection-check' not in options.skip: | ||
| validate_connection() | ||
| if 'foreman' not in options.skip: | ||
| create_host() | ||
| configure_subscription_manager() | ||
|
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
this list will vary between Katello versions, why not iterating over
features.keys()directly?