Uploaded image for project: 'Couchbase Server'
  1. Couchbase Server
  2. MB-41611

XDCR RemoteCluster REST API to provide target bucket manifest

    XMLWordPrintable

Details

    • Task
    • Resolution: Fixed
    • Major
    • 7.0.0
    • Cheshire-Cat
    • XDCR

    Description

      It is meant mainly for UI, but this REST is available given a XDCR RemoteCluster read authentication.

      Currently, the XDCR remoteCluster REST endpoint returns a list of remote clusters:

      neil.huang@NeilsMacbookPro:~$ curl -X GET -u Administrator:wewewe http://127.0.0.1:9000/pools/default/remoteClusters27.0.0.1:9000/pools/default/remoteClusters
      [{"connectivityStatus":"RC_OK","deleted":false,"hostname":"127.0.0.1:9001","name":"C2","secureType":"none","uri":"/pools/default/remoteClusters/C2","username":"Administrator","uuid":"3a313fb45ebfa0e44fffeef72d5bfe28","validateURI":"/pools/default/remoteClusters/C2?just_validate=1"},{"connectivityStatus":"RC_OK","deleted":false,"hostname":"127.0.0.1:9000","name":"self","secureType":"none","uri":"/pools/default/remoteClusters/self","username":"Administrator","uuid":"f064a2305c9ba118773fc1e839dcf317","validateURI":"/pools/default/remoteClusters/self?just_validate=1"}]
      

      However, with collections, it may be useful to retrieve the target bucket's manifest when creating or editing replication. The same REST API will be enhanced to provide ability to use an already added remote cluster, and a target bucket name, to retrieve the target bucket's collections manifest. This is accomplished via the use of a URL query.

      If user/UI wants to retrieve a specific target bucket manifest, then the current REST URL should be appended with the query with the key value of:

      remoteBucketManifest=<RemoteClusteRUUID>/<TargetBucketName>

      The target bucket manifest, if it exists, will be returned as a JSON value with the key of remoteBucketManifest for the requested cluster and bucket. If there are multiple remote clusters present, and the remoteBucketManifest query is used, then only the remote cluster being asked will be returned in the result instead of the original returned list of remote clusters.

      For example, given a target cluster UUID of 36c14fe811a47de85f65228e42c33b99 with a target bucket name of B2, the full usage would be (note the / character is replaced by %2F):

      neil.huang@NeilsMacbookPro:~$ curl -X GET -u Administrator:wewewe http://127.0.0.1:9000/pools/default/remoteClusters?remoteBucketManifest=36c14fe811a47de85f65228e42c33b99%2FB2
      [{"connectivityStatus":"RC_OK","deleted":false,"hostname":"127.0.0.1:9001","name":"C2","remoteBucketManifest":{"B2":{"uid":"3","scopes":[{"collections":[{"name":"col1","uid":"8"},{"name":"col2","uid":"9"}],"name":"S1","uid":"8"},{"collections":[{"name":"_default","uid":"0"}],"name":"_default","uid":"0"}]}},"secureType":"none","uri":"/pools/default/remoteClusters/C2","username":"Administrator","uuid":"36c14fe811a47de85f65228e42c33b99","validateURI":"/pools/default/remoteClusters/C2?just_validate=1"}]
      

      Exception handling:

      • If the URL Query is not completely correct, then it is ignored. In the following example, the query is missing the "/<bucketName>"

        neil.huang@NeilsMacbookPro:~/source/couchbase/goproj/src/github.com/couchbase/goxdcr/tools$ curl -X GET -u Administrator:wewewe http://127.0.0.1:9000/pools/default/remoteClusters?remoteBucketManifest=cad8b9a0e12a6da6b81b98dc88cfc7ec
        [{"connectivityStatus":"RC_OK","deleted":false,"hostname":"127.0.0.1:9001","name":"C2","secureType":"none","uri":"/pools/default/remoteClusters/C2","username":"Administrator","uuid":"cad8b9a0e12a6da6b81b98dc88cfc7ec","validateURI":"/pools/default/remoteClusters/C2?just_validate=1"}]
        

      • If the target bucket does not exist, it will try for a few seconds and then return an error message

        neil.huang@NeilsMacbookPro:~/source/couchbase/goproj/src/github.com/couchbase/goxdcr/tools$ curl -X GET -u Administrator:wewewe http://127.0.0.1:9000/pools/default/remoteClusters?remoteBucketManifest=36c14fe811a47de85f65228e42c33b99%2FB1
        {"_":"Bucket doesn't exist"}
        

      • To prevent malicious actors, once a retrieval request is sent for a specific target cluster (even if it is unsuccessful), the next request to the same target cluster must wait for a 10 seconds timeout before it can go through

        neil.huang@NeilsMacbookPro:~$ curl -X GET -u Administrator:wewewe http://127.0.0.1:9000/pools/default/remoteClusters?remoteBucketManifest=69010a299556fe04a95c3f390df1c19f%2FB0
        BucketValidationInfo Operation failed after max retries.  Last error: Bucket doesn't exist
        neil.huang@NeilsMacbookPro:~$ curl -X GET -u Administrator:wewewe http://127.0.0.1:9000/pools/default/remoteClusters?remoteBucketManifest=69010a299556fe04a95c3f390df1c19f%2FB2
        {"_":"This remote cluster has recently just serviced manifest retrieval request and is currently in cool down. Please wait 10s"}
        

      Attachments

        Issue Links

          No reviews matched the request. Check your Options in the drop-down menu of this sections header.

          Activity

            People

              neil.huang Neil Huang
              neil.huang Neil Huang
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes

                  PagerDuty