14813: Adds ClusterID to config export
authorEric Biagiotti <ebiagiotti@veritasgenetics.com>
Thu, 25 Jul 2019 21:18:56 +0000 (17:18 -0400)
committerEric Biagiotti <ebiagiotti@veritasgenetics.com>
Tue, 30 Jul 2019 15:25:55 +0000 (11:25 -0400)
Arvados-DCO-1.1-Signed-off-by: Eric Biagiotti <ebiagiotti@veritasgenetics.com>

lib/config/export.go
lib/config/export_test.go

index 6ff72afcc1eb709e51cf8746672ce4a5014889da..ed330454cc77df1f2601abc872c26facaa821357 100644 (file)
@@ -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,62 +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,
-       "API.WebsocketClientEventQueue":                false,
-       "API.SendTimeout":                              true,
-       "API.WebsocketServerEventQueue":                false,
-       "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.CrunchRunCommand":                  false,
-       "Containers.CrunchRunArgumentsList":            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.MinRetryPeriod":                    true,
-       "Containers.ReserveExtraRAM":                   true,
-       "Containers.SLURM":                             false,
-       "Containers.StaleLockTimeout":                  false,
-       "Containers.SupportedDockerImageFormats":       true,
-       "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,
index e12fbdc7f6aa65ed3f181374aca15f932f2ff0da..7af117e385f405dbe5f0e8acb7d597f55ab77fe4 100644 (file)
@@ -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.*`)
 }