UnicodeDecodeError during mojo run
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
Mojo: Continuous Delivery for Juju |
Fix Released
|
Undecided
|
Unassigned |
Bug Description
Upon doing a new deployment, I ran in those errors:
$mojo run -m manifests/
.
.
.
2020-11-02 15:42:48 [INFO] Waiting up to 1800 seconds for environment to become ready (not blocked or in maintenance)
2020-11-02 15:42:50 [ERROR] Unknown error
Traceback (most recent call last):
File "/usr/lib/
args.func(args)
File "/usr/lib/
return method(*args, **kwargs)
File "/usr/lib/
manifest.
File "/usr/lib/
phase_
File "/usr/lib/
timeout=
File "/usr/lib/
self.
File "/usr/lib/
self.
File "/usr/lib/
return subprocess.
File "/usr/lib/
output, unused_err = process.
File "/usr/lib/
stdout = _eintr_
File "/usr/lib/
return func(*args)
File "/usr/lib/
return codecs.
UnicodeDecodeError: 'ascii' codec can't decode byte 0xe2 in position 27878: ordinal not in range(128)
It seems to happen on every `mojo run`
$ mojo run -m manifests/deploy
.
.
.
2020-11-02 16:05:41 [INFO] Checking Juju status (timeout=1800)
2020-11-02 16:05:41 [INFO] Waiting up to 1800 seconds for environment to become ready (not blocked or in maintenance)
2020-11-02 16:05:42 [ERROR] Unknown error
Traceback (most recent call last):
File "/usr/lib/
args.func(args)
File "/usr/lib/
return method(*args, **kwargs)
File "/usr/lib/
manifest.
File "/usr/lib/
phase_
File "/usr/lib/
juju_
File "/usr/lib/
self.
File "/usr/lib/
self.
File "/usr/lib/
return subprocess.
File "/usr/lib/
output, unused_err = process.
File "/usr/lib/
stdout = _eintr_
File "/usr/lib/
return func(*args)
File "/usr/lib/
return codecs.
UnicodeDecodeError: 'ascii' codec can't decode byte 0xe2 in position 27878: ordinal not in range(128)
Related branches
- Benjamin Allot: Approve
- Canonical IS Reviewers: Pending requested
-
Diff: 137 lines (+15/-23)4 files modifiedmojo/contain.py (+3/-3)
mojo/juju/status.py (+5/-8)
mojo/tests/test_juju1.py (+3/-6)
mojo/tests/test_juju2.py (+4/-6)
affects: | juju-deployer → mojo |
Changed in mojo: | |
status: | New → Fix Committed |
Changed in mojo: | |
status: | Fix Committed → Fix Released |
Ok, so I've finally figured out what's going on here.
We don't pass through any environment variables to Mojo when executing this, and when using universal_ newlines= True text is streamed using the encoding returned by locale. getpreferredenc oding(False) . Because we've not passed through (for example LANG) we end up with a preferred encoding of ANSI_X3.4-1968, which then fails on any unicode characters.
I was able to confirm the following fixes things (will discuss with a few folks whether this is the right approach and propose an MP):
=== modified file 'mojo/juju/ status. py' juju/status. py 2021-02-05 12:12:08 +0000 juju/status. py 2021-04-15 09:47:31 +0000
--- old/mojo/
+++ new/mojo/
@@ -1,5 +1,6 @@
from __future__ import division, print_function
import datetime
+import locale
import logging
import os
import subprocess
@@ -41,6 +42,7 @@
cmd. extend( command) setlocale( locale. LC_ALL, os.environ. get('LANG' , 'en_US.UTF-8')) check_output( cmd, universal_ newlines= True) CalledProcessEr ror as cpe:
try:
+ locale.
return subprocess.
except subprocess.
if command_timeout is not None: