Bug 1261147 - hostname regex fails in update-cluster in some locales
Summary: hostname regex fails in update-cluster in some locales
Keywords:
Status: CLOSED CURRENTRELEASE
Alias: None
Product: OpenShift Online
Classification: Red Hat
Component: Image
Version: 2.x
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: ---
: ---
Assignee: John W. Lamb
QA Contact: DeShuai Ma
URL:
Whiteboard:
Depends On:
Blocks: 1277547 1277695
TreeView+ depends on / blocked
 
Reported: 2015-09-08 17:25 UTC by Andy Grimm
Modified: 2016-11-08 03:48 UTC (History)
5 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
: 1277695 (view as bug list)
Environment:
Last Closed: 2016-01-29 16:23:41 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)

Description Andy Grimm 2015-09-08 17:25:19 UTC
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:

^([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9\-]{0,61}[a-zA-Z0-9])(\.([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9\-]{0,61}[a-zA-Z0-9]))*:[0-9]{4,5}$

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):
openshift-origin-cartridge-haproxy-1.30.1-1.el6oso.noarch

How reproducible:
Always

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:

^([[:alnum:]]|[[:alnum:]]([[:alnum:]]|-){0,61}[[:alnum:]])(\.([[:alnum:]]|[[:alnum:]]([[:alnum:]]|-){0,61}[[:alnum:]]))*:[0-9]{4,5}$

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.

Comment 1 John W. Lamb 2015-10-20 21:21:42 UTC
This is very similar to this bug:
https://bugzilla.redhat.com/show_bug.cgi?id=1056666

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.

Comment 3 openshift-github-bot 2015-10-22 19:47:19 UTC
Commit pushed to master at https://github.com/openshift/origin-server

https://github.com/openshift/origin-server/commit/bc48f5cf55e5191e1738394333f3fa212c551b66
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 4 Andy Grimm 2016-01-29 16:23:41 UTC
This was already released.


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