Bug 1426424 - Bootstrap fails to register systems with invalid hostnames or only have short names
Summary: Bootstrap fails to register systems with invalid hostnames or only have short...
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Satellite
Classification: Red Hat
Component: Bootstrap
Version: 6.2.8
Hardware: Unspecified
OS: Unspecified
high
high
Target Milestone: Unspecified
Assignee: Rich Jerrido
QA Contact: Lukáš Hellebrandt
URL:
Whiteboard:
Depends On: 1425606
Blocks: 1122832
TreeView+ depends on / blocked
 
Reported: 2017-02-23 20:49 UTC by Satellite Program
Modified: 2020-12-14 08:15 UTC (History)
7 users (show)

Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Clone Of: 1425606
Environment:
Last Closed: 2018-02-21 17:06:49 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)

Description Satellite Program 2017-02-23 20:49:20 UTC
+++ This bug was initially created as a clone of Bug #1425606 +++

Description of problem:

When running bootstrap, it fails to register a system that has an invalid hostname, (such as one with an underscore), or hostname that are short (hostname -f) doesn't return an FQDN, 


Version-Release number of selected component (if applicable):
katello-client-bootstrap-1.2.2

How reproducible:
100%

Steps to Reproduce:
1. Create a system with a 

short name (where hostname -f or "ython -c "import socket;print socket.getfqdn()"" returns a shortname

or an invalid name. (Such as a name with an underscore), such as foo_bar.example.com


2. Register with bootstrap. 
3.

Actual results:
bootstrap fails with an error similar to the following:

    [RUNNING], [2017-02-21 14:13:01], [Calling Foreman API to create a host entry associated with the group, domain, org & location]
    url: https://<capsule-fqdn>:8443/api/v2/hosts/
    method: POST
    data: {
      "host": {
        "managed": "true",
        "name": "<hostname>",
        "hostgroup_id": 22,
        "organization_id": 1,
        "mac": "00:50:56:90:11:D2",
        "architecture_id": 1,
        "location_id": 3,
        "domain_id": 6
      }
    }
    Error: The following error occured while talking to the API:
    url: https://<capsule-fqdn>:8443/api/v2/hosts/
    code: 422
    data: {
      "host": {
        "managed": "true",
        "name": "<hostname>",
        "hostgroup_id": 22,
        "organization_id": 1,
        "mac": "00:50:56:90:11:D2",
        "architecture_id": 1,
        "location_id": 3,
        "domain_id": 6
      }
    }
    error: {
      "error": {
        "errors": {
          "interfaces.name": [
            "is invalid"
          ],
          "name": [
            "is invalid"
          ]
        },
        "id": null,
        "full_messages": [
          "Name is invalid",
          "Name is invalid"
        ]
      }
    }

Expected results:

bootstrap successfully registers the system. 

Additional info:

--- Additional comment from rjerrido on 20170221T22:23:22

Also RFC 952 or 1123 covers hostname validation and Foreman appears to respect this (see lib/net/validations.rb). 

As we generally cannot ask the customer to change their hostnames (many have short names for 3rd party apps), it might be advisable to allow the customer to set an arbitrary hostname in bootstrap.py (for puppet and subscription-manager) that differs from what the system reports.

--- Additional comment from rjerrido on 20170223T19:29:43

Fixed in commit https://github.com/Katello/katello-client-bootstrap/commit/49ec1ae44a7463f5f615ad6d59fccd21d9da6bda

Comment 3 Lukáš Hellebrandt 2017-10-17 14:34:29 UTC
Verified with Sat6.3 snap 20.

Used reproducer from original BZ's comment 4:

# ./bootstrap.py -s <Satellite_FQDN> -o 'Default Organization' -a testak -g 'testhostgroup' -L 'Default Location' --fqdn <client_FQDN>

Note: When run without the --fqdn parameter, the following error text is shown:

"""
We could not determine the domain of this machine, most probably `hostname -f` does not return the FQDN.
This can lead to Puppet missbehaviour and thus the script will terminate now.
You can override this by passing one of the following
	--force - to disable all checking
	--skip-puppet - to omit installing the puppet agent
"""

As we solved this by using --fqdn parameter, this should also be mentioned in the error text.

Comment 4 Bryan Kearney 2018-02-21 17:06:49 UTC
Since the problem described in this bug report should be resolved in a recent advisory, it has been closed with a resolution of ERRATA.

For information on the advisory, and where to find the updated files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHSA-2018:0336


Note You need to log in before you can comment on or make changes to this bug.