Bug 1277695 - hostname regex fails in update-cluster in some locales
Summary: hostname regex fails in update-cluster in some locales
Alias: None
Product: OpenShift Container Platform
Classification: Red Hat
Component: ImageStreams
Version: 2.2.0
Hardware: Unspecified
OS: Unspecified
Target Milestone: ---
: ---
Assignee: Abhishek Gupta
QA Contact: DeShuai Ma
Depends On: 1261147
Blocks: 1277547
TreeView+ depends on / blocked
Reported: 2015-11-03 20:47 UTC by John W. Lamb
Modified: 2015-12-17 17:11 UTC (History)
9 users (show)

Fixed In Version: openshift-origin-cartridge-haproxy-
Doc Type: Bug Fix
Doc Text:
Particular locales trigger different definitions for regular expression character classes [a-z] and [A-Z] in Bash. This caused regex-based host name validation to fail when, for example, the Estonian locale "et_EE" was set in $LC_ALL, because the Estonian letter "u" falls outside of the [a-z] character class, and "rhcloud.com" has a "u" in it. This bug fix updates the `update-cluster` script to enforce use of the POSIX locale just for the locale-sensitive regex, and to restore the user's locale setting immediately afterwards. As a result, host name validation for the `update-cluster` script now works regardless of what locale may be specified by the user.
Clone Of: 1261147
Last Closed: 2015-12-17 17:11:20 UTC
Target Upstream Version:

Attachments (Terms of Use)

System ID Private Priority Status Summary Last Updated
Red Hat Product Errata RHSA-2015:2666 0 normal SHIPPED_LIVE Important: Red Hat OpenShift Enterprise 2.2.8 security, bug fix, and enhancement update 2015-12-17 22:07:54 UTC

Description John W. Lamb 2015-11-03 20:47:40 UTC
+++ This bug was initially created as a clone of Bug #1261147 +++

Description of problem:

If a user sets the LC_ALL environment variable to certain locales, such as et_EE, then the 'alphanumeric' range [a-zA-Z0-9] does not function correctly.  One place where this causes a problem is in a scaled app, where update-cluster checks a host:port combination against this regex:


since our domain is "rhcloud.com", and in Estonian the letter "u" falls outside of a-z, all attempts to move the gear or scale the app will fail with an error like:

September 08 13:02:57 INFO [app_uuid=REDACTED] openshift-agent: request end: action=cartridge_do, requestid=9cb59dcbb3c75f6c98b5c0b64c3bb957, senderid=mcollect.cloud.redhat.com, statuscode=1, data={:time=>nil, :output=>"CLIENT_ERROR: Failed to execute: 'control update-cluster' for /var/lib/openshift/REDACTED/haproxy\nWeb/Proxy gears ratio 1\nNo disabling required\n\nAPPNAME-DOMAIN.rhcloud.com|ex-std-node746.prod.rhcloud.com:42676 - Invalid endpoint 'ex-std-node746.prod.rhcloud.com:42676' passed in input - APPNAME-DOMAIN.rhcloud.com|ex-std-node746.prod.rhcloud.com:42676\n", :exitcode=>22, :addtl_params=>nil}

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

How reproducible:

Steps to Reproduce:
1. Create a scaled app
2. Use "rhc setenv" to set LANG and LC_ALL to et_EE.utf8
3. Attempt to scale up the app or move the gear.

Actual results:
update-cluster will fail with the message in the description

Expected results:
update-cluster should succeed

Additional info:

I was able to work around this issue by changing the regex to:


However, Luke Meyer brought up a good point that this is not really the right check, because we really only support hostnames which match ASCII letters and numbers.  The right solution is probably to set LC_ALL=C or en_US somewhere in the scripts.

--- Additional comment from John W. Lamb on 2015-10-20 17:21:42 EDT ---

This is very similar to this bug:

It should probably be fixed in a similar manner:

  LANG=en_US.UTF.8 if [[ ! $ep =~ <long regex> ]] ; then

I'll test this out in the next day or two.

--- Additional comment from John W. Lamb on 2015-10-22 10:57:23 EDT ---


--- Additional comment from openshift-github-bot on 2015-10-22 15:47:19 EDT ---

Commit pushed to master at https://github.com/openshift/origin-server

haproxy: use POSIX locale for validating endpoints

Bug 1261147
Bugzilla link <https://bugzilla.redhat.com/show_bug.cgi?id=1261147>

Different locales have different ideas of what `[a-z]` mean in a
regex. The regex used for endpoint validation in `update-cluster`
depends on the `POSIX` locale being set. Users that want to control the
locale their apps run in by setting `LC_ALL` to some non-`POSIX`
locale via `rhc set-env LC_ALL=xyz` (e.g. Estonian - `ee_ET`) would find
that scaling events might fail because `[a-z]` in the new locale
excludes some letters that might appear in a valid hostname.

This change updates the `update-cluster` script in the `haproxy`
cartridge so that it preserves the user's locale setting and switches to
the `POSIX` locale only for the part of the script that does the
endpoint validation.

See also:
 * <https://bugzilla.redhat.com/show_bug.cgi?id=1056666>

Comment 5 Gaoyun Pei 2015-11-19 07:53:22 UTC
verify this bug with openshift-origin-cartridge-haproxy-

1. Create a scaleble app
 rhc app create bin jbossews-2.0 -s

2. Set the LANG and LC_ALL to et_EE.utf8
 [root@broker ~]# rhc env-set LANG=et_EE.utf8 -a bin
 Setting environment variable(s) ... done
 [root@broker ~]# rhc env-set LC_ALL=et_EE.utf8 -a bin
 Setting environment variable(s) ... done

3. Scale-up this app
 [root@broker ~]# rhc app-scale-up -a bin
 bin scaled up
 [root@broker ~]# rhc app show bin --gears
 ID        State   Cartridges               Size  SSH URL
 --------- ------- ------------------------ ----- ------------------------------- ----------
 yes-bin-1 started haproxy-1.4 jbossews-2.0 small yes-bin-1@bin-yes.ose22- auto.com.cn
 yes-bin-2 started haproxy-1.4 jbossews-2.0 small yes-bin-2@yes-bin-2-yes.ose22-auto.com.cn

Comment 7 errata-xmlrpc 2015-12-17 17:11:20 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.


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