Commit graph

59 commits

Author SHA1 Message Date
Sebastiaan van Stijn
37cbdeb1f2
libnetwork: remove most of kvstore
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-07-25 22:20:18 +02:00
Sebastiaan van Stijn
4c4149a09c
libnetwork/internal/kvstore: remove unused Delete()
All code is using the atomic alternatives (AtomicDelete)

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-07-05 12:30:20 +02:00
Sebastiaan van Stijn
4d09e60f5b
libnetwork/internal/kvstore: remove unused Watch() method
The BoltDB store is not Watchable, and the Watch function was never used,
so we can remove it.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-07-05 12:30:20 +02:00
Sebastiaan van Stijn
e21e802fc6
libnetwork/datastore: remove unused DeleteTree() method
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-07-05 12:30:20 +02:00
Sebastiaan van Stijn
b32e41f016
libnetwork/internal/kvstore/boltdb: un-export Mutex
Keep the mutex internal to BoltDB.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-07-05 12:30:19 +02:00
Sebastiaan van Stijn
7e7c7bbc17
libnetwork/internal/kvstore/boltdb: BoltDB.List(): minor cleanup
cleanup the code to be slightly more idiomatic

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-07-05 12:30:19 +02:00
Sebastiaan van Stijn
95b96eebdd
libnetwork/internal/kvstore/boltdb: BoltDB.Get(): don't shadow error
Don't shadow the original error if we got one.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-07-05 12:30:19 +02:00
Sebastiaan van Stijn
fb61b07bcf
libnetwork/internal/kvstore/boltdb: BoltDB.Exists(): fix error handling
This function could potentially return "true" even if an error was returned.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-07-05 12:30:18 +02:00
Sebastiaan van Stijn
c94ccd4207
libnetwork/internal/kvstore/boltdb: minor cleanup/refactor
Make the code slightly more idiomatic; remove some "var" declarations,
remove some intermediate variables and redundant error-checks, and remove
the filePerm const.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-07-05 12:30:18 +02:00
Sebastiaan van Stijn
acfd3934a7
libnetwork/internal/kvstore: AtomicDelete(): remove unused "deleted" return
This boolean was not used anywhere, so we can remove it. Also cleaning up
the implementation a bit.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-07-05 12:30:18 +02:00
Sebastiaan van Stijn
b576682bdc
libnetwork/internal/kvstore: AtomicPut(): remove unused "created" return
This boolean was not used anywhere, so we can remove it.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-07-05 12:30:18 +02:00
Sebastiaan van Stijn
c37b58bbc3
libnetwork/internal/kvstore: remove unused WriteOptions
The WriteOptions struct was only used to set the "IsDir" option. This option
was added in d635a8e32b
and was only supported by the etcd libkv store.

The BoltDB store does not support this option, making the WriteOptions
struct fully redundant.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-07-05 12:30:18 +02:00
Sebastiaan van Stijn
e515bef423
libnetwork/internal/kvstore: remove unused WatchTree and NewLock methods
These were not used, and not implemented by the BoltDB store.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-07-05 12:30:18 +02:00
Sebastiaan van Stijn
a373983a86
libnetwork/internal/kvstore: fix some linting issues
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-07-05 12:30:17 +02:00
Sebastiaan van Stijn
05988f88b7
libnetwork/internal/kvstore: remove unused Config options
The only remaining kvstore is BoltDB, which doesn't use TLS connections
or authentication, so we can remove these options.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-07-05 12:30:17 +02:00
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