Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes issue with dynamically created array of pointers with cffi #586

Merged
merged 2 commits into from Aug 17, 2020

Conversation

sebradloff
Copy link
Contributor

@sebradloff sebradloff commented Aug 16, 2020

The helm_values_files is meant to be an array of pointers. Those pointers are references to strings which are helm values files to use in the golang code. As of now, I've gotten lucky that the bytes weren't freed any faster. I noticed that once I hit a string over 96 bytes that I was getting errors in the golang code saying it couldn't find the file which seems to no longer be properly encoded.

valueFiles: [/tmp/tmps8j31sc8.helm_values.yml /tmp/tmp8lbavsth.kapitan/compiled/monitoring-prd/helm_values_files_prometheus_new_and_this/commo�]
From golang!!!!!
valueFiles: [/tmp/tmps8j31sc8.helm_values.yml /tmp/tmp8lbavsth.kapitan/compiled/monitoring-prd/helm_values_files_prometheus_new_and_this/commo� /tmp/tmp8lbavsth.kapitan/compiled/monitoring-prd/helm_values_files_prometheus_new_and_this/common.yml]
Compile pool terminated
Unknown (Non-Kapitan) Error occurred
multiprocessing.pool.RemoteTraceback:
"""
Traceback (most recent call last):
  File "/usr/local/lib/python3.7/multiprocessing/pool.py", line 121, in worker
    result = (True, func(*args, **kwds))
  File "/src/kapitan/targets.py", line 448, in compile_target
    input_compiler.compile_obj(comp_obj, ext_vars, **kwargs)
  File "/src/kapitan/inputs/base.py", line 53, in compile_obj
    self.compile_input_path(input_path, comp_obj, ext_vars, **kwargs)
  File "/src/kapitan/inputs/base.py", line 75, in compile_input_path
    **kwargs,
  File "/src/kapitan/inputs/helm/__init__.py", line 98, in compile_file
    **self.helm_params,
  File "/src/kapitan/inputs/helm/__init__.py", line 190, in render_chart
    return error_message.decode("utf-8")  # empty if no error
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xa0 in position 101: invalid start byte
"""

Because the array of pointers in being dynamically created, I used the recommendation from the cffi docs and created a dict to hold pointer references so the data is not prematurely garbage collected.

@ramaro
Copy link
Member

ramaro commented Aug 17, 2020

Interesting find! Thank you.

@ramaro ramaro merged commit 59821bc into kapicorp:master Aug 17, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants