Consul: how to update a tag value of service without impact the service and session ID in KV store?

Created on 16 Apr 2015  路  8Comments  路  Source: hashicorp/consul

two services were registered into the consul with different "tag" like "master" and "slave".

How to update these two tags without impact correspond services(these two services are also join the election via session acquiring ) and related session ID in the KV store ?

for now the way to me is to deregister them and re-register tags with the new value.But that will do great impaction to running services and their status.

Thanks,

Most helpful comment

Could the documentation be updated to reflect this? For the /v1/agent/service/register endpoint I see phrases like "Registers a new local service" and "You cannot have duplicate ID entries per agent ...".

Perhaps there could also be a new endpoint? /v1/agent/service/tags/<serviceId> could get a JSON array of tags sent via POST or PUT? When a GET is issued, the current tags could be retrieved? This would make it really easy for me to update a service's tags and I could check to see if they already match and skip POSTing the data.

Another alternative would be something along the lines of issuing a POST to /v1/agent/service/tags/<serviceId>/+<tag> and /v1/agent/service/tags/<serviceId>/-<tag>.

Like the user in issue #155, I would like to add a master tag to my mongodb instance as long as it is the master. In my ideal world I would have a tag based on a health check (run some command every X seconds; apply/remove a tag based on its result), though I don't see anything remotely like that.

All 8 comments

@deadjoe You can just re-register the services with the updated tags. No need to deregister first.

Could the documentation be updated to reflect this? For the /v1/agent/service/register endpoint I see phrases like "Registers a new local service" and "You cannot have duplicate ID entries per agent ...".

Perhaps there could also be a new endpoint? /v1/agent/service/tags/<serviceId> could get a JSON array of tags sent via POST or PUT? When a GET is issued, the current tags could be retrieved? This would make it really easy for me to update a service's tags and I could check to see if they already match and skip POSTing the data.

Another alternative would be something along the lines of issuing a POST to /v1/agent/service/tags/<serviceId>/+<tag> and /v1/agent/service/tags/<serviceId>/-<tag>.

Like the user in issue #155, I would like to add a master tag to my mongodb instance as long as it is the master. In my ideal world I would have a tag based on a health check (run some command every X seconds; apply/remove a tag based on its result), though I don't see anything remotely like that.

I split my last paragraph into a new suggestion instead of trying to hijack this one.

@armon is there a way to add tag with register atomically?
What if there are other changes in tags between initial register and re-register? Right now, I need to GET current tags with one call and PUT new tags in a second call. I could overwrite changes done by someone else by accident. How can I do it properly?

Hi all,

The API documentation has been updated to reflect these changes. If you see any places where we missed it, please let us know (or open a PR!) 馃槃

Hi @sethvargo,
which PR do you mean as these changes?

I know this is possible already, via the catalog API. But it would be nice if it was easier. E.g. a CLI command or an HTTP endpoint specifically for the tags.

/catalog/register is quite low-level, where basically either a node, service or check can be registered using the same endpoint. Or a combination all at once.

It's not the easiest one to use, especially if tags are to be used for ops, to change primary node etc. In these cases a simpler HTTP API or a CLI command would go a long way 馃槃

CLI commands are on the roadmap!

Was this page helpful?
0 / 5 - 0 ratings