Skip to content

Commit

Permalink
Finalize import
Browse files Browse the repository at this point in the history
  • Loading branch information
barroco committed Nov 19, 2024
1 parent 2c46459 commit 2e88961
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 95 deletions.
8 changes: 4 additions & 4 deletions cmds/core-service/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ const (
codeRetryable = stacktrace.ErrorCode(1)
)

func getDBStats(ctx context.Context, db *cockroach.DB, databaseName string) {
func getDBStats(ctx context.Context, db *datastore.Datastore, databaseName string) {
logger := logging.WithValuesFromContext(ctx, logging.Logger)
statsPtr := db.Pool.Stat()
stats := make(map[string]string)
Expand Down Expand Up @@ -109,7 +109,7 @@ func createKeyResolver() (auth.KeyResolver, error) {
func createRIDServers(ctx context.Context, locality string, logger *zap.Logger) (*rid_v1.Server, *rid_v2.Server, error) {
connectParameters := flags.ConnectParameters()
connectParameters.DBName = "rid"
ridCrdb, err := cockroach.Dial(ctx, connectParameters)
ridCrdb, err := datastore.Dial(ctx, connectParameters)
if err != nil {
// TODO: More robustly detect failure to create RID server is due to a problem that may be temporary
if strings.Contains(err.Error(), "connect: connection refused") {
Expand All @@ -123,7 +123,7 @@ func createRIDServers(ctx context.Context, locality string, logger *zap.Logger)
// try DBName of defaultdb for older versions.
ridCrdb.Pool.Close()
connectParameters.DBName = "defaultdb"
ridCrdb, err := cockroach.Dial(ctx, connectParameters)
ridCrdb, err := datastore.Dial(ctx, connectParameters)
if err != nil {
return nil, nil, stacktrace.Propagate(err, "Failed to connect to remote ID database for older version <defaultdb>; verify your database configuration is current with https://github.com/interuss/dss/tree/master/build#upgrading-database-schemas")
}
Expand Down Expand Up @@ -176,7 +176,7 @@ func createRIDServers(ctx context.Context, locality string, logger *zap.Logger)
func createSCDServer(ctx context.Context, logger *zap.Logger) (*scd.Server, error) {
connectParameters := flags.ConnectParameters()
connectParameters.DBName = scdc.DatabaseName
scdCrdb, err := cockroach.Dial(ctx, connectParameters)
scdCrdb, err := datastore.Dial(ctx, connectParameters)
if err != nil {
return nil, stacktrace.Propagate(err, "Failed to connect to strategic conflict detection database; verify your database configuration is current with https://github.com/interuss/dss/tree/master/build#upgrading-database-schemas")
}
Expand Down
2 changes: 1 addition & 1 deletion cmds/db-manager/cleanup/evict.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ func getSCDStore(ctx context.Context) (*scdc.Store, error) {
connectParameters := crdbflags.ConnectParameters()
connectParameters.ApplicationName = "db-manager"
connectParameters.DBName = scdc.DatabaseName
scdCrdb, err := cockroach.Dial(ctx, connectParameters)
scdCrdb, err := datastore.Dial(ctx, connectParameters)
if err != nil {
logParams := connectParameters
logParams.Credentials.Password = "[REDACTED]"
Expand Down
81 changes: 0 additions & 81 deletions pkg/datastore/cockroach.go

This file was deleted.

10 changes: 5 additions & 5 deletions pkg/rid/store/cockroach/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ type repo struct {
// TODO: Add the SCD interfaces here, and collapse this store with the
// outer pkg/cockroach
type Store struct {
db *cockroach.DB
db *datastore.Datastore
logger *zap.Logger
clock clockwork.Clock
version *semver.Version
Expand All @@ -60,8 +60,8 @@ type Store struct {
}

// NewStore returns a Store instance connected to a cockroach instance via db.
func NewStore(ctx context.Context, db *cockroach.DB, dbName string, logger *zap.Logger) (*Store, error) {
vs, err := db.GetVersion(ctx, dbName)
func NewStore(ctx context.Context, db *datastore.Datastore, dbName string, logger *zap.Logger) (*Store, error) {
vs, err := db.GetSchemaVersion(ctx, dbName)
if err != nil {
return nil, stacktrace.Propagate(err, "Failed to get database schema version for remote ID for db : %s", dbName)
}
Expand All @@ -87,7 +87,7 @@ func (s *Store) CheckCurrentMajorSchemaVersion(ctx context.Context) error {
if err != nil {
return stacktrace.Propagate(err, "Failed to get database schema version for remote ID")
}
if vs == cockroach.UnknownVersion {
if vs == datastore.UnknownVersion {
return stacktrace.NewError("Remote ID database has not been bootstrapped with Schema Manager, Please check https://github.com/interuss/dss/tree/master/build#updgrading-database-schemas")
}

Expand Down Expand Up @@ -169,7 +169,7 @@ func (s *Store) CleanUp(ctx context.Context) error {
// If the DB was is not bootstrapped using the schema manager we throw and error
func (s *Store) GetVersion(ctx context.Context) (*semver.Version, error) {
if s.version == nil {
vs, err := s.db.GetVersion(ctx, s.DatabaseName)
vs, err := s.db.GetSchemaVersion(ctx, s.DatabaseName)
if err != nil {
return nil, stacktrace.Propagate(err, "Failed to get database schema version for remote ID")
}
Expand Down
8 changes: 4 additions & 4 deletions pkg/scd/store/cockroach/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,12 @@ type repo struct {
// Store is an implementation of an scd.Store using
// a CockroachDB database.
type Store struct {
db *cockroach.DB
db *datastore.Datastore
clock clockwork.Clock
}

// NewStore returns a Store instance connected to a cockroach instance via db.
func NewStore(ctx context.Context, db *cockroach.DB) (*Store, error) {
func NewStore(ctx context.Context, db *datastore.Datastore) (*Store, error) {
store := &Store{
db: db,
clock: DefaultClock,
Expand All @@ -62,7 +62,7 @@ func (s *Store) CheckCurrentMajorSchemaVersion(ctx context.Context) error {
if err != nil {
return stacktrace.Propagate(err, "Failed to get database schema version for strategic conflict detection")
}
if vs == cockroach.UnknownVersion {
if vs == datastore.UnknownVersion {
return stacktrace.NewError("Strategic conflict detection database has not been bootstrapped with Schema Manager, Please check https://github.com/interuss/dss/tree/master/build#upgrading-database-schemas")
}

Expand Down Expand Up @@ -101,5 +101,5 @@ func (s *Store) Close() error {
// GetVersion returns the Version string for the Database.
// If the DB was is not bootstrapped using the schema manager we throw and error
func (s *Store) GetVersion(ctx context.Context) (*semver.Version, error) {
return s.db.GetVersion(ctx, DatabaseName)
return s.db.GetSchemaVersion(ctx, DatabaseName)
}

0 comments on commit 2e88961

Please sign in to comment.