projects
/
arvados.git
/ blobdiff
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Do not blow up the provenance graph if a PDH used in the workflow no
[arvados.git]
/
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 569046b70f4c3969dbabde049ffcbed2044dd454..7dca3293d25fce94111eb1708fde156fc5c52387 100644
(file)
--- a/
tools/keep-block-check/keep-block-check.go
+++ b/
tools/keep-block-check/keep-block-check.go
@@
-1,3
+1,7
@@
+// Copyright (C) The Arvados Authors. All rights reserved.
+//
+// SPDX-License-Identifier: AGPL-3.0
+
package main
import (
package main
import (
@@
-5,15
+9,15
@@
import (
"errors"
"flag"
"fmt"
"errors"
"flag"
"fmt"
- "git.curoverse.com/arvados.git/sdk/go/arvadosclient"
- "git.curoverse.com/arvados.git/sdk/go/keepclient"
"io/ioutil"
"log"
"net/http"
"os"
"io/ioutil"
"log"
"net/http"
"os"
- "regexp"
"strings"
"time"
"strings"
"time"
+
+ "git.curoverse.com/arvados.git/sdk/go/arvadosclient"
+ "git.curoverse.com/arvados.git/sdk/go/keepclient"
)
func main() {
)
func main() {
@@
-48,7
+52,7
@@
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(
+ blobSignatureTTL
Flag
:= 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.")
"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
+77,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 {
@@
-99,8
+103,6
@@
func loadConfig(configFile string) (config apiConfig, blobSigningKey string, err
return
}
return
}
-var matchTrue = regexp.MustCompile("^(?i:1|yes|true)$")
-
// Read config from file
func readConfigFromFile(filename string) (config apiConfig, blobSigningKey string, err error) {
if !strings.Contains(filename, "/") {
// Read config from file
func readConfigFromFile(filename string) (config apiConfig, blobSigningKey string, err error) {
if !strings.Contains(filename, "/") {
@@
-130,9
+132,9
@@
func readConfigFromFile(filename string) (config apiConfig, blobSigningKey strin
case "ARVADOS_API_HOST":
config.APIHost = value
case "ARVADOS_API_HOST_INSECURE":
case "ARVADOS_API_HOST":
config.APIHost = value
case "ARVADOS_API_HOST_INSECURE":
- config.APIHostInsecure =
matchTrue.MatchString
(value)
+ config.APIHostInsecure =
arvadosclient.StringBool
(value)
case "ARVADOS_EXTERNAL_CLIENT":
case "ARVADOS_EXTERNAL_CLIENT":
- config.ExternalClient =
matchTrue.MatchString
(value)
+ config.ExternalClient =
arvadosclient.StringBool
(value)
case "ARVADOS_BLOB_SIGNING_KEY":
blobSigningKey = value
}
case "ARVADOS_BLOB_SIGNING_KEY":
blobSigningKey = value
}
@@
-143,7
+145,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,
@@
-153,7
+155,7
@@
func setupKeepClient(config apiConfig, keepServicesJSON string, blobSignatureTTL
External: config.ExternalClient,
}
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 {
if keepServicesJSON == "" {
kc, err = keepclient.MakeKeepClient(&arv)
if err != nil {
@@
-168,12
+170,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
}
}
}
}