Commit graph

44 commits

Author SHA1 Message Date
Sebastiaan van Stijn
e60cda7051
libnetwork/internal/kvstore/boltdb: fix linting issues
libnetwork/internal/kvstore/boltdb/boltdb.go:452:28: unnecessary conversion (unconvert)
                _ = bucket.Delete([]byte(key))
                                        ^
    libnetwork/internal/kvstore/boltdb/boltdb.go:425:2: S1023: redundant `return` statement (gosimple)
        return
        ^

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-06-26 20:52:04 +02:00
Sebastiaan van Stijn
d18b89ced6
libnetwork/internal/kvstore: remove some unused code
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-06-26 20:51:53 +02:00
Sebastiaan van Stijn
5d25143ef3
libnetwork/kvstore: rewrite code for new location
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-06-26 20:49:52 +02:00
Sebastiaan van Stijn
3887475971
Integrate github.com/docker/libkv
A reduced set of the dependency, only taking the parts that are used. Taken from
upstream commit: dfacc563de

    # install filter-repo (https://github.com/newren/git-filter-repo/blob/main/INSTALL.md)
    brew install git-filter-repo

    cd ~/projects

    # create a temporary clone of docker
    git clone https://github.com/docker/libkv.git temp_libkv
    cd temp_libkv

    # create branch to work with
    git checkout -b migrate_libkv

    # remove all code, except for the files we need; rename the remaining ones to their new target location
    git filter-repo --force \
        --path libkv.go \
        --path store/store.go \
        --path store/boltdb/boltdb.go \
        --path-rename libkv.go:libnetwork/internal/kvstore/kvstore_manage.go \
        --path-rename store/store.go:libnetwork/internal/kvstore/kvstore.go \
        --path-rename store/boltdb/:libnetwork/internal/kvstore/boltdb/

    # go to the target github.com/moby/moby repository
    cd ~/projects/docker

    # create a branch to work with
    git checkout -b integrate_libkv

    # add the temporary repository as an upstream and make sure it's up-to-date
    git remote add temp_libkv ~/projects/temp_libkv
    git fetch temp_libkv

    # merge the upstream code, rewriting "pkg/symlink" to "symlink"
    git merge --allow-unrelated-histories --signoff -S temp_libkv/migrate_libkv

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-06-26 20:47:08 +02:00
Cory Snider
9e3a6ccf69 libn/i/setmatrix: make generic and constructorless
Allow SetMatrix to be used as a value type with a ready-to-use zero
value. SetMatrix values are already non-copyable by virtue of having a
mutex field so there is no harm in allowing non-pointer values to be
used as local variables or struct fields. Any attempts to pass around
by-value copies, e.g. as function arguments, will be flagged by go vet.

Signed-off-by: Cory Snider <csnider@mirantis.com>
2023-03-29 13:31:12 -04:00
Cory Snider
09d39c023c libnetwork/i/setmatrix: devirtualize
There is only one implementation. Get rid of the interface.

Signed-off-by: Cory Snider <csnider@mirantis.com>
2023-03-14 18:09:08 -04:00
Cory Snider
34303ccd55 libnetwork/i/setmatrix: un-embed the mutex
so that it cannot be accessed outside of the package.

Signed-off-by: Cory Snider <csnider@mirantis.com>
2023-03-14 17:49:59 -04:00
Sebastiaan van Stijn
427ad30c05
libnetwork: remove unused "testutils" imports
Perhaps the testutils package in the past had an `init()` function to set up
specific things, but it no longer has. so these imports were doing nothing.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2021-08-18 14:20:37 +02:00
Brian Goff
a0a473125b Fix libnetwork imports
After moving libnetwork to this repo, we need to update all the import
paths for libnetwork to point to docker/docker/libnetwork instead of
docker/libnetwork.
This change implements that.

Signed-off-by: Brian Goff <cpuguy83@gmail.com>
2021-06-01 21:51:23 +00:00
John Howard
ea4dd1bbf6 boltdb/bolt is not maintained. Used bbolt
Signed-off-by: John Howard <jhoward@microsoft.com>
2018-09-11 12:42:39 -07:00
Flavio Crisciani
204ce3e31d Create internal directory
Internal directory is designed to contain libraries
that are exclusively used by this project

Signed-off-by: Flavio Crisciani <flavio.crisciani@docker.com>
2018-07-16 17:34:20 -07:00
Alessandro Boch
6c0e0d6250 Allow client to set boltdb timeout
- also in case of no persistent connection

Signed-off-by: Alessandro Boch <aboch@docker.com>
2016-11-08 16:51:51 -08:00
Jana Radhakrishnan
a0f6d0798a Do not return boltdb bucket not found error
While doing a boltdb operation and if the bucket is not found
we should not return a boltdb specific bucket not found error
because this causes leaky abstraction where in the user of libkv
needs to know about boltdb and import boltdb dependencies
neither of which is desirable. Replaced all the bucket not found
errors with the more generic `store.ErrKeyNotFound` error which
is more appropriate.

Signed-off-by: Jana Radhakrishnan <mrjana@docker.com>
2016-04-15 13:50:43 -07:00
Paul Seiffert
deb21faad0 Add support for etcd authentication 2016-03-31 14:55:59 +02:00
allencloud
cc0ed694ee fix typo
Signed-off-by: allencloud <allen.sun@daocloud.io>
2016-03-05 22:59:26 +08:00
Stefan Weil
fbdb24ec6a Fix typo in error text
The typo was found and fixed by codespell.

Signed-off-by: Stefan Weil <sw@weilnetz.de>
2016-02-23 22:40:39 +01:00
Alexandre Beslic
dcf8828165 Return store.ErrKeyExists on AtomicPut
When using AtomicPut with 'previous' set at nil, it interprets
that the Key should be created with the AtomicPut. Instead of
returning a generic error, we return store.ErrKeyExists if the
key exists in the store during the operation.

Signed-off-by: Alexandre Beslic <abronan@docker.com>
2015-10-14 09:51:18 -07:00
Santhosh Manohar
f06f78e638 boltDB AtomicDelete fails for non-existent key
Signed-off-by: Santhosh Manohar <santhosh@docker.com>
2015-10-03 02:25:19 -07:00
Jana Radhakrishnan
002f9c37ca Synchronize boltbd libkv apis
Currently boltdb uses a handle which can be accessed
concurrently from multiple go routines and all of them
trying to open and close the boldb db handle which can
cause havoc. Use a mutex to serialize db access and
handle access.

Signed-off-by: Jana Radhakrishnan <mrjana@docker.com>
2015-10-12 11:51:36 -07:00
Alexandre Beslic
2a86b2bdb9 Merge pull request #79 from sanimej/bolt
Add transient connection option to bolt db
2015-10-08 13:24:52 -07:00
Alexandre Beslic
1f587cf86c Merge pull request #77 from abronan/enhance_documentation
Update README.md and add more documentation under the 'docs' folder
2015-10-07 18:06:06 -07:00
Alexandre Beslic
15e5d4067a Change unsupported call error in boltdb backend to use general store error
Signed-off-by: Alexandre Beslic <abronan@docker.com>
2015-10-06 06:05:48 -07:00
Alexandre Beslic
3b5fb3ec87 Remove docs in libkv.go
Signed-off-by: Alexandre Beslic <abronan@docker.com>
2015-10-05 14:32:40 -07:00
Alexandre Beslic
2603af65e5 Migration to the new Etcd client
This commit migrates the old 'go-etcd' client, which is deprecated
to the new 'coreos/etcd/client'.

One notable change is the ability to specify an 'IsDir' parameter
to the 'Put' call. This allows to circumvent the limitations of etcd
regarding the key/directory distinction while setting up Watches on
a directory. A conservative measure to set up a watch that should be
used the same way for etcd/consul/zookeeper is to enforce the 'IsDir'
parameter with 'WriteOptions' on 'Put' to avoid the 'NotANode' error
thrown by etcd on Watch call. Consul and zookeeper are not using the
'IsDir' parameter.

Signed-off-by: Alexandre Beslic <abronan@docker.com>
2015-10-05 05:57:23 -07:00
Santhosh Manohar
0b81042dc3 Add transient connection option to bolt db
Signed-off-by: Santhosh Manohar <santhosh@docker.com>
2015-09-30 18:37:17 -07:00
Alexandre Beslic
7225aba3af add TTL to consul lock using store.LockOptions and add tests for the Lock ttl behavior
Signed-off-by: Alexandre Beslic <abronan@docker.com>
2015-09-23 02:22:02 -07:00
Chun Chen
1f9cf17713 Fix AtomicPut panic if previous KVPair is not nil and key not exists in boltdb
Signed-off-by: Chun Chen <ramichen@tencent.com>
2015-09-22 14:23:59 +08:00
Alexandre Beslic
599deba8c7 nits and refactor for etcd tls config
Signed-off-by: Alexandre Beslic <abronan@docker.com>
2015-09-17 09:13:45 -07:00
Adam Thornton
cc9e627f8e Add etcd TLS client code and update README.md.
Signed-off-by: Adam Thornton <adam.thornton@gonkulator.io>
2015-09-17 09:08:53 -07:00
Madhu Venugopal
64eb25dff9 Honoring ConnectionTimeout in boltdb
Signed-off-by: Madhu Venugopal <madhu@docker.com>
2015-09-16 10:52:11 -07:00
Alexandre Beslic
3ec6dfa346 Refactor libkv to not directly import storage backends
Signed-off-by: Alexandre Beslic <abronan@docker.com>
2015-09-07 10:43:01 -07:00
Chun Chen
f817826408 Create dir first before opening data file of boltdb
Signed-off-by: Chun Chen <ramichen@tencent.com>
2015-08-25 01:41:57 +08:00
Santhosh Manohar
29af4e0f27 BoltDB backend support for libkv
Signed-off-by: Santhosh Manohar <santhosh@docker.com>
2015-08-13 21:39:53 -07:00
Alexandre Beslic
06f01227c5 change heartbeat/ephemeral combination to use a single ttl field
Signed-off-by: Alexandre Beslic <abronan@docker.com>
2015-08-12 11:12:38 -07:00
Chun Chen
f26e4f4c52 Minor fix of store comment
Signed-off-by: Chun Chen <ramichen@tencent.com>
2015-08-12 18:32:56 +08:00
Alexandre Beslic
518ab82942 Merge pull request #39 from chenchun/better_error_msg
Notify user of supported backend storage
2015-08-11 11:59:53 -07:00
Chun Chen
6b43181cfa Notify user of supported backend storage
Signed-off-by: Chun Chen <ramichen@tencent.com>
2015-08-11 14:37:01 +08:00
Ahmet Alp Balkan
a961b70b2b Remove unused type WatchCallback
Signed-off-by: Ahmet Alp Balkan <ahmetalpbalkan@gmail.com>
2015-07-21 13:48:32 -07:00
Erik Hollensbe
06151b8a4d add top-level godoc: sample some parts of the README
Signed-off-by: Erik Hollensbe <github@hollensbe.org>
2015-06-25 00:05:57 +00:00
Spike Curtis
a2d4e1c246 API Change: AtomicPut with previous = nil is create.
AtomicPut can now be used to Compare-and-Swap against the state
where the key doesn't yet exist.  E.g. a race where two clients
create the same key: one succeeds, the other fails.

Pass nil for the previous argument of AtomicPut for this
behavior.  Before, this would cause an error.

Implements this change for all three backends.
2015-06-18 11:21:11 -07:00
Ahmet Alp Balkan
fcb98254b1 Use Backend type for stores
Signed-off-by: Ahmet Alp Balkan <ahmetalpbalkan@gmail.com>
2015-06-15 15:05:46 -07:00
Alexandre Beslic
79c320c1cf remove testify dependency through mock package
Signed-off-by: Alexandre Beslic <abronan@docker.com>
2015-06-12 15:54:16 -07:00
Antonio Murdaca
48f5dca2ce Remove logging in library
Signed-off-by: Antonio Murdaca <runcom@linux.com>
2015-06-13 00:08:33 +02:00
Alexandre Beslic
dbc1a6fa9a refactor and move store backends in sub-packages
Signed-off-by: Alexandre Beslic <abronan@docker.com>
2015-06-09 21:38:14 -07:00