We would like to use Consul as our central configuration management tool and as such, we would've expect to change some of the configuration keys atomically, at once.
This will make sure we don't experience bad flows occurring because one flag was set correctly to the expected value but the other one wasn't changed on time.
Is there any pattern which currently permits doing that?
At this time Consul doesn't support atomically writing more than one key. You could acquire separate locks on a few different keys and only release once all were acquired/written, but this is by no means atomic, and watches would not be coalesced. It's an interesting idea though, so I'll mark this as thinking for now.
@ryanuber Thanks, this feature will be much appreciated.
For anyone's interested: atomicity can also be achieved in the watcher handler level with an implementation close to the following:
Consider that there are N keys we would like to update atomically, at once:
Create each key value in the following format:
<value1>:1:N:<uuid>
<value2>:2:N:<uuid>
...
...
<valueN>:3:N:<uuid>
Where <valueN> is the actual value of the Nth key in the bulk and <uuid> is a unique identifier we assign to the bulk to differentiate it from other bulks.
The watcher handler keeps a map of uuids to a list of KVs.
When a KV update occurs, the handler peeks at it's value and seeks for the format mentioned above.
In case there's a match: it will add the KV to list of KVs which is mapped by the 'uuid'.
It will then check if this list reached the size of N (the handler knows what N is since its part of the above format as well).
If the list reached the bulk size then we can safely execute some action (in our use case it was a curl command which sends the the entire KV list in one bulk to a web server endpoint).
We are evaluating consul as a central configuration management system as well. For us it would be also important to update several keys atomically at once. So +1 for this feature.
We would love to see this implemented. I don't think it would necessarily need to be atomic. The basic idea is that it would be nice to have a way to update multiple key's that would affect the same file - in one go - and have the file be updated by consul only once.
We would like to see this feature as well. For us, the updates need not technically be atomic, but we'd like to see watches/events triggered or delivered only once for the batch of updates.
+1 for this.
We need this atomic multi-key update ability as well.
+1, we need something like bulk keys changes transaction possibility as well.
Lets also add some versioning if it is possible ;-) and we are done)
we now use git2consul ref key to watch on changes if someone needs something like workaround here.
This was implemented in https://github.com/hashicorp/consul/pull/2028!
Most helpful comment
This was implemented in https://github.com/hashicorp/consul/pull/2028!