Bug 1584743

Summary: katello-change-hostname does not update db.event_listeners
Product: Red Hat Satellite Reporter: Michal Dekan <mdekan>
Component: DocumentationAssignee: csherrar
Status: CLOSED CURRENTRELEASE QA Contact: Vlada Grosu <vgrosu>
Severity: low Docs Contact:
Priority: low    
Version: 6.2.14CC: adahms, jomitsch, mdekan, vgrosu
Target Milestone: UnspecifiedKeywords: Reopened
Target Release: Unused   
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2018-09-03 13:56:07 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Michal Dekan 2018-05-31 14:23:49 UTC
Description of problem:

When changing satellite hostname with katello-change-hostname, it will fail if we set new hostname with hostnamctl set-hostname before calling katello-change hostname:

Updating default Capsule
Error: smart_proxy not found
Couldn't find default Capsule id
Failed 'hammer -u admin -p redhat --output json capsule info --name mdekan-rhel7-sat62' with exit code 70

Its expected to fail, because katello-change-hostname seems to call hostnamectl on its own ...

However tricky part here is that when you change the hostname back to the old hostname with hostnamectl set-hostname, katelllo-change-hostname will succeed but it will not update db.event_listeners with new hostname (old one will remain there)

Version-Release number of selected component (if applicable):

satellite 6.2.14
satellite 6.2.15

How reproducible:

Change satellite hostname with hostnamectl and then run katello-change-hostname:

Updating default Capsule
Error: smart_proxy not found
Couldn't find default Capsule id
Failed 'hammer -u admin -p redhat --output json capsule info --name 'katello.example.com' with exit code 70

Steps to Reproduce:
1. hostnameclt set-hostname katello.example.com
2. katello-change-hostname katello.example.com -u admin -p XXX (will fail with above)

Changing to the old hostname with hostnamectl so katello-change-hostname can pass:

3. hostnamectl set-hostname test2.example.com
4. katello-change-hostname katello.example.com -u admin -p XXX (will pass)

Mongo will contain old hostname:
5. > db.event_listeners.find()
{ "_id" : ObjectId("5b0ff0b0226fa42c34df85b1"), "notifier_config" : { "url" : "https://test2.example.com/katello/api/v2/repositories/sync_complete?token=....

Actual results:

event_listeners collection in mongo contains old hostname when hostnamectl is used before katello-hostname-change to change the satellite hostname

Expected results:

event_listeners should contain correct hostname

Additional info:

Comment 1 John Mitsch 2018-05-31 14:35:16 UTC
You shouldn't change your hostname (via hostnamectl or other means) before running katello-change-hostname since the script relies on grabbing the old hostname for search/replace and other operations. If this isn't clear in the documentation, please file a docs bug.

Does event_listeners not get updated if you use katello-change-hostname without changing things via hostnamectl first? I'm curious if the bug can be reproduced when using k-c-h as intended.

Comment 2 Michal Dekan 2018-05-31 15:15:14 UTC
When the hostname is changed with hostnamectl before running katello-change hostname it fails.

If hostname was never changed and only katello-change-hostname was used to change the hosntame, its working fine, event_listeners gets updated with a new hostname.

My intention here was to handle the described scenario on the code level, since customers are sometimes changing hostname with hostnamectl first and then continue with katello-change-hostname, which fails.

Comment 7 Andrew Dahms 2018-07-31 13:34:52 UTC
Assigning to Clifton for review.

Clifton - see the above comments for the request.

Comment 27 Michal Dekan 2018-08-30 09:11:19 UTC
Hello,

reopening this BZ as katello-change-hostname (satellite 6.2 tool) is mentioned in doc for satellite 6.3. Can be a bit confusing.

https://access.redhat.com/documentation/en-us/red_hat_satellite/6.3/html/administering_red_hat_satellite/chap-red_hat_satellite-administering_red_hat_satellite-backup_and_disaster_recovery#sect-Red_Hat_Satellite-Administering_Red_Hat_Satellite-Renaming_a_Server

========
Warning

Do not change the system host name of your Satellite Server before running the **katello-change-hostname** script. If the system host name has been changed before running this script, the script will fail when searching for the old host name. 
========


https://access.redhat.com/documentation/en-us/red_hat_satellite/6.3/html/administering_red_hat_satellite/chap-red_hat_satellite-administering_red_hat_satellite-backup_and_disaster_recovery#sect-Red_Hat_Satellite-Administering_Red_Hat_Satellite-Renaming_a_Satellite_Server 

========
Ensure the system host name has not been changed before running the **katello-change-hostname** script. If the system host name has been changed, you must revert it to the original host name by using the hostnamectl set-hostname command. 
========

Comment 32 Vlada Grosu 2018-09-03 11:39:17 UTC
(In reply to Michal Dekan from comment #27)
> Hello,
> 
> reopening this BZ as katello-change-hostname (satellite 6.2 tool) is
> mentioned in doc for satellite 6.3. Can be a bit confusing.

Hi Michal,

Thank you for reopening this ticket and point out that these changes were only intended for the 6.2 Server Administration Guide. That's now been done.

Kind regards,
Vlada