@@ -116,8 +116,8 @@ func Run(cliCtx *cli.Context, cliApp *cli.App, configPath string, clickhouseBack
116
116
}
117
117
118
118
go func () {
119
- if err := api .UpdateBackupMetrics (context .Background (), false ); err != nil {
120
- log .Errorf ("UpdateBackupMetrics return error: %v" , err )
119
+ if metricsErr := api .UpdateBackupMetrics (context .Background (), false ); metricsErr != nil {
120
+ log .Errorf ("UpdateBackupMetrics return error: %v" , metricsErr )
121
121
}
122
122
}()
123
123
@@ -390,8 +390,8 @@ func (api *APIServer) actionsDeleteHandler(row status.ActionRow, args []string,
390
390
}
391
391
api .log .Info ("DELETED" )
392
392
go func () {
393
- if err := api .UpdateBackupMetrics (context .Background (), args [1 ] == "local" ); err != nil {
394
- api .log .Errorf ("UpdateBackupMetrics return error: %v" , err )
393
+ if metricsErr := api .UpdateBackupMetrics (context .Background (), args [1 ] == "local" ); metricsErr != nil {
394
+ api .log .Errorf ("UpdateBackupMetrics return error: %v" , metricsErr )
395
395
}
396
396
}()
397
397
actionsResults = append (actionsResults , actionsResultsRow {
@@ -417,7 +417,7 @@ func (api *APIServer) actionsAsyncCommandsHandler(command string, args []string,
417
417
return
418
418
}
419
419
go func () {
420
- if err := api .UpdateBackupMetrics (context .Background (), command == "create" || command == "restore " ); err != nil {
420
+ if err := api .UpdateBackupMetrics (context .Background (), command == "create" || strings . HasPrefix ( command , "restore" ) || command == "download " ); err != nil {
421
421
api .log .Errorf ("UpdateBackupMetrics return error: %v" , err )
422
422
}
423
423
}()
@@ -452,7 +452,7 @@ func (api *APIServer) actionsCleanRemoteBrokenHandler(w http.ResponseWriter, row
452
452
api .log .Warn (ErrAPILocked .Error ())
453
453
return actionsResults , ErrAPILocked
454
454
}
455
- commandId , ctx := status .Current .Start (command )
455
+ commandId , _ := status .Current .Start (command )
456
456
cfg , err := api .ReloadConfig (w , "clean_remote_broken" )
457
457
if err != nil {
458
458
status .Current .Stop (commandId , err )
@@ -466,10 +466,11 @@ func (api *APIServer) actionsCleanRemoteBrokenHandler(w http.ResponseWriter, row
466
466
return actionsResults , err
467
467
}
468
468
api .log .Info ("CLEANED" )
469
- metricsErr := api .UpdateBackupMetrics (ctx , false )
470
- if metricsErr != nil {
471
- api .log .Errorf ("UpdateBackupMetrics return error: %v" , metricsErr )
472
- }
469
+ go func () {
470
+ if metricsErr := api .UpdateBackupMetrics (context .Background (), false ); metricsErr != nil {
471
+ api .log .Errorf ("UpdateBackupMetrics return error: %v" , metricsErr )
472
+ }
473
+ }()
473
474
status .Current .Stop (commandId , nil )
474
475
actionsResults = append (actionsResults , actionsResultsRow {
475
476
Status : "success" ,
@@ -857,7 +858,7 @@ func (api *APIServer) httpCreateHandler(w http.ResponseWriter, r *http.Request)
857
858
return
858
859
}
859
860
860
- commandId , ctx := status .Current .Start (fullCommand )
861
+ commandId , _ := status .Current .Start (fullCommand )
861
862
go func () {
862
863
err , _ := api .metrics .ExecuteWithMetrics ("create" , 0 , func () error {
863
864
b := backup .NewBackuper (cfg )
@@ -869,12 +870,12 @@ func (api *APIServer) httpCreateHandler(w http.ResponseWriter, r *http.Request)
869
870
api .errorCallback (context .Background (), err , callback )
870
871
return
871
872
}
872
- if err := api . UpdateBackupMetrics ( ctx , true ); err != nil {
873
- api .log . Errorf ( "UpdateBackupMetrics return error: %v" , err )
874
- status . Current . Stop ( commandId , err )
875
- api . errorCallback ( context . Background (), err , callback )
876
- return
877
- }
873
+ go func () {
874
+ if metricsErr := api .UpdateBackupMetrics ( context . Background (), true ); metricsErr != nil {
875
+ api . log . Errorf ( "UpdateBackupMetrics return error: %v" , metricsErr )
876
+ }
877
+ }()
878
+
878
879
status .Current .Stop (commandId , nil )
879
880
api .successCallback (context .Background (), callback )
880
881
}()
@@ -1011,7 +1012,7 @@ func (api *APIServer) httpCleanRemoteBrokenHandler(w http.ResponseWriter, _ *htt
1011
1012
if err != nil {
1012
1013
return
1013
1014
}
1014
- commandId , ctx := status .Current .Start ("clean_remote_broken" )
1015
+ commandId , _ := status .Current .Start ("clean_remote_broken" )
1015
1016
defer status .Current .Stop (commandId , err )
1016
1017
1017
1018
b := backup .NewBackuper (cfg )
@@ -1021,13 +1022,11 @@ func (api *APIServer) httpCleanRemoteBrokenHandler(w http.ResponseWriter, _ *htt
1021
1022
api .writeError (w , http .StatusInternalServerError , "clean_remote_broken" , err )
1022
1023
return
1023
1024
}
1024
-
1025
- err = api .UpdateBackupMetrics (ctx , false )
1026
- if err != nil {
1027
- api .log .Errorf ("Clean remote broken error: %v" , err )
1028
- api .writeError (w , http .StatusInternalServerError , "clean_remote_broken" , err )
1029
- return
1030
- }
1025
+ go func () {
1026
+ if metricsErr := api .UpdateBackupMetrics (context .Background (), false ); metricsErr != nil {
1027
+ api .log .Errorf ("UpdateBackupMetrics return error: %v" , metricsErr )
1028
+ }
1029
+ }()
1031
1030
1032
1031
api .sendJSONEachRow (w , http .StatusOK , struct {
1033
1032
Status string `json:"status"`
@@ -1094,8 +1093,8 @@ func (api *APIServer) httpUploadHandler(w http.ResponseWriter, r *http.Request)
1094
1093
return
1095
1094
}
1096
1095
1097
- commandId , ctx := status .Current .Start (fullCommand )
1098
1096
go func () {
1097
+ commandId , ctx := status .Current .Start (fullCommand )
1099
1098
err , _ := api .metrics .ExecuteWithMetrics ("upload" , 0 , func () error {
1100
1099
b := backup .NewBackuper (cfg )
1101
1100
return b .Upload (name , diffFrom , diffFromRemote , tablePattern , partitionsToBackup , schemaOnly , resume , commandId )
@@ -1106,12 +1105,11 @@ func (api *APIServer) httpUploadHandler(w http.ResponseWriter, r *http.Request)
1106
1105
api .errorCallback (context .Background (), err , callback )
1107
1106
return
1108
1107
}
1109
- if err := api .UpdateBackupMetrics (ctx , false ); err != nil {
1110
- api .log .Errorf ("UpdateBackupMetrics return error: %v" , err )
1111
- status .Current .Stop (commandId , err )
1112
- api .errorCallback (context .Background (), err , callback )
1113
- return
1114
- }
1108
+ go func () {
1109
+ if metricsErr := api .UpdateBackupMetrics (context .Background (), false ); metricsErr != nil {
1110
+ api .log .Errorf ("UpdateBackupMetrics return error: %v" , metricsErr )
1111
+ }
1112
+ }()
1115
1113
status .Current .Stop (commandId , nil )
1116
1114
api .successCallback (context .Background (), callback )
1117
1115
}()
@@ -1289,8 +1287,8 @@ func (api *APIServer) httpDownloadHandler(w http.ResponseWriter, r *http.Request
1289
1287
return
1290
1288
}
1291
1289
1292
- commandId , ctx := status .Current .Start (fullCommand )
1293
1290
go func () {
1291
+ commandId , _ := status .Current .Start (fullCommand )
1294
1292
err , _ := api .metrics .ExecuteWithMetrics ("download" , 0 , func () error {
1295
1293
b := backup .NewBackuper (cfg )
1296
1294
return b .Download (name , tablePattern , partitionsToBackup , schemaOnly , resume , commandId )
@@ -1301,12 +1299,11 @@ func (api *APIServer) httpDownloadHandler(w http.ResponseWriter, r *http.Request
1301
1299
api .errorCallback (context .Background (), err , callback )
1302
1300
return
1303
1301
}
1304
- if err := api .UpdateBackupMetrics (ctx , true ); err != nil {
1305
- api .log .Errorf ("UpdateBackupMetrics return error: %v" , err )
1306
- status .Current .Stop (commandId , err )
1307
- api .errorCallback (context .Background (), err , callback )
1308
- return
1309
- }
1302
+ go func () {
1303
+ if metricsErr := api .UpdateBackupMetrics (context .Background (), true ); metricsErr != nil {
1304
+ api .log .Errorf ("UpdateBackupMetrics return error: %v" , metricsErr )
1305
+ }
1306
+ }()
1310
1307
status .Current .Stop (commandId , nil )
1311
1308
api .successCallback (context .Background (), callback )
1312
1309
}()
@@ -1351,8 +1348,8 @@ func (api *APIServer) httpDeleteHandler(w http.ResponseWriter, r *http.Request)
1351
1348
return
1352
1349
}
1353
1350
go func () {
1354
- if err := api .UpdateBackupMetrics (context .Background (), vars ["where" ] == "local" ); err != nil {
1355
- api .log .Errorf ("UpdateBackupMetrics return error: %v" , err )
1351
+ if metricsErr := api .UpdateBackupMetrics (context .Background (), vars ["where" ] == "local" ); metricsErr != nil {
1352
+ api .log .Errorf ("UpdateBackupMetrics return error: %v" , metricsErr )
1356
1353
}
1357
1354
}()
1358
1355
api .sendJSONEachRow (w , http .StatusOK , struct {
0 commit comments