9701: Set repack_small_blocks() method as @synchronized
[arvados.git] / tools / keep-block-check / keep-block-check.go
index f27a4bc4c1af221b455b6ca4066ff4a85960839a..6cf11a728075c60990c1b049c0fb916cea5cd5d5 100644 (file)
@@ -48,8 +48,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.")
 
                "",
                "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.")
 
                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 +73,12 @@ func doMain(args []string) error {
        }
 
        // setup keepclient
        }
 
        // 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())
        }
 
        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 {
 }
 
 type apiConfig struct {
@@ -143,7 +143,7 @@ func readConfigFromFile(filename string) (config apiConfig, blobSigningKey strin
 }
 
 // setup keepclient using the config provided
 }
 
 // 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,
        arv := arvadosclient.ArvadosClient{
                ApiToken:    config.APIToken,
                ApiServer:   config.APIHost,
@@ -168,12 +168,13 @@ func setupKeepClient(config apiConfig, keepServicesJSON string, blobSignatureTTL
        }
 
        // Get if blobSignatureTTL is not provided
        }
 
        // Get if blobSignatureTTL is not provided
+       ttl = blobSignatureTTL
        if blobSignatureTTL == 0 {
                value, err := arv.Discovery("blobSignatureTtl")
                if err == nil {
        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 {
                } else {
-                       return nil, err
+                       return nil, 0, err
                }
        }
 
                }
        }