Skip to content
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

Grid manager proposal, updated to latest code and Python 3 #1206

Merged
merged 291 commits into from
Feb 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
291 commits
Select commit Hold shift + click to select a range
d0791eb
fix storage-client
meejah Dec 12, 2018
633f36a
Made A Decision, and start of 'admin add-grid-manager-cert' command
meejah Dec 18, 2018
08937c6
whitespace
meejah Dec 18, 2018
d302a98
'tahoe admin add-grid-manager-cert' command
meejah Dec 18, 2018
c88409a
add a note
meejah Mar 28, 2019
4665617
newsfragment
meejah Apr 9, 2019
2cf36cf
flake8
meejah Apr 9, 2019
cfda360
space-separated paths is a bad idea
meejah Apr 9, 2019
16e7bc5
pytest API
meejah Apr 9, 2019
9220dd1
get rid of debug
meejah Apr 9, 2019
3d70557
make and use set_config instead of internals
meejah Apr 9, 2019
f0e3b69
switch around how we do config (avoid space-separated filenames)
meejah Apr 9, 2019
f0a9240
cleanup
meejah Apr 9, 2019
11993a2
item -> value
meejah Apr 9, 2019
8e363ca
can't re-write a static string
meejah Apr 9, 2019
1b3bfd5
grid-manager client config is different
meejah May 14, 2019
883a3ba
no mutable defaults
meejah May 6, 2020
3af6d74
clarify further
meejah May 6, 2020
8e8b2f4
introducer-less -> introducerless
meejah May 6, 2020
235d5de
added example and more explanation for 'add'
meejah May 7, 2020
18fead0
consistently use 'nickname'
meejah May 7, 2020
4340cfa
decision made
meejah May 7, 2020
a98eae3
clarify
meejah May 7, 2020
fb3f0b7
more words about 'daemonize'
meejah May 7, 2020
7feed41
redundant webport
meejah May 7, 2020
6c15d67
'tahoe put' not 'tahoe mkdir'
meejah May 7, 2020
f1ae20a
spelling
meejah May 7, 2020
65403eb
alice -> zara, bob -> yakov and docstrings
meejah May 7, 2020
97a7672
.has_key -> 'in'
meejah May 7, 2020
5071da2
remove early return
meejah May 7, 2020
72a51e9
docstring
meejah May 7, 2020
371fcd5
timeouts not required
meejah May 7, 2020
c823ff1
better docstring
meejah May 7, 2020
4ece4e9
specific exception for failing subprocess
meejah May 7, 2020
4fc649f
error to create a duplicate node
meejah May 7, 2020
dfa8b37
irrelevant code
meejah May 7, 2020
85d8e24
ascii -> utf8
meejah May 7, 2020
c9f5ed7
redundant
meejah May 7, 2020
7cb7cdf
method instead of nested function
meejah May 7, 2020
c0f0d76
parametrize 'now' function
meejah May 7, 2020
026bcca
upload_permitted in IServer
meejah May 7, 2020
a384df7
link to docs
meejah May 7, 2020
ac46fb2
take -> require
meejah May 7, 2020
92bd22f
reword
meejah May 7, 2020
60fea95
Merge branch 'master' into 2916.grid-manager-proposal.5
meejah May 8, 2020
91af588
post-merge fixups (keyutil, preferred_peers)
meejah May 8, 2020
38069e5
keyutil -> ed25519
meejah May 8, 2020
e6cb700
incorrect merge conflict-resolution
meejah May 8, 2020
02c3401
make code more like master
meejah May 8, 2020
765d9da
keyutil -> ed25519
meejah May 8, 2020
37a23d8
debug
meejah May 8, 2020
5e1e90d
pass on stdin=
meejah May 8, 2020
f21c1f4
pass on request arg
meejah May 8, 2020
fea9fc0
fix more keyutil -> ed25519
meejah May 8, 2020
5bd5d81
kill process
meejah May 8, 2020
0bdfae8
actually put grid-manager-certificates in announcement
meejah May 8, 2020
38e6557
fix imports
meejah May 8, 2020
975491b
allow 'anything valid' sections
meejah May 8, 2020
c029698
fix more keyutil things and key-handling in test
meejah May 8, 2020
0540df8
Re-factor grid fixtures to be mostly helpers
meejah May 10, 2020
9a62b1f
cleanup is non-optional
meejah May 11, 2020
a9fe120
docs
meejah May 11, 2020
c5fb2b5
refactor more code into grid.py
meejah May 12, 2020
c9de1ee
add a .restart() to Client and StorageServer
meejah May 12, 2020
f52cd43
set the stage for the example in the intro
meejah May 12, 2020
7c8a7f9
better re-start
meejah May 12, 2020
aa2066e
move imports
meejah May 12, 2020
114c2fa
oops
meejah May 12, 2020
d4e2c66
use eliot logging
meejah May 13, 2020
9c89100
Merge master
meejah Oct 2, 2020
b13a688
better words
meejah Oct 2, 2020
b0d48dd
don't need to create section
meejah Oct 2, 2020
6b791cb
nicer error
meejah Oct 2, 2020
e65b6ba
no default named 'default'
meejah Oct 2, 2020
8deddc6
no defaults
meejah Oct 2, 2020
2483e93
tahoe add-grid-manager is only 'idea' currently
meejah Oct 2, 2020
d46c35e
grid-manager unit-tests
meejah Oct 2, 2020
6a2f1ae
use 'tahoe admin add-grid-manager-cert' in tests
meejah Oct 4, 2020
5eb1ad9
fix 'admin add-grid-manager-cert'
meejah Oct 4, 2020
370d4b0
load certs as well as keys in utest
meejah Oct 4, 2020
c43c84b
fewer files in test
meejah Oct 5, 2020
84c9da4
unused
meejah Oct 5, 2020
c439555
more gridmanager tests
meejah Oct 5, 2020
774ab72
test user-management on files
meejah Oct 5, 2020
bf45f57
minor fixes
meejah Oct 5, 2020
c65a01f
flake8
meejah Oct 5, 2020
817eef2
typo
meejah Oct 20, 2020
91e1fa3
correct config section
meejah Oct 20, 2020
6ea3c68
encoded -> tahoe-encoded
meejah Oct 30, 2020
f923144
re-factor; use a predicate instead of expanding NativeStorageServer
meejah Nov 7, 2020
30b7be6
remove integration tests/refactoring
meejah Nov 7, 2020
c7f4a1a
factor to use FilePath more
meejah Nov 7, 2020
2118a24
grid-manager stand-alone, via Click
meejah Nov 7, 2020
d096908
spelling
meejah Nov 7, 2020
a8382a5
cleanup, more tests
meejah Nov 7, 2020
41fa823
more unittests
meejah Nov 7, 2020
25ff7c6
Merge branch 'master' into 2916.grid-manager-proposal.5
meejah Nov 13, 2020
f3d530f
grid-manager CLI tests
meejah Nov 14, 2020
6e1bb1e
grid-manager CLI tests
meejah Nov 14, 2020
b6fbfee
more utests
meejah Nov 14, 2020
32b19fa
flake8
meejah Nov 14, 2020
c7f4f36
merge config
meejah Nov 14, 2020
45128f4
more works on config
meejah Nov 14, 2020
5b4f5e8
explicit unicode
meejah Nov 14, 2020
c58dd36
eliot changes
meejah Nov 14, 2020
bab77ed
function not method
meejah Nov 14, 2020
0af033b
use filepath
meejah Nov 14, 2020
15e33f8
undo a wording change
meejah Nov 14, 2020
1ccc074
docstring
meejah Nov 14, 2020
51b5217
docstring
meejah Nov 14, 2020
3a552f6
don't ned this test
meejah Nov 14, 2020
cb6ed4c
flake8
meejah Nov 14, 2020
7fa0f64
better assert
meejah Nov 14, 2020
f3b3341
better-ize test
meejah Nov 14, 2020
f6f53ad
proper spot
meejah Nov 14, 2020
885f72f
decisions
meejah Nov 16, 2020
409e9bd
file tickets for unimplemented commands
meejah Nov 16, 2020
019772a
typo
meejah Nov 16, 2020
a34093e
fix some test-ability problems and add tests for 'tahoe admin add-gri…
meejah Nov 16, 2020
6e77eba
test another path
meejah Nov 16, 2020
3b3b958
tempdir should be native-string
meejah Nov 16, 2020
d34c32c
cleanup / review
meejah Nov 17, 2020
800497a
refactor load_grid_manager() to better present errors (review)
meejah Nov 17, 2020
32625bf
tahoe grid-manager -> grid-manager
meejah Nov 17, 2020
eb11809
introduction (review)
meejah Nov 17, 2020
61f348f
clarify
meejah Nov 17, 2020
649cb93
move proposals out
meejah Nov 17, 2020
938cc56
refactor (review): move grid-manager certificate loading code out of cli
meejah Nov 18, 2020
72f2e25
ask forgiveness not permission
meejah Nov 24, 2020
1e1aad8
save only fails sometimes
meejah Nov 24, 2020
a98d784
timedelta, not seconds
meejah Nov 24, 2020
d1adbe0
unused
meejah Nov 24, 2020
a213819
sign uses timedelta
meejah Nov 24, 2020
1b53135
test create-twice
meejah Nov 24, 2020
42b7d39
check public key / server-id
meejah Nov 24, 2020
da0fe23
_load_grid_manager_certificates -> method
meejah Nov 24, 2020
a0a39d3
Merge remote-tracking branch 'origin/master' into 2916.grid-manager-p…
meejah Nov 26, 2020
4450a7a
better words
meejah Nov 26, 2020
884c264
flake8
meejah Nov 26, 2020
4b5db76
Merge remote-tracking branch 'origin/master' into 2916.grid-manager-p…
meejah Dec 1, 2020
ca5a642
Merge remote-tracking branch 'origin/master' into HEAD
exarkun Dec 8, 2020
706d308
create directories on save
meejah Dec 14, 2020
bf799c1
Merge branch 'master' into 2916.grid-manager-proposal.5
meejah Dec 14, 2020
38968b4
correct merge resolution
meejah Dec 14, 2020
4884f81
brackets are important
meejah Dec 14, 2020
4fe65a8
brackets are hard
meejah Dec 14, 2020
bd46ff2
windows-only checks
meejah Dec 15, 2020
fbddff3
link grid-manager into the ToC
meejah Dec 21, 2020
e38a1c3
two colons
meejah Dec 21, 2020
f4164aa
missed a new arg
meejah Dec 21, 2020
07180b2
spelling
meejah Dec 21, 2020
d267bb3
leftover comment
meejah Dec 21, 2020
24ac2c6
I guess only OSError we care about?
meejah Dec 21, 2020
361acc2
irrelevant comment
meejah Dec 21, 2020
bfd45d3
typo
meejah Dec 21, 2020
5d4253b
reject a bunch of invalid signatures
meejah Dec 21, 2020
5eff6f9
add a few docstrings for accessors etc
meejah Dec 21, 2020
d31d8e1
module docstring
meejah Dec 21, 2020
80c68a4
cover more error-cases
meejah Dec 21, 2020
613a6f8
Merge branch 'master' into 2916.grid-manager-proposal.5
meejah Jan 4, 2021
30e3cd2
un-writable directory test
meejah Jan 4, 2021
66de141
test: list certs from stdin
meejah Jan 4, 2021
6c9632b
test: missing cert from config is reported
meejah Jan 4, 2021
dbf385b
test: missing config section
meejah Jan 5, 2021
2223902
test: invalid cert key
meejah Jan 5, 2021
7783f31
tests for 'tahoe admin add-grid-manager-cert'
meejah Jan 5, 2021
c0f0076
undo
meejah Jan 5, 2021
7d30bd5
test: announcements contain grid-manager certs
meejah Jan 5, 2021
2dc6c5f
add a gm cert in the client test
meejah Jan 19, 2021
307a53d
Merge branch 'master' into 2916.grid-manager-proposal.5
meejah Jan 21, 2021
6560621
cover 'second certificate' codepath
meejah Jan 21, 2021
a2f0f65
order not important
meejah Jan 22, 2021
66d4118
I know know how permissions work on linux
meejah Jan 22, 2021
75db6f3
relax test
meejah Jan 22, 2021
7aaf86a
flake8 cleanup
meejah Jan 25, 2021
3c64699
Merge branch 'master' into 2916.grid-manager-proposal.5
meejah Jan 25, 2021
87c78fd
use plain TestCase (fix eliot tests, maybe)
meejah Jan 26, 2021
8bb83e7
actually not-equal
meejah Jan 26, 2021
49838af
Merge branch 'master' into 2916.grid-manager-proposal.5
meejah Feb 2, 2021
4a5bb5e
Merge branch 'master' into 2916.grid-manager-proposal.5
meejah Mar 23, 2021
7ad6c92
Merge branch 'master' into 2916.grid-manager-proposal.5
meejah Aug 25, 2021
7fa1801
Pass tests on Python 2.
itamarst Aug 26, 2021
e23767d
Tests pass on Python 2 and Python 3.
itamarst Aug 26, 2021
969f3fa
Port to Python 3.
itamarst Aug 26, 2021
6df4fa3
Add explicit dependency on Click.
itamarst Aug 26, 2021
c7f0a09
More compatibility with stdlib json module.
itamarst Aug 26, 2021
c3f6184
Match documented behavior.
itamarst Aug 26, 2021
c88130d
Make signed certificates an object instead of a dict.
itamarst Aug 26, 2021
e3a844e
Maybe fields are better off as bytes in SignedCertificate.
itamarst Aug 27, 2021
f99f9cf
Tests pass on Python 3.
itamarst Aug 27, 2021
bb48974
Ported to Python 3.
itamarst Aug 27, 2021
d5b48e6
Fix bug in jsonbytes.
itamarst Aug 27, 2021
4c750cf
Port to Python 3.
itamarst Aug 27, 2021
c0d07e1
Bit more input validation.
itamarst Aug 27, 2021
1acc80b
Validate commands actually succeeded!
itamarst Aug 27, 2021
aacdf99
Make failures easier to debug.
itamarst Aug 27, 2021
6bfcda2
Tests pass on Python 3.
itamarst Aug 27, 2021
e8e0ecd
Port to Python 3.
itamarst Aug 27, 2021
2d2e805
Port to Python 3.
itamarst Aug 27, 2021
75ba5c7
More passing tests on Python 3.
itamarst Aug 27, 2021
b9a1cc3
Pacify flake8.
itamarst Aug 30, 2021
056f774
Fix errant str()-of-bytes bug.
itamarst Aug 30, 2021
1ede0e7
Merge remote-tracking branch 'meejah/2916.grid-manager-proposal.5' in…
pythonspeed Jul 15, 2022
b3ab2fd
Fix grid manager CLI tests.
pythonspeed Jul 15, 2022
b4703ac
Some tweaks for Python 3.
pythonspeed Jul 18, 2022
d84d366
Some tweaks for Python 3 and modern attrs.
pythonspeed Jul 18, 2022
90188ce
More Python 3 tweaks.
pythonspeed Jul 18, 2022
6cf3bc7
Some Python 3 cleanups.
pythonspeed Jul 18, 2022
07a3d1e
Python 3 tweaks.
pythonspeed Jul 18, 2022
8b0941a
Python 3 tweaks.
pythonspeed Jul 18, 2022
011b942
Python 3 tweaks.
pythonspeed Jul 18, 2022
1bcca7f
Python 3 tweaks.
pythonspeed Jul 18, 2022
4cc5c4d
Merge remote-tracking branch 'origin/master' into 2916.grid-manager-p…
pythonspeed Jul 25, 2022
b9ac102
Merge remote-tracking branch 'origin/master' into 2916.grid-manager-p…
pythonspeed Aug 15, 2022
435df49
Merge branch 'master' into 2916.grid-manager-proposal.6
itamarst Oct 5, 2022
630ad1a
Update docs/managed-grid.rst
meejah Nov 9, 2022
588f1fd
Update docs/managed-grid.rst
meejah Nov 9, 2022
87c2f9b
Update docs/managed-grid.rst
meejah Nov 9, 2022
6da9e50
Update newsfragments/2916.feature
meejah Nov 9, 2022
b2431f3
Update src/allmydata/cli/grid_manager.py
meejah Nov 9, 2022
039c1d8
Update src/allmydata/grid_manager.py
meejah Nov 9, 2022
464498f
Merge branch 'master' into 2916.grid-manager-proposal.6
meejah Feb 20, 2023
5b14561
use attrs directly
meejah Feb 20, 2023
a6cf06c
http needs access to GridManager
meejah Feb 20, 2023
bdf4c49
fine, move the if statement
meejah Feb 21, 2023
7b98eda
add more words
meejah Feb 21, 2023
8e20fa0
whitespace
meejah Feb 21, 2023
affe0cb
fine?
meejah Feb 21, 2023
43d2998
Update src/allmydata/cli/grid_manager.py
meejah Feb 21, 2023
032b852
define -> frozen
meejah Feb 21, 2023
38669cc
define -> frozen
meejah Feb 21, 2023
1b6d5e1
Revert "use attrs directly"
meejah Feb 21, 2023
82045b4
store signature as raw bytes, not base32
meejah Feb 21, 2023
d91bfcb
clarify
meejah Feb 21, 2023
00ef466
ISO dates, not seconds
meejah Feb 21, 2023
6ee5c75
comment -> ticket
meejah Feb 21, 2023
70459cf
use possibly-overriden stderr
meejah Feb 21, 2023
fb10e13
might want to use these at parse time
meejah Feb 22, 2023
69a480d
rewrite test
meejah Feb 22, 2023
0ae7da7
prop up the fragile scaffolding
meejah Feb 22, 2023
c587c9e
Merge branch '2916.grid-manager-proposal.6' of https://github.com/tah…
meejah Feb 22, 2023
6aff94d
flake8, more frozen
meejah Feb 22, 2023
a6a2eb1
export it too
meejah Feb 23, 2023
1587a71
spelling
meejah Feb 28, 2023
9f63441
types
meejah Feb 28, 2023
d55a4a1
whitespace
meejah Feb 28, 2023
aed5061
wording
meejah Feb 28, 2023
b28ac61
different way to say 'all items okay'
meejah Feb 28, 2023
5672a28
more-specific error
meejah Feb 28, 2023
8e7f2cd
unused
meejah Feb 28, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 3 additions & 0 deletions docs/configuration.rst
Original file line number Diff line number Diff line change
Expand Up @@ -980,6 +980,9 @@ the node will not use an Introducer at all.
Such "introducerless" clients must be configured with static servers (described
below), or they will not be able to upload and download files.


.. _server_list:

Static Server Definitions
=========================

Expand Down
1 change: 1 addition & 0 deletions docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ Contents:
gpg-setup

servers
managed-grid
helper
convergence-secret
garbage-collection
Expand Down
342 changes: 342 additions & 0 deletions docs/managed-grid.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,342 @@


Managed Grid
============

This document explains the "Grid Manager" concept and the
`grid-manager` command. Someone operating a grid may choose to use a
Grid Manager. Operators of storage-servers and clients will then be
given additional configuration in this case.


Overview and Motivation
-----------------------

In a grid using an Introducer, a client will use any storage-server
the Introducer announces (and the Introducer will announce any
storage-server that connects to it). This means that anyone with the
Introducer fURL can connect storage to the grid.

Sometimes, this is just what you want!

For some use-cases, though, you want to have clients only use certain
servers. One case might be a "managed" grid, where some entity runs
the grid; clients of this grid don't want their uploads to go to
"unmanaged" storage if some other client decides to provide storage.

One way to limit which storage servers a client connects to is via the
"server list" (:ref:`server_list`) (aka "Introducerless"
mode). Clients are given static lists of storage-servers, and connect
only to those. This means manually updating these lists if the storage
servers change, however.

Another method is for clients to use `[client] peers.preferred=`
configuration option (:ref:`Client Configuration`), which suffers
from a similar disadvantage.


Grid Manager
------------

A "grid-manager" consists of some data defining a keypair (along with
some other details) and Tahoe sub-commands to manipulate the data and
produce certificates to give to storage-servers. Certificates assert
the statement: "Grid Manager X suggests you use storage-server Y to
upload shares to" (X and Y are public-keys). Such a certificate
consists of:

- the version of the format the certificate conforms to (`1`)
- the public-key of a storage-server
- an expiry timestamp
- a signature of the above

A client will always use any storage-server for downloads (expired
certificate, or no certificate) because clients check the ciphertext
and re-assembled plaintext against the keys in the capability;
"grid-manager" certificates only control uploads.
exarkun marked this conversation as resolved.
Show resolved Hide resolved

Clients make use of this functionality by configuring one or more Grid Manager public keys.
This tells the client to only upload to storage-servers that have a currently-valid certificate from any of the Grid Managers their client allows.
In case none are configured, the default behavior (of using any storage server) prevails.


Grid Manager Data Storage
-------------------------

The data defining the grid-manager is stored in an arbitrary
directory, which you indicate with the ``--config`` option (in the
future, we may add the ability to store the data directly in a grid,
at which time you may be able to pass a directory-capability to this
option).

If you don't want to store the configuration on disk at all, you may
use ``--config -`` (the last character is a dash) and write a valid
JSON configuration to stdin.

All commands require the ``--config`` option and they all behave
similarly for "data from stdin" versus "data from disk". A directory
(and not a file) is used on disk because in that mode, each
certificate issued is also stored alongside the configuration
document; in "stdin / stdout" mode, an issued certificate is only
ever available on stdout.

The configuration is a JSON document. It is subject to change as Grid
Manager evolves. It contains a version number in the
`grid_manager_config_version` key which will increment whenever the
document schema changes.


grid-manager create
```````````````````

Create a new grid-manager.

If you specify ``--config -`` then a new grid-manager configuration is
written to stdout. Otherwise, a new grid-manager is created in the
directory specified by the ``--config`` option. It is an error if the
directory already exists.


grid-manager public-identity
````````````````````````````

Print out a grid-manager's public key. This key is derived from the
private-key of the grid-manager, so a valid grid-manager config must
be given via ``--config``

This public key is what is put in clients' configuration to actually
validate and use grid-manager certificates.


grid-manager add
````````````````

Takes two args: ``name pubkey``. The ``name`` is an arbitrary local
identifier for the new storage node (also sometimes called "a petname"
or "nickname"). The pubkey is the tahoe-encoded key from a ``node.pubkey``
file in the storage-server's node directory (minus any
whitespace). For example, if ``~/storage0`` contains a storage-node,
you might do something like this::

grid-manager --config ./gm0 add storage0 $(cat ~/storage0/node.pubkey)

This adds a new storage-server to a Grid Manager's
configuration. (Since it mutates the configuration, if you used
``--config -`` the new configuration will be printed to stdout). The
usefulness of the ``name`` is solely for reference within this Grid
Manager.


grid-manager list
`````````````````

Lists all storage-servers that have previously been added using
``grid-manager add``.


grid-manager sign
`````````````````

Takes two args: ``name expiry_days``. The ``name`` is a nickname used
previously in a ``grid-manager add`` command and ``expiry_days`` is
the number of days in the future when the certificate should expire.

Note that this mutates the state of the grid-manager if it is on disk,
by adding this certificate to our collection of issued
certificates. If you used ``--config -``, the certificate isn't
persisted anywhere except to stdout (so if you wish to keep it
somewhere, that is up to you).

This command creates a new "version 1" certificate for a
storage-server (identified by its public key). The new certificate is
printed to stdout. If you stored the config on disk, the new
certificate will (also) be in a file named like ``alice.cert.0``.


Enrolling a Storage Server: CLI
-------------------------------


tahoe admin add-grid-manager-cert
`````````````````````````````````

- `--filename`: the file to read the cert from
- `--name`: the name of this certificate

Import a "version 1" storage-certificate produced by a grid-manager A
storage server may have zero or more such certificates installed; for
now just one is sufficient. You will have to re-start your node after
this. Subsequent announcements to the Introducer will include this
certificate.

.. note::

This command will simply edit the `tahoe.cfg` file and direct you
to re-start. In the Future(tm), we should consider (in exarkun's
words):

"A python program you run as a new process" might not be the
best abstraction to layer on top of the configuration
persistence system, though. It's a nice abstraction for users
(although most users would probably rather have a GUI) but it's
not a great abstraction for automation. So at some point it
may be better if there is CLI -> public API -> configuration
persistence system. And maybe "public API" is even a network
API for the storage server so it's equally easy to access from
an agent implemented in essentially any language and maybe if
the API is exposed by the storage node itself then this also
gives you live-configuration-updates, avoiding the need for
node restarts (not that this is the only way to accomplish
this, but I think it's a good way because it avoids the need
for messes like inotify and it supports the notion that the
storage node process is in charge of its own configuration
persistence system, not just one consumer among many ... which
has some nice things going for it ... though how this interacts
exactly with further node management automation might bear
closer scrutiny).


Enrolling a Storage Server: Config
----------------------------------

You may edit the ``[storage]`` section of the ``tahoe.cfg`` file to
turn on grid-management with ``grid_management = true``. You then must
also provide a ``[grid_management_certificates]`` section in the
config-file which lists ``name = path/to/certificate`` pairs.

These certificate files are issued by the ``grid-manager sign``
command; these should be transmitted to the storage server operator
who includes them in the config for the storage server. Relative paths
are based from the node directory. Example::

[storage]
grid_management = true

[grid_management_certificates]
default = example_grid.cert

This will cause us to give this certificate to any Introducers we
connect to (and subsequently, the Introducer will give the certificate
out to clients).


Enrolling a Client: Config
--------------------------

You may instruct a Tahoe client to use only storage servers from given
Grid Managers. If there are no such keys, any servers are used
(but see https://tahoe-lafs.org/trac/tahoe-lafs/ticket/3979). If
there are one or more keys, the client will only upload to a storage
server that has a valid certificate (from any of the keys).

To specify public-keys, add a ``[grid_managers]`` section to the
config. This consists of ``name = value`` pairs where ``name`` is an
arbitrary name and ``value`` is a public-key of a Grid
Manager. Example::

[grid_managers]
example_grid = pub-v0-vqimc4s5eflwajttsofisp5st566dbq36xnpp4siz57ufdavpvlq

See also https://tahoe-lafs.org/trac/tahoe-lafs/ticket/3507 which
proposes a command to edit the config.


Example Setup of a New Managed Grid
-----------------------------------

This example creates an actual grid, but it's all just on one machine
with different "node directories" and a separate tahoe process for
each node. Usually of course each storage server would be on a
separate computer.

Note that we use the ``daemonize`` command in the following but that's
only one way to handle "running a command in the background". You
could instead run commands that start with ``daemonize ...`` in their
own shell/terminal window or via something like ``systemd``

We'll store our Grid Manager configuration on disk, in
``./gm0``. To initialize this directory::

grid-manager --config ./gm0 create

(If you already have a grid, you can :ref:`skip ahead <skip_ahead>`.)

First of all, create an Introducer. Note that we actually have to run
it briefly before it creates the "Introducer fURL" we want for the
next steps::

tahoe create-introducer --listen=tcp --port=5555 --location=tcp:localhost:5555 ./introducer
daemonize tahoe -d introducer run

Next, we attach a couple of storage nodes::

tahoe create-node --introducer $(cat introducer/private/introducer.furl) --nickname storage0 --webport 6001 --location tcp:localhost:6003 --port 6003 ./storage0
tahoe create-node --introducer $(cat introducer/private/introducer.furl) --nickname storage1 --webport 6101 --location tcp:localhost:6103 --port 6103 ./storage1
daemonize tahoe -d storage0 run
daemonize tahoe -d storage1 run

.. _skip_ahead:

We can now tell the Grid Manager about our new storage servers::

grid-manager --config ./gm0 add storage0 $(cat storage0/node.pubkey)
grid-manager --config ./gm0 add storage1 $(cat storage1/node.pubkey)

To produce a new certificate for each node, we do this::

grid-manager --config ./gm0 sign storage0 > ./storage0/gridmanager.cert
grid-manager --config ./gm0 sign storage1 > ./storage1/gridmanager.cert

Now, we want our storage servers to actually announce these
certificates into the grid. We do this by adding some configuration
(in ``tahoe.cfg``)::

[storage]
grid_management = true

[grid_manager_certificates]
default = gridmanager.cert

Add the above bit to each node's ``tahoe.cfg`` and re-start the
storage nodes. (Alternatively, use the ``tahoe add-grid-manager``
command).

Now try adding a new storage server ``storage2``. This client can join
the grid just fine, and announce itself to the Introducer as providing
storage::

tahoe create-node --introducer $(cat introducer/private/introducer.furl) --nickname storage2 --webport 6301 --location tcp:localhost:6303 --port 6303 ./storage2
daemonize tahoe -d storage2 run

At this point any client will upload to any of these three
storage-servers. Make a client "alice" and try!

::

tahoe create-client --introducer $(cat introducer/private/introducer.furl) --nickname alice --webport 6401 --shares-total=3 --shares-needed=2 --shares-happy=3 ./alice
daemonize tahoe -d alice run
tahoe -d alice put README.rst # prints out a read-cap
find storage2/storage/shares # confirm storage2 has a share

Now we want to make Alice only upload to the storage servers that the
grid-manager has given certificates to (``storage0`` and
``storage1``). We need the grid-manager's public key to put in Alice's
configuration::

grid-manager --config ./gm0 public-identity

Put the key printed out above into Alice's ``tahoe.cfg`` in section
``client``::

[grid_managers]
example_name = pub-v0-vqimc4s5eflwajttsofisp5st566dbq36xnpp4siz57ufdavpvlq


Now, re-start the "alice" client. Since we made Alice's parameters
require 3 storage servers to be reachable (``--happy=3``), all their
uploads should now fail (so ``tahoe put`` will fail) because they
won't use storage2 and thus can't "achieve happiness".

A proposal to expose more information about Grid Manager and
certificate status in the Welcome page is discussed in
https://tahoe-lafs.org/trac/tahoe-lafs/ticket/3506
1 change: 1 addition & 0 deletions newsfragments/2916.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Tahoe-LAFS now includes a new "Grid Manager" specification and implementation adding more options to control which storage servers a client will use for uploads.
10 changes: 9 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,9 @@ def read_version_py(infname):
# amount of copying involved.
"pycddl >= 0.4",

# Command-line parsing
"click >= 7.0",

# for pid-file support
"psutil",
"filelock",
Expand Down Expand Up @@ -428,6 +431,11 @@ def run(self):
},
include_package_data=True,
setup_requires=setup_requires,
entry_points = { 'console_scripts': [ 'tahoe = allmydata.scripts.runner:run' ] },
entry_points={
'console_scripts': [
'tahoe = allmydata.scripts.runner:run',
'grid-manager = allmydata.cli.grid_manager:grid_manager',
]
},
**setup_args
)
Empty file added src/allmydata/cli/__init__.py
Empty file.