crowdsec icon indicating copy to clipboard operation
crowdsec copied to clipboard

apiclient: fix http roundtrip (clone body also)

Open he2ss opened this issue 3 years ago • 1 comments

This pr allows to retry properly the HTTP request when it receives a 401 HTTP code including the request body.

he2ss avatar Sep 16 '22 11:09 he2ss

Codecov Report

Merging #1758 (8130698) into master (fe23da6) will increase coverage by 0.03%. The diff coverage is 93.75%.

@@            Coverage Diff             @@
##           master    #1758      +/-   ##
==========================================
+ Coverage   53.73%   53.77%   +0.03%     
==========================================
  Files         151      151              
  Lines       20280    20301      +21     
==========================================
+ Hits        10898    10917      +19     
- Misses       8205     8206       +1     
- Partials     1177     1178       +1     
Flag Coverage Δ
func-crowdsec 47.07% <ø> (ø)
func-cscli 44.57% <ø> (-0.05%) :arrow_down:
unit-linux 58.37% <93.75%> (+0.15%) :arrow_up:
unit-windows 53.41% <93.75%> (-0.08%) :arrow_down:

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
pkg/apiclient/auth.go 78.31% <93.54%> (-0.46%) :arrow_down:
pkg/apiclient/client.go 77.31% <100.00%> (+0.23%) :arrow_up:
cmd/crowdsec-cli/machines.go 50.17% <0.00%> (-1.07%) :arrow_down:
pkg/acquisition/modules/docker/docker.go 61.51% <0.00%> (+0.24%) :arrow_up:
pkg/acquisition/modules/cloudwatch/cloudwatch.go 78.82% <0.00%> (+0.98%) :arrow_up:

:mega: We’re building smart automated test selection to slash your CI/CD build times. Learn more

codecov-commenter avatar Sep 16 '22 11:09 codecov-commenter

Need a fix server side too

sabban avatar Oct 18 '22 08:10 sabban

The PR is ready, the server side fixed is done.

he2ss avatar Nov 29 '22 11:11 he2ss

/kind enhancement /area agent

LaurenceJJones avatar Dec 06 '22 13:12 LaurenceJJones

Before merging, we need to test this behavior,

Having LAPI and agent separated then, restart LAPI and check if the agent can send a heartbeat.

he2ss avatar Dec 06 '22 14:12 he2ss

Before merging, we need to test this behavior,

Having LAPI and agent separated then, restart LAPI and check if the agent can send a heartbeat.

Tested,

INFO[12-12-2022 14:11:35] 127.0.0.1 - [Mon, 12 Dec 2022 14:11:35 CET] "GET /v1/heartbeat HTTP/1.1 401 91.671µs "crowdsec/v1.4.3-linux-9e6781aad2acc249e875e5dc64fd52d0cf9f842d" " 
INFO[12-12-2022 14:11:35] 127.0.0.1 - [Mon, 12 Dec 2022 14:11:35 CET] "POST /v1/watchers/login HTTP/1.1 200 63.247137ms "crowdsec/v1.4.3-linux-9e6781aad2acc249e875e5dc64fd52d0cf9f842d" " 
INFO[12-12-2022 14:11:35] 127.0.0.1 - [Mon, 12 Dec 2022 14:11:35 CET] "GET /v1/heartbeat HTTP/1.1 200 5.105604ms "crowdsec/v1.4.3-linux-9e6781aad2acc249e875e5dc64fd52d0cf9f842d" " 
INFO[12-12-2022 14:12:35] 127.0.0.1 - [Mon, 12 Dec 2022 14:12:35 CET] "GET /v1/heartbeat HTTP/1.1 200 20.727092ms "crowdsec/v1.4.3-linux-9e6781aad2acc249e875e5dc64fd52d0cf9f842d" "

It works fine.

he2ss avatar Dec 12 '22 14:12 he2ss