@@ -46,15 +46,19 @@ func (e *DefaultADCExecutor) Execute(ctx context.Context, mode string, config ad
4646
4747func (e * DefaultADCExecutor ) runADC (ctx context.Context , mode string , config adcConfig , args []string ) error {
4848 for _ , addr := range config .ServerAddrs {
49- ctxWithTimeout , cancel := context .WithTimeout (ctx , 15 * time .Second )
50- defer cancel ()
51- if err := e .runForSingleServer (ctxWithTimeout , addr , mode , config , args ); err != nil {
49+ if err := e .runForSingleServerWithTimeout (ctx , addr , mode , config , args ); err != nil {
5250 return err
5351 }
5452 }
5553 return nil
5654}
5755
56+ func (e * DefaultADCExecutor ) runForSingleServerWithTimeout (ctx context.Context , serverAddr , mode string , config adcConfig , args []string ) error {
57+ ctx , cancel := context .WithTimeout (ctx , 15 * time .Second )
58+ defer cancel ()
59+ return e .runForSingleServer (ctx , serverAddr , mode , config , args )
60+ }
61+
5862func (e * DefaultADCExecutor ) runForSingleServer (ctx context.Context , serverAddr , mode string , config adcConfig , args []string ) error {
5963 cmdArgs := append ([]string {}, args ... )
6064 if ! config .TlsVerify {
@@ -108,6 +112,10 @@ func (e *DefaultADCExecutor) buildCmdError(runErr error, stdout, stderr []byte)
108112
109113func (e * DefaultADCExecutor ) handleOutput (output []byte ) error {
110114 var result adctypes.SyncResult
115+ if index := strings .IndexByte (string (output ), '{' ); index > 0 {
116+ log .Warnf ("extra output: %s" , string (output [:index ]))
117+ output = output [index :]
118+ }
111119 if err := json .Unmarshal (output , & result ); err != nil {
112120 log .Errorw ("failed to unmarshal adc output" ,
113121 zap .Error (err ),
0 commit comments