Skip to content
This repository has been archived by the owner on Aug 29, 2018. It is now read-only.

Fixes #19227 - katello-change-hostname health check #424

Merged
merged 1 commit into from Apr 20, 2017

Conversation

johnpmitsch
Copy link
Contributor

This will check services before running the hostname change.
A hammer ping doesn't return a failing exit code if a
service is failing, so this makes use of grepping FAIL

@theforeman-bot
Copy link

@johnpmitsch, the Redmine ticket used is for a different project than the one associated with this GitHub repository. Please either:

If changing the ticket number used, remember to update the PR title and the commit message (using git commit --amend).


This message was auto-generated by Foreman's prprocessor

@johnpmitsch
Copy link
Contributor Author

Failing hammer ping status - script terminates

[root@john ~]# ./katello-change-hostname -u admin -p changeme -d hey.example.com
This script will modify your system. You will need to re-register any Foreman Proxies and Katello clients after script completion. Foreman Proxies will have to be reinstalled. If you are using custom certificates, you will have to run the foreman-installer again with custom certificate options after this script completes. Have you taken the necessary precautions (backups, snapshots, etc...) and want to proceed with changing your hostname? 
 [y/n]:
true
All services are not currently running, please check 'hammer ping'
[root@john ~]# hammer ping
candlepin:      
    Status:          ok
    Server Response: Duration: 23ms
candlepin_auth: 
    Status:          ok
    Server Response: Duration: 23ms
pulp:           
    Status:          FAIL
    Server Response:
foreman_tasks:  
    Status:          ok
    Server Response: Duration: 488ms

Successful hammer ping status - script completes successfully

[root@john ~]# ./katello-change-hostname -u admin -p changeme -d hey.example.com
...
...
...
  Success!
  * Katello is running at https://hey.example.com
  * To install an additional Foreman proxy on separate machine continue by running:

      foreman-proxy-certs-generate --foreman-proxy-fqdn "$FOREMAN_PROXY" --certs-tar "~/$FOREMAN_PROXY-certs.tar"

  The full log is at /var/log/foreman-installer/katello.log
[ INFO 2017-04-12 20:32:57 verbose] pulp.conf is already present, skipping
[ INFO 2017-04-12 20:32:57 verbose] All hooks in group post finished
Regenerating ueber certs
rake aborted!
Don't know how to build task 'katello:regenerate_ueber_certs' (error from running on 3.3 which doesn't have this task)

(See full trace by running task with --trace)
Restarting puppet services
Redirecting to /bin/systemctl restart  puppet.service
Redirecting to /bin/systemctl restart  puppetserver.service

  Hostname change complete!
  
  You will need to re-register any Foreman Proxies or clients with the server. 
  
  When re-registering clients, you will have to reinstall the bootstrap RPM.
  Any mention of the hey.example.com on your clients will have to change to hey.example.com (i.e. /etc/hosts)
  
  For Foreman Proxies, you will need to regenerate the certs on the Katello server and reinstall the Foreman Proxy
  
  If you want to use custom certificates, re-run the foreman-installer with custom certificate options

  Short hostnames have not been updated, please update those manually.
  
[root@john ~]# 
[root@john ~]# hammer ping
candlepin:      
    Status:          ok
    Server Response: Duration: 238ms
candlepin_auth: 
    Status:          ok
    Server Response: Duration: 42ms
pulp:           
    Status:          ok
    Server Response: Duration: 70ms
foreman_tasks:  
    Status:          ok
    Server Response: Duration: 42ms

Copy link
Member

@akofink akofink 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, just one small comment.

hammer_ping_failure = $?.success?
if hammer_ping_failure
STDOUT.puts "All services are not currently running, please check 'hammer ping'"
exit(false)
Copy link
Member

Choose a reason for hiding this comment

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

what about the case when hammer ping returns overall failure? To test this, stop your katello server. hammer_ping_failure is false in that case.

This will check services before running the hostname change.
A `hammer ping` doesn't return a failing exit code if a
service is failing, so this makes use of grepping FAIL
@johnpmitsch
Copy link
Contributor Author

@akofink I updated to check the return code as well, this will be != 0 if the "status" of hammer ping is failing.

Side note -- shouldn't hammer ping display the overall status as well?

@akofink
Copy link
Member

akofink commented Apr 20, 2017

It does display an overall status in some cases, but if the server is down, no response is sent.

$ hammer ping
Error: 503 Service Unavailable

@akofink
Copy link
Member

akofink commented Apr 20, 2017

LGTM! ACK!

@johnpmitsch johnpmitsch merged commit b9f809c into Katello:master Apr 20, 2017
@johnpmitsch johnpmitsch deleted the hostname_change_health branch April 20, 2017 19:40
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants