Skip to content

Commit

Permalink
Switch 'reason' to 'require_resync'
Browse files Browse the repository at this point in the history
  • Loading branch information
adamcfraser committed Jun 24, 2024
1 parent 013b08e commit 7df5299
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 13 deletions.
9 changes: 4 additions & 5 deletions docs/api/components/schemas.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2523,11 +2523,10 @@ CollectionNames:
- Starting
- Stopping
- Resyncing
reason:
description: Optional reason a database is in a particular state.
enum:
- require_resync
- ""
require_resync:
description: Indicates whether the database requires resync before it can be brought online.
type: boolean
example: true
init_in_progress:
description: Indicates whether database initialization is in progress.
type: boolean
Expand Down
8 changes: 4 additions & 4 deletions rest/adminapitest/collections_admin_api_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -265,10 +265,10 @@ func TestRequireResync(t *testing.T) {
// databases sorted alphabetically
require.Equal(t, db1Name, allDBsSummary[0].DBName)
require.Equal(t, db.RunStateString[db.DBOnline], allDBsSummary[0].State)
require.Equal(t, "", allDBsSummary[0].Reason)
require.Equal(t, false, allDBsSummary[0].RequireResync)
require.Equal(t, db2Name, allDBsSummary[1].DBName)
require.Equal(t, db.RunStateString[db.DBOffline], allDBsSummary[1].State)
require.Equal(t, rest.OfflineReasonRequireResync, allDBsSummary[1].Reason)
require.Equal(t, true, allDBsSummary[1].RequireResync)

// Run resync for collection
resyncCollections := make(db.ResyncCollections, 0)
Expand Down Expand Up @@ -296,10 +296,10 @@ func TestRequireResync(t *testing.T) {
// databases sorted alphabetically
require.Equal(t, db1Name, allDBsSummary[0].DBName)
require.Equal(t, db.RunStateString[db.DBOnline], allDBsSummary[0].State)
require.Equal(t, "", allDBsSummary[0].Reason)
require.Equal(t, false, allDBsSummary[0].RequireResync)
require.Equal(t, db2Name, allDBsSummary[1].DBName)
require.Equal(t, db.RunStateString[db.DBOffline], allDBsSummary[1].State)
require.Equal(t, "", allDBsSummary[1].Reason)
require.Equal(t, false, allDBsSummary[1].RequireResync)

resp = rt.SendAdminRequest("GET", "/"+db2Name+"/", "")
rest.RequireStatus(t, resp, http.StatusOK)
Expand Down
2 changes: 1 addition & 1 deletion rest/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -412,7 +412,7 @@ type DbSummary struct {
Bucket string `json:"bucket"`
State string `json:"state"`
InitializationActive bool `json:"init_in_progress,omitempty"`
Reason string `json:"reason,omitempty"`
RequireResync bool `json:"require_resync,omitempty"`
}

func (h *handler) handleGetDB() error {
Expand Down
4 changes: 1 addition & 3 deletions rest/server_context.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,6 @@ const defaultBytesStatsReportingInterval = 30 * time.Second

const dbLoadedStateChangeMsg = "DB loaded from config"

const OfflineReasonRequireResync = "require_resync"

var errCollectionsUnsupported = base.HTTPErrorf(http.StatusBadRequest, "Named collections specified in database config, but not supported by connected Couchbase Server.")

var ErrSuspendingDisallowed = errors.New("database does not allow suspending")
Expand Down Expand Up @@ -363,7 +361,7 @@ func (sc *ServerContext) allDatabaseSummaries() []DbSummary {
}
if state == db.RunStateString[db.DBOffline] {
if len(dbctx.RequireResync.ScopeAndCollectionNames()) > 0 {
summary.Reason = OfflineReasonRequireResync
summary.RequireResync = true
}
}
if sc.DatabaseInitManager.HasActiveInitialization(name) {
Expand Down

0 comments on commit 7df5299

Please sign in to comment.