[ARVADOS] created: 1.1.4-382-g8de0cca

Git user git at public.curoverse.com
Mon Jun 11 09:52:04 EDT 2018


        at  8de0cca205b1b6be4c57d84289fcc21aab0860fe (commit)


commit 8de0cca205b1b6be4c57d84289fcc21aab0860fe
Author: Peter Amstutz <pamstutz at veritasgenetics.com>
Date:   Mon Jun 11 09:48:46 2018 -0400

    13579: keepstore help prints out a single annotated example config.
    
    Instead of separate "example config" and "field documentation"
    sections in usage.
    
    Implementation: move docs for Config fields to struct field tag and
    use reflection to get documentation for each config field.
    
    Arvados-DCO-1.1-Signed-off-by: Peter Amstutz <pamstutz at veritasgenetics.com>

diff --git a/services/keepstore/config.go b/services/keepstore/config.go
index c9c9ae1..b91ce05 100644
--- a/services/keepstore/config.go
+++ b/services/keepstore/config.go
@@ -23,30 +23,79 @@ import (
 )
 
 type Config struct {
-	Debug  bool
-	Listen string
-
-	LogFormat string
-
-	PIDFile string
-
-	MaxBuffers  int
-	MaxRequests int
-
-	BlobSignatureTTL    arvados.Duration
-	BlobSigningKeyFile  string
-	RequireSignatures   bool
-	SystemAuthTokenFile string
-	EnableDelete        bool
-	TrashLifetime       arvados.Duration
-	TrashCheckInterval  arvados.Duration
-	PullWorkers         int
-	TrashWorkers        int
-	EmptyTrashWorkers   int
-	TLSCertificateFile  string
-	TLSKeyFile          string
-
-	Volumes VolumeList
+	Debug bool `doc: Print extra debug logging`
+
+	Listen string `doc: Local port to listen on. Can be 'address:port' or ':port', where
+'address' is a host IP address or name and 'port' is a port number
+or name.`
+
+	LogFormat string `doc: Format of request/response and error logs: "json" or "text".`
+
+	PIDFile string `doc: Path to write PID file during startup. This file is kept open and
+locked with LOCK_EX until keepstore exits, so "fuser -k pidfile" is
+one way to shut down. Exit immediately if there is an error
+opening, locking, or writing the PID file.`
+
+	MaxBuffers int `doc: Maximum RAM to use for data buffers, given in multiples of block
+size (64 MiB). When this limit is reached, HTTP requests requiring
+buffers (like GET and PUT) will wait for buffer space to be
+released.`
+
+	MaxRequests int `doc: Maximum concurrent requests. When this limit is reached, new
+requests will receive 503 responses. Note: this limit does not
+include idle connections from clients using HTTP keepalive, so it
+does not strictly limit the number of concurrent connections. If
+omitted or zero, the default is 2 * MaxBuffers.`
+
+	BlobSignatureTTL arvados.Duration `doc: Duration for which new permission signatures (returned in PUT
+responses) will be valid.  This should be equal to the API
+server's blob_signature_ttl configuration entry.`
+
+	BlobSigningKeyFile string `doc: Local file containing the secret blob signing key (used to
+generate and verify blob signatures).  This key should be
+identical to the API server's blob_signing_key configuration
+entry.`
+
+	RequireSignatures bool `doc: Honor read requests only if a valid signature is provided.  This
+should be true, except for development use and when migrating from
+a very old version.`
+
+	SystemAuthTokenFile string `doc: Local file containing the Arvados API token used by keep-balance
+or data manager.  Delete, trash, and index requests are honored
+only for this token.`
+
+	EnableDelete bool `doc: Enable trash and delete features. If false, trash lists will be
+accepted but blocks will not be trashed or deleted.`
+
+	TrashLifetime arvados.Duration `doc: Time duration after a block is trashed during which it can be
+recovered using an /untrash request.`
+
+	TrashCheckInterval arvados.Duration `doc: How often to check for (and delete) trashed blocks whose
+TrashLifetime has expired.`
+
+	PullWorkers int `doc: Maximum number of concurrent pull operations. Default is 1, i.e.,
+pull lists are processed serially.`
+
+	TrashWorkers int `doc: Maximum number of concurrent trash operations. Default is 1, i.e.,
+trash lists are processed serially.`
+
+	EmptyTrashWorkers int `doc: Maximum number of concurrent block deletion operations (per
+volume) when emptying trash. Default is 1.`
+
+	TLSCertificateFile string `doc: Path to server certificate file in X509 format. Enables TLS mode.
+
+Example: /var/lib/acme/live/keep0.example.com/fullchain`
+
+	TLSKeyFile string `doc: Path to server key file in X509 format. Enables TLS mode.
+
+The key pair is read from disk during startup, and whenever SIGHUP
+is received.
+
+Example: /var/lib/acme/live/keep0.example.com/privkey`
+
+	Volumes VolumeList `doc: List of storage volumes. If omitted or empty, the default is to
+use all directories named "keep" that exist in the top level
+directory of a mount point at startup time.`
 
 	blobSigningKey  []byte
 	systemAuthToken string
diff --git a/services/keepstore/usage.go b/services/keepstore/usage.go
index 8e83f6c..2a00676 100644
--- a/services/keepstore/usage.go
+++ b/services/keepstore/usage.go
@@ -8,6 +8,8 @@ import (
 	"flag"
 	"fmt"
 	"os"
+	"reflect"
+	"regexp"
 	"sort"
 	"strings"
 
@@ -26,7 +28,7 @@ func usage() {
 		panic(err)
 	}
 	sort.Strings(knownTypes)
-	knownTypeList := strings.Join(knownTypes, ", ")
+	//knownTypeList := strings.Join(knownTypes, ", ")
 	fmt.Fprintf(os.Stderr, `
 
 keepstore provides a content-addressed data store backed by a local filesystem or networked storage.
@@ -41,122 +43,28 @@ NOTE: All options (other than -config) are deprecated in favor of YAML
 Options:
 `)
 	flag.PrintDefaults()
-	fmt.Fprintf(os.Stderr, `
-Example config file:
-
-%s
-
-Listen:
-
-    Local port to listen on. Can be "address:port" or ":port", where
-    "address" is a host IP address or name and "port" is a port number
-    or name.
-
-LogFormat:
-
-    Format of request/response and error logs: "json" or "text".
-
-PIDFile:
-
-   Path to write PID file during startup. This file is kept open and
-   locked with LOCK_EX until keepstore exits, so "fuser -k pidfile" is
-   one way to shut down. Exit immediately if there is an error
-   opening, locking, or writing the PID file.
-
-MaxBuffers:
-
-    Maximum RAM to use for data buffers, given in multiples of block
-    size (64 MiB). When this limit is reached, HTTP requests requiring
-    buffers (like GET and PUT) will wait for buffer space to be
-    released.
-
-MaxRequests:
-
-    Maximum concurrent requests. When this limit is reached, new
-    requests will receive 503 responses. Note: this limit does not
-    include idle connections from clients using HTTP keepalive, so it
-    does not strictly limit the number of concurrent connections. If
-    omitted or zero, the default is 2 * MaxBuffers.
-
-BlobSigningKeyFile:
-
-    Local file containing the secret blob signing key (used to
-    generate and verify blob signatures).  This key should be
-    identical to the API server's blob_signing_key configuration
-    entry.
-
-RequireSignatures:
-
-    Honor read requests only if a valid signature is provided.  This
-    should be true, except for development use and when migrating from
-    a very old version.
-
-BlobSignatureTTL:
-
-    Duration for which new permission signatures (returned in PUT
-    responses) will be valid.  This should be equal to the API
-    server's blob_signature_ttl configuration entry.
-
-SystemAuthTokenFile:
-
-    Local file containing the Arvados API token used by keep-balance
-    or data manager.  Delete, trash, and index requests are honored
-    only for this token.
-
-EnableDelete:
 
-    Enable trash and delete features. If false, trash lists will be
-    accepted but blocks will not be trashed or deleted.
-
-TrashLifetime:
-
-    Time duration after a block is trashed during which it can be
-    recovered using an /untrash request.
-
-TrashCheckInterval:
-
-    How often to check for (and delete) trashed blocks whose
-    TrashLifetime has expired.
-
-TrashWorkers:
-
-    Maximum number of concurrent trash operations. Default is 1, i.e.,
-    trash lists are processed serially.
-
-EmptyTrashWorkers:
-
-    Maximum number of concurrent block deletion operations (per
-    volume) when emptying trash. Default is 1.
-
-PullWorkers:
-
-    Maximum number of concurrent pull operations. Default is 1, i.e.,
-    pull lists are processed serially.
-
-TLSCertificateFile:
-
-    Path to server certificate file in X509 format. Enables TLS mode.
-
-    Example: /var/lib/acme/live/keep0.example.com/fullchain
-
-TLSKeyFile:
-
-    Path to server key file in X509 format. Enables TLS mode.
-
-    The key pair is read from disk during startup, and whenever SIGHUP
-    is received.
-
-    Example: /var/lib/acme/live/keep0.example.com/privkey
-
-Volumes:
+	configType := reflect.TypeOf(c).Elem()
+	docstrings := make(map[string]string)
+	for i := 0; i < configType.NumField(); i++ {
+		f := configType.Field(i)
+		idx := strings.Index(string(f.Tag), "doc:")
+		if idx > -1 {
+			docstrings[f.Name] = strings.TrimSpace(string(f.Tag[idx+4:]))
+		}
+	}
 
-    List of storage volumes. If omitted or empty, the default is to
-    use all directories named "keep" that exist in the top level
-    directory of a mount point at startup time.
+	fmt.Fprintf(os.Stderr, "\nExample config file:\n")
 
-    Volume types: %s
+	field, _ := regexp.Compile("([^ ]*): ")
+	for _, line := range strings.Split(string(exampleConfigFile), "\n") {
+		sm := field.FindStringSubmatch(line)
 
-    (See volume configuration examples above.)
+		if len(sm) > 1 && docstrings[sm[1]] != "" {
+			fmt.Fprintf(os.Stderr, "\n# %v\n%v\n", strings.Replace(docstrings[sm[1]], "\n", "\n# ", -1), line)
+		} else {
+			fmt.Fprintf(os.Stderr, "%v\n", line)
+		}
+	}
 
-`, exampleConfigFile, knownTypeList)
 }

-----------------------------------------------------------------------


hooks/post-receive
-- 




More information about the arvados-commits mailing list