sysinv is_valid_domain_or_ip function rejects IP ending in single digit

Bug #1898921 reported by Don Penney
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
StarlingX
Fix Released
Medium
Yuxing

Bug Description

Brief Description
-----------------
The is_valid_domain_or_ip function from sysinv.common.utils fails when an IP address ends in a single digit. For example:

>>> from sysinv.common.utils import is_valid_domain_or_ip
>>> is_valid_domain_or_ip('10.10.10.1/mirror/k8s.gcr.io')
False
>>> is_valid_domain_or_ip('10.10.10.20/mirror/k8s.gcr.io')
True
>>> is_valid_domain_or_ip('10.10.10.9/mirror/k8s.gcr.io')
False
>>>
>>> from sysinv.common.utils import is_valid_domain
>>> is_valid_domain('10.10.10.9/mirror/k8s.gcr.io')
False
>>> is_valid_domain('10.10.10.20/mirror/k8s.gcr.io')
True
>>> is_valid_domain('10.10.1.20/mirror/k8s.gcr.io')
True
>>> is_valid_domain('10.1.1.20/mirror/k8s.gcr.io')
True
>>> is_valid_domain('1.1.1.20/mirror/k8s.gcr.io')
True
>>> is_valid_domain('1.1.1.1/mirror/k8s.gcr.io')
False
>>>

As a result, using something like "url: 10.10.10.1/mirror/k8s.gcr.io" as a docker_registries override in ansible localhost.yaml causes a validation failure when applying the bootstrap playbook.

The rejection stems from the regex used in the is_valid_domain function:
https://opendev.org/starlingx/config/src/commit/06839f3cbe99a42641706ad1eecb8723a8938876/sysinv/sysinv/sysinv/sysinv/common/utils.py#L1798

Severity
--------
Minor - workaround is available (specify 10.10.10.1:5000 instead)

Expected Behavior
------------------
is_valid_domain_or_ip('10.10.10.1/mirror/k8s.gcr.io') should return True

Actual Behavior
----------------
Returns False

Reproducibility
---------------
Reproducible

Branch/Pull Time/Commit
-----------------------
master, as of Oct 7, 2020

Workaround
----------
Specify port, ie. 10.10.10.1:5000 to fall through to the IP/port check of the function.

Revision history for this message
Ghada Khalil (gkhalil) wrote :

stx.5.0 / medium priority - would be nice to fix to avoid the workaround

tags: added: stx.config
Changed in starlingx:
importance: Undecided → Low
status: New → Triaged
importance: Low → Medium
tags: added: stx.5.0
Changed in starlingx:
assignee: nobody → Yuxing (yuxing)
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to config (master)

Fix proposed to branch: master
Review: https://review.opendev.org/758563

Changed in starlingx:
status: Triaged → In Progress
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to config (master)

Reviewed: https://review.opendev.org/758563
Committed: https://git.openstack.org/cgit/starlingx/config/commit/?id=14e56460d08401c29f4628b5e957c6c9eb2a04c5
Submitter: Zuul
Branch: master

commit 14e56460d08401c29f4628b5e957c6c9eb2a04c5
Author: Yuxing Jiang <email address hidden>
Date: Thu Oct 15 15:45:48 2020 -0400

    Split ip address without port

    The url string should split by slash to get the ip address in the
    case there is no specified port. This commit splits the path and
    port from the ip address before validating, allows the ip validate
    methods get the correct format of address. After this change, the
    port sector in the is_valid_domain is no longer required.

    An unit test against the is_valid_domain_or_ip method with a
    list of typical urls is added.

    Tested wih a fresh install on an AIOSX setup, and boot it up with
    the ansible playbook.

    Closes-bug: 1898921
    Change-Id: I5d37fafbfd7bdc669bba61e5d0c04eb467c46e70
    Signed-off-by: Yuxing Jiang <email address hidden>

Changed in starlingx:
status: In Progress → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.