[ARVADOS] created: 1.3.0-1394-gb2cce8b18

Git user git at public.curoverse.com
Thu Jul 25 21:31:31 UTC 2019


        at  b2cce8b18dfa70597cfb531cb127bce35d96a8c3 (commit)


commit b2cce8b18dfa70597cfb531cb127bce35d96a8c3
Author: Eric Biagiotti <ebiagiotti at veritasgenetics.com>
Date:   Thu Jul 25 17:18:56 2019 -0400

    14813: Adds ClusterID to config export
    
    Arvados-DCO-1.1-Signed-off-by: Eric Biagiotti <ebiagiotti at veritasgenetics.com>

diff --git a/lib/config/export.go b/lib/config/export.go
index b79dec4d9..ed330454c 100644
--- a/lib/config/export.go
+++ b/lib/config/export.go
@@ -26,6 +26,10 @@ func ExportJSON(w io.Writer, cluster *arvados.Cluster) error {
 	if err != nil {
 		return err
 	}
+
+	// ClusterID is not marshalled by default (see `json:"-"`).
+	// Add it back here so it is included in the exported config.
+	m["ClusterID"] = cluster.ClusterID
 	err = redactUnsafe(m, "", "")
 	if err != nil {
 		return err
@@ -55,54 +59,55 @@ func ExportJSON(w io.Writer, cluster *arvados.Cluster) error {
 // exists.
 var whitelist = map[string]bool{
 	// | sort -t'"' -k2,2
-	"API":                                          true,
-	"API.AsyncPermissionsUpdateInterval":           false,
-	"API.DisabledAPIs":                             false,
-	"API.MaxIndexDatabaseRead":                     false,
-	"API.MaxItemsPerResponse":                      true,
-	"API.MaxRequestAmplification":                  false,
-	"API.MaxRequestSize":                           true,
-	"API.RailsSessionSecretToken":                  false,
-	"API.RequestTimeout":                           true,
-	"AuditLogs":                                    false,
-	"AuditLogs.MaxAge":                             false,
-	"AuditLogs.MaxDeleteBatch":                     false,
-	"AuditLogs.UnloggedAttributes":                 false,
-	"Collections":                                  true,
-	"Collections.BlobSigning":                      true,
-	"Collections.BlobSigningKey":                   false,
-	"Collections.BlobSigningTTL":                   true,
-	"Collections.CollectionVersioning":             false,
-	"Collections.DefaultReplication":               true,
-	"Collections.DefaultTrashLifetime":             true,
-	"Collections.ManagedProperties":                true,
-	"Collections.ManagedProperties.*":              true,
-	"Collections.ManagedProperties.*.*":            true,
-	"Collections.PreserveVersionIfIdle":            true,
-	"Collections.TrashSweepInterval":               false,
-	"Collections.TrustAllContent":                  false,
-	"Containers":                                   true,
-	"Containers.CloudVMs":                          false,
-	"Containers.DefaultKeepCacheRAM":               true,
-	"Containers.DispatchPrivateKey":                false,
-	"Containers.JobsAPI":                           true,
-	"Containers.JobsAPI.CrunchJobUser":             false,
-	"Containers.JobsAPI.CrunchJobWrapper":          false,
-	"Containers.JobsAPI.CrunchRefreshTrigger":      false,
-	"Containers.JobsAPI.DefaultDockerImage":        false,
-	"Containers.JobsAPI.Enable":                    true,
-	"Containers.JobsAPI.GitInternalDir":            false,
-	"Containers.JobsAPI.ReuseJobIfOutputsDiffer":   false,
-	"Containers.Logging":                           false,
-	"Containers.LogReuseDecisions":                 false,
-	"Containers.MaxComputeVMs":                     false,
-	"Containers.MaxDispatchAttempts":               false,
-	"Containers.MaxRetryAttempts":                  true,
-	"Containers.SLURM":                             false,
-	"Containers.StaleLockTimeout":                  false,
-	"Containers.SupportedDockerImageFormats":       true,
-	"Containers.UsePreemptibleInstances":           true,
-	"EnableBetaController14287":                    false,
+	"ClusterID": true,
+	"API":       true,
+	"API.AsyncPermissionsUpdateInterval":         false,
+	"API.DisabledAPIs":                           false,
+	"API.MaxIndexDatabaseRead":                   false,
+	"API.MaxItemsPerResponse":                    true,
+	"API.MaxRequestAmplification":                false,
+	"API.MaxRequestSize":                         true,
+	"API.RailsSessionSecretToken":                false,
+	"API.RequestTimeout":                         true,
+	"AuditLogs":                                  false,
+	"AuditLogs.MaxAge":                           false,
+	"AuditLogs.MaxDeleteBatch":                   false,
+	"AuditLogs.UnloggedAttributes":               false,
+	"Collections":                                true,
+	"Collections.BlobSigning":                    true,
+	"Collections.BlobSigningKey":                 false,
+	"Collections.BlobSigningTTL":                 true,
+	"Collections.CollectionVersioning":           false,
+	"Collections.DefaultReplication":             true,
+	"Collections.DefaultTrashLifetime":           true,
+	"Collections.ManagedProperties":              true,
+	"Collections.ManagedProperties.*":            true,
+	"Collections.ManagedProperties.*.*":          true,
+	"Collections.PreserveVersionIfIdle":          true,
+	"Collections.TrashSweepInterval":             false,
+	"Collections.TrustAllContent":                false,
+	"Containers":                                 true,
+	"Containers.CloudVMs":                        false,
+	"Containers.DefaultKeepCacheRAM":             true,
+	"Containers.DispatchPrivateKey":              false,
+	"Containers.JobsAPI":                         true,
+	"Containers.JobsAPI.CrunchJobUser":           false,
+	"Containers.JobsAPI.CrunchJobWrapper":        false,
+	"Containers.JobsAPI.CrunchRefreshTrigger":    false,
+	"Containers.JobsAPI.DefaultDockerImage":      false,
+	"Containers.JobsAPI.Enable":                  true,
+	"Containers.JobsAPI.GitInternalDir":          false,
+	"Containers.JobsAPI.ReuseJobIfOutputsDiffer": false,
+	"Containers.Logging":                         false,
+	"Containers.LogReuseDecisions":               false,
+	"Containers.MaxComputeVMs":                   false,
+	"Containers.MaxDispatchAttempts":             false,
+	"Containers.MaxRetryAttempts":                true,
+	"Containers.SLURM":                           false,
+	"Containers.StaleLockTimeout":                false,
+	"Containers.SupportedDockerImageFormats":     true,
+	"Containers.UsePreemptibleInstances":         true,
+	"EnableBetaController14287":                  false,
 	"Git":                                          false,
 	"InstanceTypes":                                true,
 	"InstanceTypes.*":                              true,
diff --git a/lib/config/export_test.go b/lib/config/export_test.go
index e12fbdc7f..7af117e38 100644
--- a/lib/config/export_test.go
+++ b/lib/config/export_test.go
@@ -20,11 +20,12 @@ func (s *ExportSuite) TestExport(c *check.C) {
 	confdata := strings.Replace(string(DefaultYAML), "SAMPLE", "testkey", -1)
 	cfg, err := testLoader(c, confdata, nil).Load()
 	c.Assert(err, check.IsNil)
-	cluster := cfg.Clusters["xxxxx"]
+	cluster, err := cfg.GetCluster("xxxxx")
+	c.Assert(err, check.IsNil)
 	cluster.ManagementToken = "abcdefg"
 
 	var exported bytes.Buffer
-	err = ExportJSON(&exported, &cluster)
+	err = ExportJSON(&exported, cluster)
 	c.Check(err, check.IsNil)
 	if err != nil {
 		c.Logf("If all the new keys are safe, add these to whitelist in export.go:")
@@ -32,5 +33,7 @@ func (s *ExportSuite) TestExport(c *check.C) {
 			c.Logf("\t%q: true,", strings.Replace(k, `"`, "", -1))
 		}
 	}
-	c.Check(exported.String(), check.Not(check.Matches), `(?ms).*abcdefg.*`)
+	var exportedStr = exported.String()
+	c.Check(exportedStr, check.Matches, `(?ms).*ClusterID":"xxxxx.*`)
+	c.Check(exportedStr, check.Not(check.Matches), `(?ms).*abcdefg.*`)
 }

commit 9656b85278fa05b4118f98c987fec278168a4b1c
Author: Tom Clegg <tclegg at veritasgenetics.com>
Date:   Wed Jul 24 09:43:18 2019 -0400

    14813: Add CORS headers to "get config" by moving it to arvados.API.
    
    Arvados-DCO-1.1-Signed-off-by: Tom Clegg <tclegg at veritasgenetics.com>

diff --git a/lib/controller/federation/conn.go b/lib/controller/federation/conn.go
index 3addcf4fa..63e801b22 100644
--- a/lib/controller/federation/conn.go
+++ b/lib/controller/federation/conn.go
@@ -5,8 +5,10 @@
 package federation
 
 import (
+	"bytes"
 	"context"
 	"crypto/md5"
+	"encoding/json"
 	"errors"
 	"fmt"
 	"net/http"
@@ -14,6 +16,7 @@ import (
 	"regexp"
 	"strings"
 
+	"git.curoverse.com/arvados.git/lib/config"
 	"git.curoverse.com/arvados.git/lib/controller/railsproxy"
 	"git.curoverse.com/arvados.git/lib/controller/rpc"
 	"git.curoverse.com/arvados.git/sdk/go/arvados"
@@ -177,6 +180,12 @@ func portableDataHash(mt string) string {
 	return fmt.Sprintf("%x+%d", h.Sum(nil), size)
 }
 
+func (conn *Conn) ConfigGet(ctx context.Context) (json.RawMessage, error) {
+	var buf bytes.Buffer
+	err := config.ExportJSON(&buf, conn.cluster)
+	return json.RawMessage(buf.Bytes()), err
+}
+
 func (conn *Conn) CollectionGet(ctx context.Context, options arvados.GetOptions) (arvados.Collection, error) {
 	if len(options.UUID) == 27 {
 		// UUID is really a UUID
diff --git a/lib/controller/handler.go b/lib/controller/handler.go
index 852327fd8..f7b2362f3 100644
--- a/lib/controller/handler.go
+++ b/lib/controller/handler.go
@@ -5,19 +5,16 @@
 package controller
 
 import (
-	"bytes"
 	"context"
 	"database/sql"
 	"errors"
 	"fmt"
-	"io"
 	"net/http"
 	"net/url"
 	"strings"
 	"sync"
 	"time"
 
-	"git.curoverse.com/arvados.git/lib/config"
 	"git.curoverse.com/arvados.git/lib/controller/federation"
 	"git.curoverse.com/arvados.git/lib/controller/railsproxy"
 	"git.curoverse.com/arvados.git/lib/controller/router"
@@ -80,19 +77,10 @@ func (h *Handler) setup() {
 		Routes: health.Routes{"ping": func() error { _, err := h.db(&http.Request{}); return err }},
 	})
 
-	mux.Handle("/arvados/v1/config", http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
-		var buf bytes.Buffer
-		err := config.ExportJSON(&buf, h.Cluster)
-		if err != nil {
-			httpserver.Error(w, err.Error(), http.StatusInternalServerError)
-			return
-		}
-		w.Header().Set("Content-Type", "application/json")
-		io.Copy(w, &buf)
-	}))
+	rtr := router.New(federation.New(h.Cluster))
+	mux.Handle("/arvados/v1/config", rtr)
 
 	if h.Cluster.EnableBetaController14287 {
-		rtr := router.New(federation.New(h.Cluster))
 		mux.Handle("/arvados/v1/collections", rtr)
 		mux.Handle("/arvados/v1/collections/", rtr)
 	}
diff --git a/lib/controller/handler_test.go b/lib/controller/handler_test.go
index fbfb037d3..4b49e4615 100644
--- a/lib/controller/handler_test.go
+++ b/lib/controller/handler_test.go
@@ -68,6 +68,9 @@ func (s *HandlerSuite) TestConfigExport(c *check.C) {
 	resp := httptest.NewRecorder()
 	s.handler.ServeHTTP(resp, req)
 	c.Check(resp.Code, check.Equals, http.StatusOK)
+	c.Check(resp.Header().Get("Access-Control-Allow-Origin"), check.Equals, `*`)
+	c.Check(resp.Header().Get("Access-Control-Allow-Methods"), check.Matches, `.*\bGET\b.*`)
+	c.Check(resp.Header().Get("Access-Control-Allow-Headers"), check.Matches, `.+`)
 	var cluster arvados.Cluster
 	c.Log(resp.Body.String())
 	err := json.Unmarshal(resp.Body.Bytes(), &cluster)
diff --git a/lib/controller/router/router.go b/lib/controller/router/router.go
index 9c2c1f3a1..5d5602df5 100644
--- a/lib/controller/router/router.go
+++ b/lib/controller/router/router.go
@@ -41,6 +41,13 @@ func (rtr *router) addRoutes() {
 		exec        routableFunc
 	}{
 		{
+			arvados.EndpointConfigGet,
+			func() interface{} { return &struct{}{} },
+			func(ctx context.Context, opts interface{}) (interface{}, error) {
+				return rtr.fed.ConfigGet(ctx)
+			},
+		},
+		{
 			arvados.EndpointCollectionCreate,
 			func() interface{} { return &arvados.CreateOptions{} },
 			func(ctx context.Context, opts interface{}) (interface{}, error) {
diff --git a/lib/controller/rpc/conn.go b/lib/controller/rpc/conn.go
index ea3d6fb2d..1028da829 100644
--- a/lib/controller/rpc/conn.go
+++ b/lib/controller/rpc/conn.go
@@ -121,6 +121,13 @@ func (conn *Conn) requestAndDecode(ctx context.Context, dst interface{}, ep arva
 	return aClient.RequestAndDecodeContext(ctx, dst, ep.Method, path, body, params)
 }
 
+func (conn *Conn) ConfigGet(ctx context.Context) (json.RawMessage, error) {
+	ep := arvados.EndpointConfigGet
+	var resp json.RawMessage
+	err := conn.requestAndDecode(ctx, &resp, ep, nil, nil)
+	return resp, err
+}
+
 func (conn *Conn) CollectionCreate(ctx context.Context, options arvados.CreateOptions) (arvados.Collection, error) {
 	ep := arvados.EndpointCollectionCreate
 	var resp arvados.Collection
diff --git a/sdk/go/arvados/api.go b/sdk/go/arvados/api.go
index 71265756d..772f8da97 100644
--- a/sdk/go/arvados/api.go
+++ b/sdk/go/arvados/api.go
@@ -4,7 +4,10 @@
 
 package arvados
 
-import "context"
+import (
+	"context"
+	"encoding/json"
+)
 
 type APIEndpoint struct {
 	Method string
@@ -14,6 +17,7 @@ type APIEndpoint struct {
 }
 
 var (
+	EndpointConfigGet                     = APIEndpoint{"GET", "arvados/v1/config", ""}
 	EndpointCollectionCreate              = APIEndpoint{"POST", "arvados/v1/collections", "collection"}
 	EndpointCollectionUpdate              = APIEndpoint{"PATCH", "arvados/v1/collections/:uuid", "collection"}
 	EndpointCollectionGet                 = APIEndpoint{"GET", "arvados/v1/collections/:uuid", ""}
@@ -80,6 +84,7 @@ type DeleteOptions struct {
 }
 
 type API interface {
+	ConfigGet(ctx context.Context) (json.RawMessage, error)
 	CollectionCreate(ctx context.Context, options CreateOptions) (Collection, error)
 	CollectionUpdate(ctx context.Context, options UpdateOptions) (Collection, error)
 	CollectionGet(ctx context.Context, options GetOptions) (Collection, error)
diff --git a/sdk/go/arvadostest/api.go b/sdk/go/arvadostest/api.go
index 77a26bcba..850bd0639 100644
--- a/sdk/go/arvadostest/api.go
+++ b/sdk/go/arvadostest/api.go
@@ -6,6 +6,7 @@ package arvadostest
 
 import (
 	"context"
+	"encoding/json"
 	"errors"
 	"reflect"
 	"runtime"
@@ -23,6 +24,10 @@ type APIStub struct {
 	mtx   sync.Mutex
 }
 
+func (as *APIStub) ConfigGet(ctx context.Context) (json.RawMessage, error) {
+	as.appendCall(as.ConfigGet, ctx, nil)
+	return nil, as.Error
+}
 func (as *APIStub) CollectionCreate(ctx context.Context, options arvados.CreateOptions) (arvados.Collection, error) {
 	as.appendCall(as.CollectionCreate, ctx, options)
 	return arvados.Collection{}, as.Error

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


hooks/post-receive
-- 




More information about the arvados-commits mailing list