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

storage_backend in bucket create REST API needs validation

    XMLWordPrintable

Details

    • Untriaged
    • 1
    • Unknown

    Description

      7.0.0-3644

      storage_backend in bucket create REST API does not seem to have any validation - I was testing community edition to validate if magma is not available - when I supplied storage_backend=magma, it did not throw an error as expected - instead it went ahead and created a bucket with couchstore storage mode:

      [root@node1-mad-hatter-testing-centos7 bin]# curl -v -X POST http://10.112.194.101:8091/pools/default/buckets -u Administrator:password -d name=testBucket -d bucketType=couchbase -d ramQuotaMB=100 -d storage_backend=magma
      * About to connect() to 10.112.194.101 port 8091 (#0)
      *   Trying 10.112.194.101...
      * Connected to 10.112.194.101 (10.112.194.101) port 8091 (#0)
      * Server auth using Basic with user 'Administrator'
      > POST /pools/default/buckets HTTP/1.1
      > Authorization: Basic QWRtaW5pc3RyYXRvcjpwYXNzd29yZA==
      > User-Agent: curl/7.29.0
      > Host: 10.112.194.101:8091
      > Accept: */*
      > Content-Length: 73
      > Content-Type: application/x-www-form-urlencoded
      >
      * upload completely sent off: 73 out of 73 bytes
      < HTTP/1.1 202 Accepted
      < Cache-Control: no-cache,no-store,must-revalidate
      < Content-Length: 0
      < Date: Fri, 06 Nov 2020 05:20:28 GMT
      < Expires: Thu, 01 Jan 1970 00:00:00 GMT
      < Location: /pools/default/buckets/testBucket
      < Pragma: no-cache
      < Server: Couchbase Server
      < X-Content-Type-Options: nosniff
      < X-Frame-Options: DENY
      < X-Permitted-Cross-Domain-Policies: none
      < X-XSS-Protection: 1; mode=block
      <
      * Connection #0 to host 10.112.194.101 left intact
      

      It does not seem to have validation actually - even if I give any garbage value like "abc", it goes through and creates a bucket with couchstore - other parameters in bucket create REST API have validation - we should have validation for storage_backend as well - some examples of validation errors:

      {"errors":{"compressionMode":"Compression mode is supported in enterprise edition only"},"summaries":{"ramSummary":{"total":536870912,"otherBuckets":104857600,"nodesCount":1,"perNodeMegs":100,"thisAlloc":104857600,"thisUsed":0,"free":327155712},"hddSummary":{"total":19828572160,"otherData":15810500910,"otherBuckets":52356818,"thisUsed":0,"free":3965714432}}}
       
      {"errors":{"name":"Bucket name can only contain characters in range A-Z, a-z, 0-9 as well as underscore, period, dash & percent. Consult the documentation.","bucketType":"invalid bucket type"},"summaries":{"ramSummary":{"total":536870912,"otherBuckets":104857600,"nodesCount":1,"perNodeMegs":100,"thisAlloc":104857600,"thisUsed":0,"free":327155712},"hddSummary":{"total":19828572160,"otherData":15810500910,"otherBuckets":52356818,"thisUsed":0,"free":3965714432}}}
       
      "errors":{"ramQuotaMB":"The RAM Quota cannot be negative.","bucketType":"invalid bucket type"},"summaries":{"ramSummary":{"total":536870912,"otherBuckets":104857600,"nodesCount":1,"perNodeMegs":0,"thisAlloc":0,"thisUsed":0,"free":432013312},"hddSummary":{"total":19828572160,"otherData":15810500910,"otherBuckets":52356818,"thisUsed":0,"free":3965714432}}}
      

      Attachments

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

        Activity

          Arunkumar Senthilnathan The argument to the REST api is named "storageBackend". If there is documentation saying it is "storage_backend" the doc should be corrected.

          $ curl -X POST http://localhost:9000/pools/default/buckets -u Administrator:asdasd -d name=testBucket -d bucketType=couchbase -d ramQuotaMB=100 -d storageBackend=magma
          {"errors":{"storageBackend":"Magma is supported in enterprise edition only"},"summaries":{"ramSummary":{"total":1073741824,"otherBuckets":106954752,"nodesCount":1,"perNodeMegs":100,"thisAlloc":104857600,"thisUsed":0,"free":861929472},"hddSummary":{"total":499963174912,"otherData":284978929175,"otherBuckets":80524,"thisUsed":0,"free":214984165213}}}
          

          It would be nice if the REST APIs checked for specified, but ignored arguments but that currently isn't the case. In MB-39562 I mentioned:

          This might be an issue in general for ns_server REST Apis...that we look for specific attributes and ignore others.  Maybe left to when we clean up the REST apis...some day.
          

          steve.watanabe Steve Watanabe added a comment - Arunkumar Senthilnathan The argument to the REST api is named "storageBackend". If there is documentation saying it is "storage_backend" the doc should be corrected. $ curl -X POST http://localhost:9000/pools/default/buckets -u Administrator:asdasd -d name=testBucket -d bucketType=couchbase -d ramQuotaMB=100 -d storageBackend=magma {"errors":{"storageBackend":"Magma is supported in enterprise edition only"},"summaries":{"ramSummary":{"total":1073741824,"otherBuckets":106954752,"nodesCount":1,"perNodeMegs":100,"thisAlloc":104857600,"thisUsed":0,"free":861929472},"hddSummary":{"total":499963174912,"otherData":284978929175,"otherBuckets":80524,"thisUsed":0,"free":214984165213}}} It would be nice if the REST APIs checked for specified, but ignored arguments but that currently isn't the case. In MB-39562 I mentioned: This might be an issue in general for ns_server REST Apis...that we look for specific attributes and ignore others. Maybe left to when we clean up the REST apis...some day.

          thanks Steve Watanabe - verified with storageBacked=magma and it works - closing this issue

          arunkumar Arunkumar Senthilnathan (Inactive) added a comment - thanks Steve Watanabe - verified with storageBacked=magma and it works - closing this issue

          People

            arunkumar Arunkumar Senthilnathan (Inactive)
            arunkumar Arunkumar Senthilnathan (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes

                PagerDuty