att-comdev / armada

This project has moved to OpenStack.
https://www.airshipit.org/
Apache License 2.0
78 stars 35 forks source link

Deploying simple service get UnicodeDecodeError: 'utf-8' error #195

Closed joeyee2015 closed 6 years ago

joeyee2015 commented 6 years ago

Is this a bug report or feature request? (choose one): Bug

Python Version (output of python --version): Python3.5

Development or Deployment Environment?: Development

Release Tag or Master: Master

Expected Behavior: When executing command: docker exec armada armada apply /example/simple.yaml, we expect it will deploy charts success.

What Actually Happened: I get the error message like this:

2018-03-17 17:00:14.744 1696 ERROR armada.cli [-] Caught internal exception: armada.exceptions.chartbuilder_exceptions.HelmChartBuildException: Failed to build Helm chart for blog-1.
2018-03-17 17:00:14.744 1696 ERROR armada.cli Traceback (most recent call last):
2018-03-17 17:00:14.744 1696 ERROR armada.cli   File "/usr/local/lib/python3.5/site-packages/armada/handlers/chartbuilder.py", line 246, in get_helm_chart
2018-03-17 17:00:14.744 1696 ERROR armada.cli     files=self.get_files())
2018-03-17 17:00:14.744 1696 ERROR armada.cli   File "/usr/local/lib/python3.5/site-packages/armada/handlers/chartbuilder.py", line 172, in get_files
2018-03-17 17:00:14.744 1696 ERROR armada.cli     _append_file_to_result(root, rel_folder_path, file)
2018-03-17 17:00:14.744 1696 ERROR armada.cli   File "/usr/local/lib/python3.5/site-packages/armada/handlers/chartbuilder.py", line 157, in _append_file_to_result
2018-03-17 17:00:14.744 1696 ERROR armada.cli     file_contents = f.read().encode('utf-8').strip()
2018-03-17 17:00:14.744 1696 ERROR armada.cli   File "/usr/local/lib/python3.5/codecs.py", line 321, in decode
2018-03-17 17:00:14.744 1696 ERROR armada.cli     (result, consumed) = self._buffer_decode(data, self.errors, final)
2018-03-17 17:00:14.744 1696 ERROR armada.cli UnicodeDecodeError: 'utf-8' codec can't decode byte 0xac in position 13: invalid start byte

How to Reproduce the Issue (as minimally as possible): executing command: docker exec armada armada apply /example/hello.yaml, and if exists the file: .git/index on the gitlab(.git/index character encoding is latin1). I have push the example on gitlab: https://github.com/joeyee2015/hello-world-chart.git

# hello.yaml
---
schema: armada/Chart/v1
metadata:
  schema: metadata/Document/v1
  name: blog-1
data:
  chart_name: blog-1
  release: blog-1
  namespace: default
  values: {}
  source:
    type: git
    location: https://github.com/joeyee2015/hello-world-chart.git
    subpath: .
    reference: master
  dependencies: []
---
schema: armada/ChartGroup/v1
metadata:
  schema: metadata/Document/v1
  name: blog-group
data:
  description: Deploys Simple Service
  sequenced: False
  chart_group:
    - blog-1
---
schema: armada/Manifest/v1
metadata:
  schema: metadata/Document/v1
  name: simple-armada
data:
  release_prefix: armada
  chart_groups:
    - blog-group

Any Additional Comments: I try to modify file: ${armada_dir}/armada/handlers/chartbuilder.py at line 156

            def _append_file_to_result(root, rel_folder_path, file):
            abspath = os.path.abspath(os.path.join(root, file))
            relpath = os.path.join(rel_folder_path, file)

            with open(abspath, 'r') as f:
                try:    //add
                    file_contents = f.read().encode('utf-8')
                except:    //add
                    file_contents = f.read().encode('latin1')   //add

rebuild armada, and run armada local, it works.