Skip to content

Commit bc027c9

Browse files
committed
MB-66604 Add --enable-cross-cluster-versioning to bucket-edit
Change-Id: I6a6a636c91a94eaabbe7dbd15b1c59545b06cf5a Reviewed-on: https://review.couchbase.org/c/couchbase-cli/+/227957 Tested-by: Build Bot <build@couchbase.com> Reviewed-by: Safian Ali <safian.ali@couchbase.com>
1 parent 9d355a0 commit bc027c9

4 files changed

Lines changed: 35 additions & 6 deletions

File tree

cbmgr.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1429,6 +1429,9 @@ def __init__(self):
14291429
type=(int),
14301430
help="The number of seconds of acceptable drift at which new CAS values will be accepted")
14311431

1432+
group.add_argument("--enable-cross-cluster-versioning", dest="xcluster_versioning", action='store_true')
1433+
group.add_argument("--force", dest="force", action='store_true')
1434+
14321435
@rest_initialiser(cluster_init_check=True, version_check=True, enterprise_check=False)
14331436
def execute(self, opts):
14341437
if opts.max_ttl and not self.enterprise:
@@ -1520,6 +1523,10 @@ def execute(self, opts):
15201523
if opts.dek_lifetime:
15211524
dek_lifetime = opts.dek_lifetime * 24 * 60 * 60
15221525

1526+
if opts.xcluster_versioning and not opts.force:
1527+
if not prompt_for_confirmation('Cross-cluster versioning cannot be turned off.'):
1528+
return
1529+
15231530
_, errors = self.rest.edit_bucket(opts.bucket_name, opts.memory_quota, opts.durability_min_level,
15241531
opts.eviction_policy, opts.replica_count, priority, opts.enable_flush,
15251532
opts.max_ttl, opts.compression_mode, opts.remove_port, opts.db_frag_perc,
@@ -1529,7 +1536,7 @@ def execute(self, opts):
15291536
opts.history_retention_bytes, opts.history_retention_seconds,
15301537
opts.enable_history_retention, opts.rank, opts.encryption_key,
15311538
dek_rotate_interval, dek_lifetime, is_couchbase_bucket, opts.invalid_hlc_strategy,
1532-
opts.hlc_max_future_threshold)
1539+
opts.hlc_max_future_threshold, opts.xcluster_versioning)
15331540
_exit_if_errors(errors)
15341541

15351542
_success("Bucket edited")

cluster_manager.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1257,7 +1257,7 @@ def edit_bucket(self, name, memory_quota, durability_min_level, eviction_policy,
12571257
abort_outside, paralleldb_and_view_compact, purge_interval,
12581258
history_retention_bytes, history_retention_seconds, history_retention_default,
12591259
rank, encryption_key, dek_rotation_interval, dek_lifetime, couchbase_bucket: bool = True,
1260-
invalid_hlc_strategy=None, hlc_max_future_threshold=None):
1260+
invalid_hlc_strategy=None, hlc_max_future_threshold=None, xcluster_versioning: bool = False):
12611261
url = f'{self.hostname}/pools/default/buckets/{name}'
12621262

12631263
if name is None:
@@ -1331,6 +1331,9 @@ def edit_bucket(self, name, memory_quota, durability_min_level, eviction_policy,
13311331
if hlc_max_future_threshold is not None:
13321332
params["hlcMaxFutureThreshold"] = hlc_max_future_threshold
13331333

1334+
if xcluster_versioning:
1335+
params["enableCrossClusterVersioning"] = "true"
1336+
13341337
return self._post_form_encoded(url, params)
13351338

13361339
def delete_bucket(self, name):

docs/modules/cli/pages/cbcli/couchbase-cli-bucket-edit.adoc

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ _couchbase-cli bucket-edit_ [--cluster <url>] [--username <user>]
3131
[--enable-history-retention-by-default <0|1>] [--rank <num>]
3232
[--encryption-key <key>] [--dek-rotate-every <days>] [--dek-lifetime <days>]
3333
[--invalid-hlc-strategy <error|ignore|replace>] [--hlc-max-future-threshold <seconds>]
34+
[--enable-cross-cluster-versioning]
3435

3536
== DESCRIPTION
3637

@@ -212,20 +213,26 @@ Run index and data compaction in parallel. Global setting only.
212213
rank "0". The default rank for a bucket is 0.
213214

214215
--encryption-key <key>::
215-
The key that should be used to encrypt the bucket.
216+
The key that should be used to encrypt the bucket.
216217

217218
--dek-rotate-every <days>::
218-
The number of days after which the DEK (Data Encryption Key) should be rotated.
219+
The number of days after which the DEK (Data Encryption Key) should be rotated.
219220

220221
--dek-lifetime <days>::
221-
The number of days which the DEK (Data Encryption Key) should be kept for.
222+
The number of days which the DEK (Data Encryption Key) should be kept for.
222223

223224
--invalid-hlc-strategy <error|ignore|replace>::
224225
Sets the invalid HLC strategy, used to handle invalid CAS values.
225226
(Can be error, ignore or replace)
226227

227228
--hlc-max-future-threshold <seconds>::
228-
The number of seconds of acceptable drift at which new CAS values will be accepted.
229+
The number of seconds of acceptable drift at which new CAS values will be accepted.
230+
231+
--enable-cross-cluster-versioning::
232+
Turn on cross-cluster versioning for this bucket. This setting cannot be turned off.
233+
234+
--force::
235+
Skip any prompts asking you whether to continue.
229236

230237
include::{partialsdir}/cbcli/part-common-history-retention.adoc[]
231238

test/test_cli.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -866,6 +866,18 @@ def test_bucket_edit_hlc_threshold_invalid(self):
866866
self.assertIn("--hlc-max-future-threshold cannot be lower than 10",
867867
self.str_output)
868868

869+
def test_bucket_edit_cross_cluster_versioning(self):
870+
self.server_args['buckets'].append(self.bucket_membase)
871+
self.no_error_run(self.command + self.command_args + self.command_couch_args + self.command_EE_args +
872+
['--enable-cross-cluster-versioning', '--force'],
873+
self.server_args)
874+
expected_params = [
875+
'evictionPolicy=fullEviction', 'flushEnabled=1', 'threadsNumber=8', 'replicaNumber=0', 'maxTTL=20',
876+
'compressionMode=active', 'ramQuotaMB=100', 'rank=3', 'enableCrossClusterVersioning=true',
877+
]
878+
879+
self.rest_parameter_match(expected_params)
880+
869881

870882
class TestBucketFlush(CommandTest):
871883
def setUp(self):

0 commit comments

Comments
 (0)