X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/4d9ece42c8482948e4eca9f587cdb36f62a00e2b..75e00445b6de230493e9ee37483dd4c469db29b1:/tools/keep-block-check/keep-block-check.go diff --git a/tools/keep-block-check/keep-block-check.go b/tools/keep-block-check/keep-block-check.go index f27a4bc4c1..e57a9abed4 100644 --- a/tools/keep-block-check/keep-block-check.go +++ b/tools/keep-block-check/keep-block-check.go @@ -5,8 +5,6 @@ import ( "errors" "flag" "fmt" - "git.curoverse.com/arvados.git/sdk/go/arvadosclient" - "git.curoverse.com/arvados.git/sdk/go/keepclient" "io/ioutil" "log" "net/http" @@ -14,6 +12,9 @@ import ( "regexp" "strings" "time" + + "git.curoverse.com/arvados.git/sdk/go/arvadosclient" + "git.curoverse.com/arvados.git/sdk/go/keepclient" ) func main() { @@ -48,8 +49,8 @@ func doMain(args []string) error { "", "Block hash prefix. When a prefix is specified, only hashes listed in the file with this prefix will be checked.") - blobSignatureTTL := flags.Duration( - "blob-signing-ttl", + blobSignatureTTLFlag := flags.Duration( + "blob-signature-ttl", 0, "Lifetime of blob permission signatures on the keepservers. If not provided, this will be retrieved from the API server's discovery document.") @@ -73,12 +74,12 @@ func doMain(args []string) error { } // setup keepclient - kc, err := setupKeepClient(config, *keepServicesJSON, *blobSignatureTTL) + kc, blobSignatureTTL, err := setupKeepClient(config, *keepServicesJSON, *blobSignatureTTLFlag) if err != nil { return fmt.Errorf("Error configuring keepclient: %s", err.Error()) } - return performKeepBlockCheck(kc, *blobSignatureTTL, blobSigningKey, blockLocators, *verbose) + return performKeepBlockCheck(kc, blobSignatureTTL, blobSigningKey, blockLocators, *verbose) } type apiConfig struct { @@ -143,7 +144,7 @@ func readConfigFromFile(filename string) (config apiConfig, blobSigningKey strin } // setup keepclient using the config provided -func setupKeepClient(config apiConfig, keepServicesJSON string, blobSignatureTTL time.Duration) (kc *keepclient.KeepClient, err error) { +func setupKeepClient(config apiConfig, keepServicesJSON string, blobSignatureTTL time.Duration) (kc *keepclient.KeepClient, ttl time.Duration, err error) { arv := arvadosclient.ArvadosClient{ ApiToken: config.APIToken, ApiServer: config.APIHost, @@ -153,7 +154,7 @@ func setupKeepClient(config apiConfig, keepServicesJSON string, blobSignatureTTL External: config.ExternalClient, } - // if keepServicesJSON is provided, use it to load services; else, use DiscoverKeepServers + // If keepServicesJSON is provided, use it instead of service discovery if keepServicesJSON == "" { kc, err = keepclient.MakeKeepClient(&arv) if err != nil { @@ -168,12 +169,13 @@ func setupKeepClient(config apiConfig, keepServicesJSON string, blobSignatureTTL } // Get if blobSignatureTTL is not provided + ttl = blobSignatureTTL if blobSignatureTTL == 0 { value, err := arv.Discovery("blobSignatureTtl") if err == nil { - blobSignatureTTL = time.Duration(int(value.(float64))) * time.Second + ttl = time.Duration(int(value.(float64))) * time.Second } else { - return nil, err + return nil, 0, err } }