Skip to content

Commit 83df91e

Browse files
authored
fix(logs): app logs endpoint was returning binary string instead of a normal string (#1035)
When pythong-requests got data from logger it was in binary string format, converting that to normal string was sufficient Fixes #1033
1 parent e1c6e71 commit 83df91e

3 files changed

Lines changed: 9 additions & 9 deletions

File tree

rootfs/api/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22
The **api** Django app presents a RESTful web API for interacting with the **deis** system.
33
"""
44

5-
__version__ = '2.2.0'
5+
__version__ = '2.3.0'

rootfs/api/models/app.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -735,7 +735,7 @@ def logs(self, log_lines=str(settings.LOG_LINES)):
735735
raise ServiceUnavailable('Error accessing deis-logger')
736736

737737
# cast content to string since it comes as bytes via the requests object
738-
return str(r.content)
738+
return str(r.content.decode('utf-8'))
739739

740740
def run(self, user, command):
741741
def pod_name(size=5, chars=string.ascii_lowercase + string.digits):

rootfs/api/tests/test_app.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ def test_app_override_id(self, mock_requests):
8989
self.assertContains(response, 'Application with this id already exists.', status_code=400)
9090

9191
@mock.patch('requests.get')
92-
def test_app_actions(self, mock_requests, mock_get):
92+
def test_app_logs(self, mock_requests, mock_get):
9393
app_id = self.create_app()
9494

9595
# test logs - 204 from deis-logger
@@ -111,7 +111,8 @@ def test_app_actions(self, mock_requests, mock_get):
111111
self.assertContains(
112112
response,
113113
"Error accessing logs for {}".format(app_id),
114-
status_code=500)
114+
status_code=500
115+
)
115116

116117
# test logs - success accessing deis-logger
117118
mock_response.status_code = 200
@@ -125,9 +126,8 @@ def test_app_actions(self, mock_requests, mock_get):
125126
self.assertContains(
126127
response,
127128
"Error accessing logs for {}".format(app_id),
128-
status_code=500)
129-
130-
# TODO: test run needs an initial build
129+
status_code=500
130+
)
131131

132132
@mock.patch('api.models.logger')
133133
def test_app_release_notes_in_logs(self, mock_requests, mock_logger):
@@ -566,9 +566,9 @@ def test_get_private_registry_config_bad_registry_location(self, mock_requests):
566566
self.assertEqual(create, None)
567567

568568

569-
FAKE_LOG_DATA = """
569+
FAKE_LOG_DATA = bytes("""
570570
2013-08-15 12:41:25 [33454] [INFO] Starting gunicorn 17.5
571571
2013-08-15 12:41:25 [33454] [INFO] Listening at: http://0.0.0.0:5000 (33454)
572572
2013-08-15 12:41:25 [33454] [INFO] Using worker: sync
573573
2013-08-15 12:41:25 [33457] [INFO] Booting worker with pid 33457
574-
"""
574+
""", 'utf-8')

0 commit comments

Comments
 (0)