-
Notifications
You must be signed in to change notification settings - Fork 4.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add an option to register services and their checks idempotently #4905
Add an option to register services and their checks idempotently #4905
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, but a few changes:
- handle properly '?idempotent' query param
- add documentation
agent/agent_endpoint.go
Outdated
@@ -890,8 +890,15 @@ func (s *HTTPServer) AgentRegisterService(resp http.ResponseWriter, req *http.Re | |||
} | |||
|
|||
// Add the service. | |||
if err := s.agent.AddService(ns, chkTypes, true, token, ConfigSourceRemote); err != nil { | |||
return nil, err | |||
idempotent, _ := strconv.ParseBool(req.URL.Query().Get("idempotent")) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For the sake of consistency with other Consul APIs, you might check for parameter being present as true (similar to what is done in '&passing' or '&stale' for instance) (but handle false as you do still)
/agent/service/register => idempotent=false
/agent/service/register?idempotent => idempotent=true
/agent/service/register?idempotent=true => idempotent=true
/agent/service/register?idempotent=false => idempotent=false
e2f870e
to
64d7748
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
64d7748
to
985e731
Compare
@i0rek done |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for your work - I left a couple of comments, nothing major though! 🙏
@Aestek I left a couple of comments earlier. just making sure you saw that. |
@Aestek Can you fix the remaining issues? |
985e731
to
f3b2db9
Compare
@i0rek done (: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @Aestek, just have a few comments inline.
f3b2db9
to
700c4e8
Compare
thx @freddygv, fixed except the last point. |
700c4e8
to
b2a103b
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Aestek I'm seeing a timeout in the following test when running it locally and in CI:
TestAgent_RegisterService_ReRegister_ReplaceExistingChecks
Can you please look into it? I ran it locally with:
go test -v -run TestAgent_RegisterService_ReRegister_ReplaceExistingChecks ./agent
Also, I found some outdated references to remove-old-checks
, so I made some suggestions inline.
Hi @pierresouchay and @Aestek, can you please take a look at the test mentioned above. We can get this merged once that's fixed. |
b2a103b
to
dd138aa
Compare
@freddygv Done ! The test was indeed hanging, a rebase miskate. This is fixed now |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
@Aestek we had to stop merging into |
When registering several times a service on a local Agent using `/v1/agent/service/register`, if checks are removed, those checks are not removed from the service. This change adds the option to be idempotent when registering services and makes sure only specified checks are registered for the service.
dd138aa
to
080008d
Compare
@freddygv done |
Thx ! |
…th central config enabled Also: * Finished threading replaceExistingChecks setting (from GH-4905) through service manager. * Respected the original configSource value that was used to register a service or a check when restoring persisted data. * Run several existing tests with and without central config enabled (not exhaustive yet). * Switch to ioutil.ReadFile for all types of agent persistence. Fixes #6323
…th central config enabled Also: * Finished threading replaceExistingChecks setting (from GH-4905) through service manager. * Respected the original configSource value that was used to register a service or a check when restoring persisted data. * Run several existing tests with and without central config enabled (not exhaustive yet). * Switch to ioutil.ReadFile for all types of agent persistence. Fixes #6323
It looks like the docs say
Should the docs be updated to say that the value should be Also, how might this be added to the
Can this be an option that's passed in |
@fastest963 thanks, well spotted it does look like we should at least update the docs and add this to the |
…th central config enabled Also: * Finished threading replaceExistingChecks setting (from GH-4905) through service manager. * Respected the original configSource value that was used to register a service or a check when restoring persisted data. * Run several existing tests with and without central config enabled (not exhaustive yet). * Switch to ioutil.ReadFile for all types of agent persistence.
…th central config enabled (#6472) Also: * Finished threading replaceExistingChecks setting (from GH-4905) through service manager. * Respected the original configSource value that was used to register a service or a check when restoring persisted data. * Run several existing tests with and without central config enabled (not exhaustive yet). * Switch to ioutil.ReadFile for all types of agent persistence.
…th central config enabled (#6472) Also: * Finished threading replaceExistingChecks setting (from GH-4905) through service manager. * Respected the original configSource value that was used to register a service or a check when restoring persisted data. * Run several existing tests with and without central config enabled (not exhaustive yet). * Switch to ioutil.ReadFile for all types of agent persistence.
Fixes point
#1
of: #4903When registering several times a service on a local Agent using
/v1/agent/service/register
, if checks are removed, those checks are notremoved from the service.
This change adds the option to be idempotent when registering services
and makes sure only specified checks are registered for the service when specifying
&idempotent=true