This repository was archived by the owner on Mar 13, 2022. It is now read-only.
File tree 1 file changed +10
-8
lines changed
1 file changed +10
-8
lines changed Original file line number Diff line number Diff line change @@ -51,23 +51,25 @@ def run(self, previous_response=None):
51
51
self .env ['KUBERNETES_EXEC_INFO' ] = json .dumps (kubernetes_exec_info )
52
52
process = subprocess .Popen (
53
53
self .args ,
54
- stdin = subprocess .PIPE ,
54
+ stdout = subprocess .PIPE ,
55
55
stderr = subprocess .PIPE ,
56
- env = self .env )
57
- process .wait ()
58
- if process .returncode != 0 :
59
- msg = 'exec: process returned %d' % process .returncode
60
- stderr = process .stderr .read ().strip ()
56
+ env = self .env ,
57
+ universal_newlines = True )
58
+ (stdout , stderr ) = process .communicate ()
59
+ exit_code = process .wait ()
60
+ if exit_code != 0 :
61
+ msg = 'exec: process returned %d' % exit_code
62
+ stderr = stderr .strip ()
61
63
if stderr :
62
64
msg += '. %s' % stderr
63
65
raise ConfigException (msg )
64
- stdout = process . stdout . read ()
66
+ stdout = stdout
65
67
try :
66
68
data = json .loads (stdout )
67
69
except json .decoder .JSONDecodeError as de :
68
70
raise ConfigException (
69
71
'exec: failed to decode process output: %s' % de )
70
- if all (k in data for k in ('apiVersion' , 'kind' , 'status' )):
72
+ if not all (k in data for k in ('apiVersion' , 'kind' , 'status' )):
71
73
raise ConfigException (
72
74
'exec: malformed response. plugin returned: %s' % stdout )
73
75
if data ['apiVersion' ] != self .api_version :
You can’t perform that action at this time.
0 commit comments