consider setting proper locale for hooks environments
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
Canonical Juju |
Fix Released
|
Medium
|
Tim Penhey | ||
MongoDB Charm |
Won't Fix
|
Low
|
Unassigned |
Bug Description
A mongodb-
The python script encountered a unicode error:
2014-06-19 20:23:17 INFO mongodb-
2014-06-19 20:23:17 INFO mongodb-
2014-06-19 20:23:17 INFO mongodb-
2014-06-19 20:23:17 INFO mongodb-
2014-06-19 20:23:17 INFO mongodb-
2014-06-19 20:23:17 INFO mongodb-
2014-06-19 20:23:17 INFO mongodb-
2014-06-19 20:23:17 INFO mongodb-
2014-06-19 20:23:17 INFO mongodb-
2014-06-19 20:23:17 INFO mongodb-
2014-06-19 20:23:17 ERROR juju.worker.uniter uniter.go:482 hook failed: exit status 1
Running the same script from a terminal on the same node succeeded.
After further debugging, I determined that the mongodb-
Adding:
export LANG=en_US.UTF-8
to the hook allowed the import script to succeed.
Note: although this enabled me to make progress on writing my hook, I think upstream needs to take a closer look. I am not an expert on locales, and I wonder if forcing en_US.UTF-8 on all juju users is appropriate or not...
Copied from github (also see discussion there): https:/
Changed in juju-core: | |
assignee: | nobody → Jesse Meek (waigani) |
Changed in juju-core: | |
assignee: | Jesse Meek (waigani) → nobody |
Changed in juju-core: | |
importance: | High → Medium |
Changed in juju-core: | |
milestone: | none → 2.0.0 |
tags: | added: mongodb |
affects: | juju-core → juju |
Changed in juju: | |
milestone: | 2.0.0 → none |
milestone: | none → 2.0.0 |
Changed in juju: | |
milestone: | 2.0.0 → 2.0.1 |
Changed in juju: | |
milestone: | 2.0.1 → none |
affects: | mongodb (Juju Charms Collection) → mongodb-charm |
tags: | added: canonical-is |
Changed in juju: | |
milestone: | none → 2.7-beta1 |
assignee: | nobody → Tim Penhey (thumper) |
Changed in juju: | |
status: | In Progress → Fix Committed |
Changed in juju: | |
status: | Fix Committed → Fix Released |
Changed in charm-mongodb: | |
status: | Triaged → Won't Fix |
The traceback is showing a bug in the mongodb charm:
2014-06-19 20:23:17 INFO mongodb- relation- changed json_data = open(basepath + 'data/bikes/ Valenbisi. JSON'). read()
It is attempting to open a file in text mode without specifying the encoding, which will fail in some environments. You could force the system locale, which would mean this bug would only be triggered in locales not using UTF-8 encoding. Forcing a specific locale is not really appropriate, as if you are not using the system locale or you will end up with much harder to solve problems (things being sorted in the wrong order, unreadable filenames).
As the preferred encoding of JSON is UTF-8, the fix is to specify this in the open call (if you want read() to return unicode text), or open the file in binary mode if you want a UTF-8 encoded byte string.