[ARVADOS] updated: 1.3.0-3038-g27566b089

Git user git at public.arvados.org
Sat Aug 29 11:20:39 UTC 2020


Summary of changes:
 lib/controller/rpc/conn.go            |  6 ++----
 lib/crunchrun/crunchrun.go            | 37 +++++++++++++++++------------------
 lib/dispatchcloud/driver.go           |  5 ++---
 lib/dispatchcloud/test/stub_driver.go | 12 ++++--------
 sdk/go/arvados/blob_signature.go      |  3 +--
 sdk/go/arvados/config.go              |  3 +--
 sdk/go/arvados/keep_service.go        |  2 +-
 sdk/go/arvadosclient/arvadosclient.go | 12 +++++-------
 sdk/go/keepclient/root_sorter.go      |  5 ++---
 sdk/go/keepclient/support.go          | 15 +++++++-------
 10 files changed, 43 insertions(+), 57 deletions(-)

       via  27566b089a00a4038fceb320175b37fcb0e77033 (commit)
      from  bee95c1cdbc3859f47a0a95940680ebaa2a4c9a5 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.


commit 27566b089a00a4038fceb320175b37fcb0e77033
Author: Ward Vandewege <ward at curii.com>
Date:   Sat Aug 29 07:20:19 2020 -0400

    Fix some golint warnings.
    
    No issue #
    
    Arvados-DCO-1.1-Signed-off-by: Ward Vandewege <ward at curii.com>

diff --git a/lib/controller/rpc/conn.go b/lib/controller/rpc/conn.go
index 729d8bdde..6c332db07 100644
--- a/lib/controller/rpc/conn.go
+++ b/lib/controller/rpc/conn.go
@@ -28,9 +28,8 @@ type TokenProvider func(context.Context) ([]string, error)
 func PassthroughTokenProvider(ctx context.Context) ([]string, error) {
 	if incoming, ok := auth.FromContext(ctx); !ok {
 		return nil, errors.New("no token provided")
-	} else {
-		return incoming.Tokens, nil
 	}
+	return incoming.Tokens, nil
 }
 
 type Conn struct {
@@ -170,9 +169,8 @@ func (conn *Conn) relativeToBaseURL(location string) string {
 		u.User = nil
 		u.Host = ""
 		return u.String()
-	} else {
-		return location
 	}
+	return location
 }
 
 func (conn *Conn) CollectionCreate(ctx context.Context, options arvados.CreateOptions) (arvados.Collection, error) {
diff --git a/lib/crunchrun/crunchrun.go b/lib/crunchrun/crunchrun.go
index c8f171ca9..c125b27a5 100644
--- a/lib/crunchrun/crunchrun.go
+++ b/lib/crunchrun/crunchrun.go
@@ -870,25 +870,24 @@ func (runner *ContainerRunner) LogNodeRecord() error {
 			return err
 		}
 		return w.Close()
-	} else {
-		// Dispatched via crunch-dispatch-slurm. Look up
-		// apiserver's node record corresponding to
-		// $SLURMD_NODENAME.
-		hostname := os.Getenv("SLURMD_NODENAME")
-		if hostname == "" {
-			hostname, _ = os.Hostname()
-		}
-		_, err := runner.logAPIResponse("node", "nodes", map[string]interface{}{"filters": [][]string{{"hostname", "=", hostname}}}, func(resp interface{}) {
-			// The "info" field has admin-only info when
-			// obtained with a privileged token, and
-			// should not be logged.
-			node, ok := resp.(map[string]interface{})
-			if ok {
-				delete(node, "info")
-			}
-		})
-		return err
 	}
+	// Dispatched via crunch-dispatch-slurm. Look up
+	// apiserver's node record corresponding to
+	// $SLURMD_NODENAME.
+	hostname := os.Getenv("SLURMD_NODENAME")
+	if hostname == "" {
+		hostname, _ = os.Hostname()
+	}
+	_, err := runner.logAPIResponse("node", "nodes", map[string]interface{}{"filters": [][]string{{"hostname", "=", hostname}}}, func(resp interface{}) {
+		// The "info" field has admin-only info when
+		// obtained with a privileged token, and
+		// should not be logged.
+		node, ok := resp.(map[string]interface{})
+		if ok {
+			delete(node, "info")
+		}
+	})
+	return err
 }
 
 func (runner *ContainerRunner) logAPIResponse(label, path string, params map[string]interface{}, munge func(interface{})) (logged bool, err error) {
@@ -1489,7 +1488,7 @@ func (runner *ContainerRunner) ContainerToken() (string, error) {
 	return runner.token, nil
 }
 
-// UpdateContainerComplete updates the container record state on API
+// UpdateContainerFinal updates the container record state on API
 // server to "Complete" or "Cancelled"
 func (runner *ContainerRunner) UpdateContainerFinal() error {
 	update := arvadosclient.Dict{}
diff --git a/lib/dispatchcloud/driver.go b/lib/dispatchcloud/driver.go
index f2a6c9263..fe498d048 100644
--- a/lib/dispatchcloud/driver.go
+++ b/lib/dispatchcloud/driver.go
@@ -17,7 +17,7 @@ import (
 	"golang.org/x/crypto/ssh"
 )
 
-// Map of available cloud drivers.
+// Drivers is a map of available cloud drivers.
 // Clusters.*.Containers.CloudVMs.Driver configuration values
 // correspond to keys in this map.
 var Drivers = map[string]cloud.Driver{
@@ -180,7 +180,6 @@ func (inst instrumentedInstance) SetTags(tags cloud.InstanceTags) error {
 func boolLabelValue(v bool) string {
 	if v {
 		return "1"
-	} else {
-		return "0"
 	}
+	return "0"
 }
diff --git a/lib/dispatchcloud/test/stub_driver.go b/lib/dispatchcloud/test/stub_driver.go
index f6e06d3f7..41eb20763 100644
--- a/lib/dispatchcloud/test/stub_driver.go
+++ b/lib/dispatchcloud/test/stub_driver.go
@@ -118,10 +118,8 @@ func (sis *StubInstanceSet) Create(it arvados.InstanceType, image cloud.ImageID,
 	}
 	if sis.allowCreateCall.After(time.Now()) {
 		return nil, RateLimitError{sis.allowCreateCall}
-	} else {
-		sis.allowCreateCall = time.Now().Add(sis.driver.MinTimeBetweenCreateCalls)
 	}
-
+	sis.allowCreateCall = time.Now().Add(sis.driver.MinTimeBetweenCreateCalls)
 	ak := sis.driver.AuthorizedKeys
 	if authKey != nil {
 		ak = append([]ssh.PublicKey{authKey}, ak...)
@@ -154,9 +152,8 @@ func (sis *StubInstanceSet) Instances(cloud.InstanceTags) ([]cloud.Instance, err
 	defer sis.mtx.RUnlock()
 	if sis.allowInstancesCall.After(time.Now()) {
 		return nil, RateLimitError{sis.allowInstancesCall}
-	} else {
-		sis.allowInstancesCall = time.Now().Add(sis.driver.MinTimeBetweenInstancesCalls)
 	}
+	sis.allowInstancesCall = time.Now().Add(sis.driver.MinTimeBetweenInstancesCalls)
 	var r []cloud.Instance
 	for _, ss := range sis.servers {
 		r = append(r, ss.Instance())
@@ -372,10 +369,9 @@ func (svm *StubVM) Exec(env map[string]string, command string, stdin io.Reader,
 		if running {
 			fmt.Fprintf(stderr, "%s: container is running\n", uuid)
 			return 1
-		} else {
-			fmt.Fprintf(stderr, "%s: container is not running\n", uuid)
-			return 0
 		}
+		fmt.Fprintf(stderr, "%s: container is not running\n", uuid)
+		return 0
 	}
 	if command == "true" {
 		return 0
diff --git a/sdk/go/arvados/blob_signature.go b/sdk/go/arvados/blob_signature.go
index 132939547..2202016bc 100644
--- a/sdk/go/arvados/blob_signature.go
+++ b/sdk/go/arvados/blob_signature.go
@@ -57,9 +57,8 @@ func SignManifest(manifest string, apiToken string, expiry time.Time, ttl time.D
 	return regexp.MustCompile(`\S+`).ReplaceAllStringFunc(manifest, func(tok string) string {
 		if mBlkRe.MatchString(tok) {
 			return SignLocator(mPermHintRe.ReplaceAllString(tok, ""), apiToken, expiry, ttl, permissionSecret)
-		} else {
-			return tok
 		}
+		return tok
 	})
 }
 
diff --git a/sdk/go/arvados/config.go b/sdk/go/arvados/config.go
index d98ffd18e..6e1549224 100644
--- a/sdk/go/arvados/config.go
+++ b/sdk/go/arvados/config.go
@@ -17,9 +17,8 @@ import (
 var DefaultConfigFile = func() string {
 	if path := os.Getenv("ARVADOS_CONFIG"); path != "" {
 		return path
-	} else {
-		return "/etc/arvados/config.yml"
 	}
+	return "/etc/arvados/config.yml"
 }()
 
 type Config struct {
diff --git a/sdk/go/arvados/keep_service.go b/sdk/go/arvados/keep_service.go
index da1710374..eb7988422 100644
--- a/sdk/go/arvados/keep_service.go
+++ b/sdk/go/arvados/keep_service.go
@@ -140,7 +140,7 @@ func (s *KeepService) Untrash(ctx context.Context, c *Client, blk string) error
 	return nil
 }
 
-// Index returns an unsorted list of blocks at the given mount point.
+// IndexMount returns an unsorted list of blocks at the given mount point.
 func (s *KeepService) IndexMount(ctx context.Context, c *Client, mountUUID string, prefix string) ([]KeepServiceIndexEntry, error) {
 	return s.index(ctx, c, s.url("mounts/"+mountUUID+"/blocks?prefix="+prefix))
 }
diff --git a/sdk/go/arvadosclient/arvadosclient.go b/sdk/go/arvadosclient/arvadosclient.go
index e2c046662..bfcbde2a7 100644
--- a/sdk/go/arvadosclient/arvadosclient.go
+++ b/sdk/go/arvadosclient/arvadosclient.go
@@ -70,12 +70,11 @@ func (e APIServerError) Error() string {
 			e.HttpStatusCode,
 			e.HttpStatusMessage,
 			e.ServerAddress)
-	} else {
-		return fmt.Sprintf("arvados API server error: %d: %s returned by %s",
-			e.HttpStatusCode,
-			e.HttpStatusMessage,
-			e.ServerAddress)
 	}
+	return fmt.Sprintf("arvados API server error: %d: %s returned by %s",
+		e.HttpStatusCode,
+		e.HttpStatusMessage,
+		e.ServerAddress)
 }
 
 // StringBool tests whether s is suggestive of true. It returns true
@@ -420,9 +419,8 @@ func (c *ArvadosClient) Discovery(parameter string) (value interface{}, err erro
 	value, found = c.DiscoveryDoc[parameter]
 	if found {
 		return value, nil
-	} else {
-		return value, ErrInvalidArgument
 	}
+	return value, ErrInvalidArgument
 }
 
 func (ac *ArvadosClient) httpClient() *http.Client {
diff --git a/sdk/go/keepclient/root_sorter.go b/sdk/go/keepclient/root_sorter.go
index afeb80284..c46b7185e 100644
--- a/sdk/go/keepclient/root_sorter.go
+++ b/sdk/go/keepclient/root_sorter.go
@@ -33,10 +33,9 @@ func NewRootSorter(serviceRoots map[string]string, hash string) *RootSorter {
 func (rs RootSorter) getWeight(hash string, uuid string) string {
 	if len(uuid) == 27 {
 		return Md5String(hash + uuid[12:])
-	} else {
-		// Only useful for testing, a set of one service root, etc.
-		return Md5String(hash + uuid)
 	}
+	// Only useful for testing, a set of one service root, etc.
+	return Md5String(hash + uuid)
 }
 
 func (rs RootSorter) GetSortedRoots() []string {
diff --git a/sdk/go/keepclient/support.go b/sdk/go/keepclient/support.go
index 71b4b5ed2..7989e66c0 100644
--- a/sdk/go/keepclient/support.go
+++ b/sdk/go/keepclient/support.go
@@ -127,7 +127,7 @@ func (this *KeepClient) putReplicas(
 	sv := NewRootSorter(this.WritableLocalRoots(), hash).GetSortedRoots()
 
 	// The next server to try contacting
-	next_server := 0
+	nextServer := 0
 
 	// The number of active writers
 	active := 0
@@ -162,15 +162,15 @@ func (this *KeepClient) putReplicas(
 
 	for retriesRemaining > 0 {
 		retriesRemaining -= 1
-		next_server = 0
+		nextServer = 0
 		retryServers = []string{}
 		for replicasTodo > 0 {
 			for active*replicasPerThread < replicasTodo {
 				// Start some upload requests
-				if next_server < len(sv) {
-					DebugPrintf("DEBUG: [%s] Begin upload %s to %s", reqid, hash, sv[next_server])
-					go this.uploadToKeepServer(sv[next_server], hash, getReader(), upload_status, expectedLength, reqid)
-					next_server += 1
+				if nextServer < len(sv) {
+					DebugPrintf("DEBUG: [%s] Begin upload %s to %s", reqid, hash, sv[nextServer])
+					go this.uploadToKeepServer(sv[nextServer], hash, getReader(), upload_status, expectedLength, reqid)
+					nextServer += 1
 					active += 1
 				} else {
 					if active == 0 && retriesRemaining == 0 {
@@ -180,9 +180,8 @@ func (this *KeepClient) putReplicas(
 						}
 						msg = msg[:len(msg)-2]
 						return locator, replicasDone, InsufficientReplicasError(errors.New(msg))
-					} else {
-						break
 					}
+					break
 				}
 			}
 			DebugPrintf("DEBUG: [%s] Replicas remaining to write: %v active uploads: %v",

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


hooks/post-receive
-- 




More information about the arvados-commits mailing list