@@ -94,18 +94,21 @@ func BaseCommand() *serpent.Command {
94
94
}
95
95
}
96
96
97
+ func isChild () bool {
98
+ return os .Getenv ("CHILD" ) == "true"
99
+ }
100
+
97
101
// Run executes the boundary command with the given configuration and arguments
98
102
func Run (ctx context.Context , config Config , args []string ) error {
99
- isChild := os .Getenv ("CHILD" ) == "true"
100
- if isChild {
101
- log .Printf ("CHILD process is started" )
102
- vethNetJail := os .Getenv ("VETH_JAIL_NAME" )
103
+ if isChild () {
104
+ log .Printf ("boundary CHILD process is started" )
103
105
106
+ vethNetJail := os .Getenv ("VETH_JAIL_NAME" )
104
107
err := jail .SetupChildNetworking (vethNetJail )
105
108
if err != nil {
106
- return fmt .Errorf ("failed to run SetupChildNetworking : %v" , err )
109
+ return fmt .Errorf ("failed to setup child networking : %v" , err )
107
110
}
108
- log .Printf ("child networking is configured" )
111
+ log .Printf ("child networking is successfully configured" )
109
112
110
113
// Program to run
111
114
bin := args [0 ]
@@ -117,10 +120,9 @@ func Run(ctx context.Context, config Config, args []string) error {
117
120
cmd .Stderr = os .Stderr
118
121
err = cmd .Run ()
119
122
if err != nil {
120
- log .Printf ("failed to run %s: %v, output: %s " , bin , err , "output" )
123
+ log .Printf ("failed to run %s: %v" , bin , err )
121
124
return err
122
125
}
123
- log .Printf ("successfully run %s: %s" , bin , "output" )
124
126
125
127
return nil
126
128
}
@@ -227,18 +229,21 @@ func Run(ctx context.Context, config Config, args []string) error {
227
229
logger .Debug ("Executing command in boundary" , "command" , strings .Join (os .Args , " " ))
228
230
err := cmd .Start ()
229
231
if err != nil {
230
- logger .Error ("Command execution failed(Start)" , "error" , err )
232
+ logger .Error ("Command failed to start" , "error" , err )
233
+ return
231
234
}
232
235
233
236
err = boundaryInstance .ConfigureAfterCommandExecution (cmd .Process .Pid )
234
237
if err != nil {
235
- logger .Error ("configuration failed" , "error" , err )
238
+ logger .Error ("configuration after command execution failed" , "error" , err )
239
+ return
236
240
}
237
241
238
242
logger .Debug ("waiting on a child process to finish" )
239
243
err = cmd .Wait ()
240
244
if err != nil {
241
- logger .Error ("Command execution failed(Wait)" , "error" , err )
245
+ logger .Error ("Command execution failed" , "error" , err )
246
+ return
242
247
}
243
248
}()
244
249
0 commit comments