Skip to content

Commit

Permalink
GOCBC-597: Don't set replicaNumber for memcached buckets
Browse files Browse the repository at this point in the history
Motivation
----------
As of 6.5 when creating a bucket the server will error if
the replicaNumber field is present for memcached buckets.

Changes
-------
On bucket create/edit check if replicaNumber is set to 0 and
it's a memcached bucket. If so then omit the field.

Change-Id: I0cdac80d044dd1ef7770e3657f4df10cd0b0573a
Reviewed-on: http://review.couchbase.org/114697
Reviewed-by: Brett Lawson <brett19@gmail.com>
Tested-by: Charles Dixon <chvckd@gmail.com>
  • Loading branch information
chvck committed Sep 18, 2019
1 parent d324e4f commit e39cbf9
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions cluster_bucketmgr.go
Expand Up @@ -528,15 +528,18 @@ func (bm *BucketManager) settingsToPostData(settings *BucketSettings) (url.Value
posts.Add("replicaIndex", "1")
}

posts.Add("replicaNumber", fmt.Sprintf("%d", settings.NumReplicas))

switch settings.BucketType {
case CouchbaseBucketType:
posts.Add("bucketType", string(settings.BucketType))
posts.Add("replicaNumber", fmt.Sprintf("%d", settings.NumReplicas))
case MemcachedBucketType:
posts.Add("bucketType", string(settings.BucketType))
if settings.NumReplicas > 0 {
return nil, configurationError{message: "replicas cannot be used with memcached buckets"}
}
case EphemeralBucketType:
posts.Add("bucketType", string(settings.BucketType))
posts.Add("replicaNumber", fmt.Sprintf("%d", settings.NumReplicas))
default:
return nil, bucketManagerError{message: "Unrecognized bucket type"}
}
Expand Down

0 comments on commit e39cbf9

Please sign in to comment.