Skip to content

Commit b476cc3

Browse files
committed
CBG-5377 remove serverless options
1 parent 75b8bd0 commit b476cc3

26 files changed

Lines changed: 65 additions & 1176 deletions

base/bootstrap.go

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,6 @@ type CouchbaseClusterSpec struct {
110110
type CouchbaseCluster struct {
111111
server string
112112
clusterOptions gocb.ClusterOptions
113-
forcePerBucketAuth bool // Forces perBucketAuth authenticators to be used to connect to the bucket
114113
perBucketAuth map[string]*gocb.Authenticator
115114
bucketConnectionMode BucketConnectionMode // Whether to cache cluster connections
116115
cachedClusterConnection *gocb.Cluster // Cached cluster connection, should only be used by GetConfigBuckets
@@ -236,7 +235,7 @@ var _ BootstrapConnection = &CouchbaseCluster{}
236235
// _system._mobile is the source of truth and reads transparently fall back to _default._default
237236
// for any keys that have not yet been migrated; when false, _default._default is used unconditionally.
238237
func NewCouchbaseCluster(ctx context.Context, clusterSpec CouchbaseClusterSpec,
239-
forcePerBucketAuth bool, perBucketCreds PerBucketCredentialsConfig,
238+
perBucketCreds PerBucketCredentialsConfig,
240239
useXattrConfig bool, useSystemMetadataCollection bool, bucketMode BucketConnectionMode) (*CouchbaseCluster, error) {
241240
securityConfig, err := GoCBv2SecurityConfig(ctx, Ptr(clusterSpec.TLSSkipVerify), clusterSpec.CACertpath)
242241
if err != nil {
@@ -273,7 +272,6 @@ func NewCouchbaseCluster(ctx context.Context, clusterSpec CouchbaseClusterSpec,
273272

274273
cbCluster := &CouchbaseCluster{
275274
server: clusterSpec.Server,
276-
forcePerBucketAuth: forcePerBucketAuth,
277275
perBucketAuth: perBucketAuth,
278276
clusterOptions: clusterOptions,
279277
bucketConnectionMode: bucketMode,
@@ -1115,8 +1113,6 @@ func defaultCollectionExists(b *gocb.Bucket) (bool, error) {
11151113
func (cc *CouchbaseCluster) GetClusterConnectionForBucket(ctx context.Context, bucketName string) (connection *gocb.Cluster, teardownFn func(), err error) {
11161114
if bucketAuth, set := cc.perBucketAuth[bucketName]; set {
11171115
connection, err = cc.connect(bucketAuth)
1118-
} else if cc.forcePerBucketAuth {
1119-
return nil, nil, fmt.Errorf("unable to get bucket %q since credentials are not defined in bucket_credentials", MD(bucketName).Redact())
11201116
} else {
11211117
connection, err = cc.connect(nil)
11221118
}

base/bootstrap_test.go

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,7 @@ func TestBootstrapRefCounting(t *testing.T) {
5353
}, 2*time.Minute, 5*time.Millisecond) // Wait for bucket pool to be initialized, since GetConfigBuckets requires equal buckets to TestBucketPool.numBuckets
5454

5555
var perBucketCredentialsConfig map[string]*CredentialsConfig
56-
forcePerBucketAuth := false
57-
cluster, err := NewCouchbaseCluster(ctx, TestClusterSpec(t), forcePerBucketAuth, perBucketCredentialsConfig, TestUseXattrs(), false, CachedClusterConnections)
56+
cluster, err := NewCouchbaseCluster(ctx, TestClusterSpec(t), perBucketCredentialsConfig, TestUseXattrs(), false, CachedClusterConnections)
5857
require.NoError(t, err)
5958
defer cluster.Close()
6059
require.NotNil(t, cluster)
@@ -146,7 +145,7 @@ func newTestBootstrapConnection(t *testing.T) BootstrapConnection {
146145
t.Cleanup(cluster.Close)
147146
return cluster
148147
}
149-
cluster, err := NewCouchbaseCluster(ctx, TestClusterSpec(t), false, nil, TestUseXattrs(), false, CachedClusterConnections)
148+
cluster, err := NewCouchbaseCluster(ctx, TestClusterSpec(t), nil, TestUseXattrs(), false, CachedClusterConnections)
150149
require.NoError(t, err)
151150
t.Cleanup(cluster.Close)
152151
return cluster
@@ -360,7 +359,7 @@ func newCouchbaseBootstrapDualFixture(t *testing.T, useXattrs bool) bootstrapDua
360359
assert.Equal(c, int32(GTestBucketPool.numBuckets), GTestBucketPool.stats.TotalBucketInitCount.Load())
361360
}, 2*time.Minute, 5*time.Millisecond)
362361

363-
cluster, err := NewCouchbaseCluster(ctx, TestClusterSpec(t), false, nil, useXattrs, true, CachedClusterConnections)
362+
cluster, err := NewCouchbaseCluster(ctx, TestClusterSpec(t), nil, useXattrs, true, CachedClusterConnections)
364363
require.NoError(t, err)
365364
t.Cleanup(cluster.Close)
366365

@@ -469,7 +468,7 @@ func newCouchbaseBootstrapTwoBucketDualFixture(t *testing.T, useXattrs bool) boo
469468
assert.Equal(c, int32(GTestBucketPool.numBuckets), GTestBucketPool.stats.TotalBucketInitCount.Load())
470469
}, 2*time.Minute, 5*time.Millisecond)
471470

472-
cluster, err := NewCouchbaseCluster(ctx, TestClusterSpec(t), false, nil, useXattrs, true, CachedClusterConnections)
471+
cluster, err := NewCouchbaseCluster(ctx, TestClusterSpec(t), nil, useXattrs, true, CachedClusterConnections)
473472
require.NoError(t, err)
474473
t.Cleanup(cluster.Close)
475474

base/constants.go

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -106,12 +106,6 @@ const (
106106
// Number of kv connections (pipelines) per Couchbase Server node
107107
DefaultGocbKvPoolSize = 2
108108

109-
// Number of kv connections (pipelines) per Couchbase Server node when running in serverless
110-
DefaultGocbKvPoolSizeServerless = 1
111-
112-
// kv connections buffer size per Couchbase Server node when running in serverless
113-
DefaultKvBufferSizeServerless = 1 * 1024 * 1024
114-
115109
// Number of connections used by DCP agents - must be 1
116110
GoCBPoolSizeDCP = 1
117111

base/dcp_sharded.go

Lines changed: 7 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,13 @@ import (
2727
)
2828

2929
const (
30-
CBGTIndexTypeSyncGatewayImport = "syncGateway-import-"
31-
DefaultImportPartitions = 16
32-
DefaultImportPartitionsServerless = 6
33-
CBGTCfgIndexDefs = SyncDocPrefix + "cfgindexDefs"
34-
CBGTCfgNodeDefsKnown = SyncDocPrefix + "cfgnodeDefs-known"
35-
CBGTCfgNodeDefsWanted = SyncDocPrefix + "cfgnodeDefs-wanted"
36-
CBGTCfgPlanPIndexes = SyncDocPrefix + "cfgplanPIndexes"
37-
CBGTIndexTypeSyncGatewayResync = "syncGateway-resync"
30+
CBGTIndexTypeSyncGatewayImport = "syncGateway-import-"
31+
DefaultImportPartitions = 16
32+
CBGTCfgIndexDefs = SyncDocPrefix + "cfgindexDefs"
33+
CBGTCfgNodeDefsKnown = SyncDocPrefix + "cfgnodeDefs-known"
34+
CBGTCfgNodeDefsWanted = SyncDocPrefix + "cfgnodeDefs-wanted"
35+
CBGTCfgPlanPIndexes = SyncDocPrefix + "cfgplanPIndexes"
36+
CBGTIndexTypeSyncGatewayResync = "syncGateway-resync"
3837
)
3938

4039
// CbgtUnregisterFeedCallback is the function invoked by cbgt when a DCP feed shuts down.
@@ -910,14 +909,6 @@ func RemoveDestFactory(destKey string) {
910909
cbgtDestFactoriesLock.Unlock()
911910
}
912911

913-
func GetDefaultImportPartitions(serverless bool) uint16 {
914-
if serverless {
915-
return DefaultImportPartitionsServerless
916-
} else {
917-
return DefaultImportPartitions
918-
}
919-
}
920-
921912
type sgMgrEventHandlers struct {
922913
ctx context.Context
923914
ctxCancel context.CancelCauseFunc

base/gocb_connection_string.go

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ const (
2222
kvPoolSizeKey = "kv_pool_size"
2323
)
2424

25-
// GoCBConnStringParams represents parameters that are passed to gocb when creating a new connection string. These are the subset of values that are changed when running with serverless mode.
25+
// GoCBConnStringParams represents parameters that are passed to gocb when creating a new connection string.
2626
type GoCBConnStringParams struct {
2727
KvPoolSize int // corresponds to kv_pool_size
2828
KvBufferSize int // corresponds to kv_buffer_size
@@ -38,15 +38,6 @@ func DefaultGoCBConnStringParams() *GoCBConnStringParams {
3838
}
3939
}
4040

41-
// DefaultServerlessGoCBConnStringParams returns a GoCBConnStringParams with the default values for serverless deployments.
42-
func DefaultServerlessGoCBConnStringParams() *GoCBConnStringParams {
43-
return &GoCBConnStringParams{
44-
KvPoolSize: DefaultGocbKvPoolSizeServerless,
45-
KvBufferSize: DefaultKvBufferSizeServerless,
46-
DcpBufferSize: DefaultDCPBufferServerless,
47-
}
48-
}
49-
5041
// getGoCBConnSpec returns a gocb connection spec based on the server string. The provided defaults will be used only when the corresponding property is not set in the connection string.
5142
func getGoCBConnSpec(server string, defaults *GoCBConnStringParams) (*gocbconnstr.ConnSpec, error) {
5243
connSpec, err := gocbconnstr.Parse(server)

base/gocb_connection_string_test.go

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,6 @@ func TestGetGoCBConnStringWithDefaults(t *testing.T) {
3232
connStr: "couchbase://127.0.0.1?idle_http_connection_timeout=90000&kv_pool_size=2&max_idle_http_connections=64000&max_perhost_idle_http_connections=256",
3333
params: DefaultGoCBConnStringParams(),
3434
},
35-
{
36-
name: "default, serverless params",
37-
server: "couchbase://127.0.0.1",
38-
connStr: "couchbase://127.0.0.1?dcp_buffer_size=1048576&idle_http_connection_timeout=90000&kv_buffer_size=1048576&kv_pool_size=1&max_idle_http_connections=64000&max_perhost_idle_http_connections=256",
39-
params: DefaultServerlessGoCBConnStringParams(),
40-
},
4135
{
4236
name: "kv_pool_size=8, no params",
4337
server: "couchbase://127.0.0.1?kv_pool_size=8",
@@ -49,12 +43,6 @@ func TestGetGoCBConnStringWithDefaults(t *testing.T) {
4943
connStr: "couchbase://127.0.0.1?idle_http_connection_timeout=90000&kv_pool_size=8&max_idle_http_connections=64000&max_perhost_idle_http_connections=256",
5044
params: DefaultGoCBConnStringParams(),
5145
},
52-
{
53-
name: "kv_pool_size=8, serverless params",
54-
server: "couchbase://127.0.0.1?kv_pool_size=8",
55-
connStr: "couchbase://127.0.0.1?dcp_buffer_size=1048576&idle_http_connection_timeout=90000&kv_buffer_size=1048576&kv_pool_size=8&max_idle_http_connections=64000&max_perhost_idle_http_connections=256",
56-
params: DefaultServerlessGoCBConnStringParams(),
57-
},
5846
{
5947
name: "kv_buffer_size=3, no params",
6048
server: "couchbase://127.0.0.1?kv_buffer_size=3",
@@ -66,12 +54,6 @@ func TestGetGoCBConnStringWithDefaults(t *testing.T) {
6654
connStr: "couchbase://127.0.0.1?idle_http_connection_timeout=90000&kv_buffer_size=3&kv_pool_size=2&max_idle_http_connections=64000&max_perhost_idle_http_connections=256",
6755
params: DefaultGoCBConnStringParams(),
6856
},
69-
{
70-
name: "kv_buffer_size=3, serverless params",
71-
server: "couchbase://127.0.0.1?kv_buffer_size=3",
72-
connStr: "couchbase://127.0.0.1?dcp_buffer_size=1048576&idle_http_connection_timeout=90000&kv_buffer_size=3&kv_pool_size=1&max_idle_http_connections=64000&max_perhost_idle_http_connections=256",
73-
params: DefaultServerlessGoCBConnStringParams(),
74-
},
7557
{
7658
name: "dcp_buffer_size=3, no params",
7759
server: "couchbase://127.0.0.1?dcp_buffer_size=3",
@@ -83,12 +65,6 @@ func TestGetGoCBConnStringWithDefaults(t *testing.T) {
8365
connStr: "couchbase://127.0.0.1?dcp_buffer_size=3&idle_http_connection_timeout=90000&kv_pool_size=2&max_idle_http_connections=64000&max_perhost_idle_http_connections=256",
8466
params: DefaultGoCBConnStringParams(),
8567
},
86-
{
87-
name: "dcp_pool_size=3, serverless params",
88-
server: "couchbase://127.0.0.1?dcp_buffer_size=3",
89-
connStr: "couchbase://127.0.0.1?dcp_buffer_size=3&idle_http_connection_timeout=90000&kv_buffer_size=1048576&kv_pool_size=1&max_idle_http_connections=64000&max_perhost_idle_http_connections=256",
90-
params: DefaultServerlessGoCBConnStringParams(),
91-
},
9268
}
9369
for _, testCase := range testCases {
9470
t.Run(testCase.name, func(t *testing.T) {

base/gocb_dcp_client.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,6 @@ const openStreamTimeout = 30 * time.Second
2929
const openRetryCount = uint32(10)
3030
const DefaultNumWorkers = 8
3131

32-
// DCP buffer size if we are running in serverless
33-
const DefaultDCPBufferServerless = 1 * 1024 * 1024
34-
3532
const getVbSeqnoTimeout = 30 * time.Second
3633

3734
const infiniteOpenStreamRetries = uint32(math.MaxUint32)

base/rosmar_cluster.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -706,8 +706,6 @@ func (c *RosmarCluster) CachedBootstrapTargets() map[string]string {
706706
func (c *RosmarCluster) Close() {
707707
}
708708

709-
func (c *RosmarCluster) SetConnectionStringServerless() error { return nil }
710-
711709
// AsRosmarBucket returns a bucket as a rosmar.Bucket, or an error if it is not one.
712710
func AsRosmarBucket(bucket Bucket) (*rosmar.Bucket, error) {
713711
baseBucket := GetBaseBucket(bucket)

docs/api/components/schemas.yaml

Lines changed: 5 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1668,13 +1668,6 @@ Database:
16681668
Disable this when you are confident all clients use newer CV-based revisions and no longer require legacy RevTree ID lookups.
16691669
type: boolean
16701670
default: true
1671-
suspendable:
1672-
description: |-
1673-
Set to true to allow the database to be suspended.
1674-
1675-
Defaults to true when running in serverless mode otherwise defaults to false.
1676-
type: boolean
1677-
default: false
16781671
sync:
16791672
description: |-
16801673
The Javascript function that newly created documents are ran through for the default scope and collection.
@@ -1827,6 +1820,11 @@ Database:
18271820
The maximum number of revisions to store in the revision cache.
18281821
type: number
18291822
deprecated: true
1823+
suspendable:
1824+
description: This option has no effect.
1825+
type: boolean
1826+
default: false
1827+
deprecated: true
18301828
title: Database-config
18311829
Disabled-users-and-roles:
18321830
type: object
@@ -2174,21 +2172,6 @@ Compact-status:
21742172
- start_time
21752173
- last_error
21762174
title: Compact-status
2177-
Serverless:
2178-
description: Configuration for when SG is running in serverless mode
2179-
type: object
2180-
properties:
2181-
enabled:
2182-
description: Run SG in to serverless mode
2183-
type: boolean
2184-
readOnly: true
2185-
min_config_fetch_interval:
2186-
description: |-
2187-
How long database configs should be kept for in Sync Gateway before refreshing. Set to 0 to fetch configs everytime. This is used for requested databases that SG does not know about.
2188-
2189-
This is a duration and therefore can be provided with units "h", "m", "s", "ms", "us", and "ns". For example, 5 hours, 20 minutes, and 30 seconds would be `5h20m30s`.
2190-
type: string
2191-
default: 1s
21922175
Startup-config:
21932176
type: object
21942177
x-requirePropertiesSorted: true
@@ -2477,8 +2460,6 @@ Startup-config:
24772460
description: Whether HTTP2 support is enabled
24782461
type: boolean
24792462
default: false
2480-
serverless:
2481-
$ref: '#/Serverless'
24822463
stats_log_frequency:
24832464
description: |-
24842465
How often should stats be written to stats logs.

rest/admin_api.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ func (h *handler) handleCreateDB() error {
104104

105105
dbCreds, _ := h.server.Config.DatabaseCredentials[dbName]
106106
bucketCreds, _ := h.server.Config.BucketCredentials[bucket]
107-
if err := config.setup(h.ctx(), dbName, h.server.Config.Bootstrap, dbCreds, bucketCreds, h.server.Config.IsServerless()); err != nil {
107+
if err := config.setup(h.ctx(), dbName, h.server.Config.Bootstrap, dbCreds, bucketCreds); err != nil {
108108
return err
109109
}
110110

@@ -167,7 +167,7 @@ func (h *handler) handleCreateDB() error {
167167
h.server._dbConfigs[dbName].cfgCas = cas
168168
} else {
169169
// Intentionally pass in an empty BootstrapConfig to avoid inheriting any credentials or server when running with a legacy config (CBG-1764)
170-
if err := config.setup(h.ctx(), dbName, BootstrapConfig{}, nil, nil, false); err != nil {
170+
if err := config.setup(h.ctx(), dbName, BootstrapConfig{}, nil, nil); err != nil {
171171
return err
172172
}
173173

@@ -805,7 +805,7 @@ func (h *handler) updateConfigAndReloadDatabase(ctx base.NonCancellableContext,
805805

806806
dbCreds, _ := h.server.Config.DatabaseCredentials[dbName]
807807
bucketCreds, _ := h.server.Config.BucketCredentials[bucket]
808-
if err := updatedDbConfig.setup(ctx.Ctx, dbName, h.server.Config.Bootstrap, dbCreds, bucketCreds, h.server.Config.IsServerless()); err != nil {
808+
if err := updatedDbConfig.setup(ctx.Ctx, dbName, h.server.Config.Bootstrap, dbCreds, bucketCreds); err != nil {
809809
return err
810810
}
811811

@@ -839,7 +839,7 @@ func (h *handler) updateNonPersistentDbConfig(ctx base.NonCancellableContext, db
839839
}
840840

841841
dbCreds, _ := h.server.Config.DatabaseCredentials[dbName]
842-
if err := updatedDbConfig.setup(ctx.Ctx, dbName, h.server.Config.Bootstrap, dbCreds, nil, false); err != nil {
842+
if err := updatedDbConfig.setup(ctx.Ctx, dbName, h.server.Config.Bootstrap, dbCreds, nil); err != nil {
843843
return err
844844
}
845845
if err := h.server.ReloadDatabaseWithConfig(ctx, *updatedDbConfig); err != nil {
@@ -993,7 +993,7 @@ func (h *handler) handlePutDbConfig() (err error) {
993993
tmpConfig.cfgCas = bucketDbConfig.cfgCas
994994
dbCreds, _ := h.server.Config.DatabaseCredentials[dbName]
995995
bucketCreds, _ := h.server.Config.BucketCredentials[bucket]
996-
if err := tmpConfig.setup(h.ctx(), dbName, h.server.Config.Bootstrap, dbCreds, bucketCreds, h.server.Config.IsServerless()); err != nil {
996+
if err := tmpConfig.setup(h.ctx(), dbName, h.server.Config.Bootstrap, dbCreds, bucketCreds); err != nil {
997997
return nil, err
998998
}
999999

0 commit comments

Comments
 (0)