[arvados] updated: 2.1.0-3173-gda416e33b

git repository hosting git at public.arvados.org
Tue Dec 13 19:26:58 UTC 2022


Summary of changes:
 lib/boot/rails_db.go      | 12 +++++++-----
 lib/boot/rails_db_test.go |  7 ++++++-
 2 files changed, 13 insertions(+), 6 deletions(-)

       via  da416e33b7e9fb51c27662ef111bdc4fafcadbcf (commit)
      from  228028e523983a847239fd4a5530d3e54b27cfa5 (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 da416e33b7e9fb51c27662ef111bdc4fafcadbcf
Author: Tom Clegg <tom at curii.com>
Date:   Tue Dec 13 14:24:33 2022 -0500

    19709: Warn, not eror, on unexpected files in db/migrate/.
    
    Arvados-DCO-1.1-Signed-off-by: Tom Clegg <tom at curii.com>

diff --git a/lib/boot/rails_db.go b/lib/boot/rails_db.go
index ad9124d7d..16e150172 100644
--- a/lib/boot/rails_db.go
+++ b/lib/boot/rails_db.go
@@ -6,7 +6,6 @@ package boot
 
 import (
 	"context"
-	"fmt"
 	"io/fs"
 	"os"
 	"path/filepath"
@@ -14,6 +13,7 @@ import (
 
 	"git.arvados.org/arvados.git/lib/controller/dblock"
 	"git.arvados.org/arvados.git/lib/ctrlctx"
+	"github.com/sirupsen/logrus"
 )
 
 type railsDatabase struct{}
@@ -48,7 +48,7 @@ func (runner railsDatabase) Run(ctx context.Context, fail func(error), super *Su
 	// there are no new migrations, that would add ~2s to startup
 	// time / downtime during service restart.
 
-	todo, err := migrationList(appdir)
+	todo, err := migrationList(appdir, super.logger)
 	if err != nil {
 		return err
 	}
@@ -97,7 +97,7 @@ func (runner railsDatabase) Run(ctx context.Context, fail func(error), super *Su
 	return super.RunProgram(ctx, appdir, runOptions{env: railsEnv}, "bundle", "exec", "rake", "db:migrate")
 }
 
-func migrationList(dir string) (map[string]bool, error) {
+func migrationList(dir string, log logrus.FieldLogger) (map[string]bool, error) {
 	todo := map[string]bool{}
 
 	// list versions in db/migrate/{version}_{name}.rb
@@ -107,7 +107,8 @@ func migrationList(dir string) (map[string]bool, error) {
 		}
 		fnm := d.Name()
 		if !strings.HasSuffix(fnm, ".rb") {
-			return fmt.Errorf("unexpected file in db/migrate dir: %s", fnm)
+			log.Warnf("unexpected file in db/migrate dir: %s", fnm)
+			return nil
 		}
 		for i, c := range fnm {
 			if i > 0 && c == '_' {
@@ -118,7 +119,8 @@ func migrationList(dir string) (map[string]bool, error) {
 				// non-numeric character before the
 				// first '_' means this is not a
 				// migration
-				return fmt.Errorf("unexpected file in db/migrate dir: %s", fnm)
+				log.Warnf("unexpected file in db/migrate dir: %s", fnm)
+				return nil
 			}
 		}
 		return nil
diff --git a/lib/boot/rails_db_test.go b/lib/boot/rails_db_test.go
index ac78a3c9a..5711189e7 100644
--- a/lib/boot/rails_db_test.go
+++ b/lib/boot/rails_db_test.go
@@ -5,6 +5,8 @@
 package boot
 
 import (
+	"bytes"
+
 	"git.arvados.org/arvados.git/lib/config"
 	"git.arvados.org/arvados.git/sdk/go/arvadostest"
 	"git.arvados.org/arvados.git/sdk/go/ctxlog"
@@ -17,9 +19,12 @@ var _ = check.Suite(&railsDBSuite{})
 
 // Check services/api/db/migrate/*.rb match schema_migrations
 func (s *railsDBSuite) TestMigrationList(c *check.C) {
-	todo, err := migrationList("../../services/api")
+	var logbuf bytes.Buffer
+	log := ctxlog.New(&logbuf, "text", "info")
+	todo, err := migrationList("../../services/api", log)
 	c.Check(err, check.IsNil)
 	c.Check(todo["20220804133317"], check.Equals, true)
+	c.Check(logbuf.String(), check.Equals, "")
 
 	cfg, err := config.NewLoader(nil, ctxlog.TestLogger(c)).Load()
 	c.Assert(err, check.IsNil)

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


hooks/post-receive
-- 




More information about the arvados-commits mailing list