Skip to content
This repository has been archived by the owner on Mar 13, 2022. It is now read-only.

Commit

Permalink
It is now actually working :)
Browse files Browse the repository at this point in the history
  • Loading branch information
dovreshef committed Jul 18, 2018
1 parent 3c882ef commit d39b3bb
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions config/exec_provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,23 +51,25 @@ def run(self, previous_response=None):
self.env['KUBERNETES_EXEC_INFO'] = json.dumps(kubernetes_exec_info)
process = subprocess.Popen(
self.args,
stdin=subprocess.PIPE,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
env=self.env)
process.wait()
if process.returncode != 0:
msg = 'exec: process returned %d' % process.returncode
stderr = process.stderr.read().strip()
env=self.env,
universal_newlines=True)
(stdout, stderr) = process.communicate()
exit_code = process.wait()
if exit_code != 0:
msg = 'exec: process returned %d' % exit_code
stderr = stderr.strip()
if stderr:
msg += '. %s' % stderr
raise ConfigException(msg)
stdout = process.stdout.read()
stdout = stdout
try:
data = json.loads(stdout)
except json.decoder.JSONDecodeError as de:
raise ConfigException(
'exec: failed to decode process output: %s' % de)
if all(k in data for k in ('apiVersion', 'kind', 'status')):
if not all(k in data for k in ('apiVersion', 'kind', 'status')):
raise ConfigException(
'exec: malformed response. plugin returned: %s' % stdout)
if data['apiVersion'] != self.api_version:
Expand Down

0 comments on commit d39b3bb

Please sign in to comment.