Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sg doesn't properly handle config files with buckets '%' in the name #878

Closed
andreibaranouski opened this issue May 25, 2015 · 6 comments
Closed
Assignees
Labels
Milestone

Comments

@andreibaranouski
Copy link

steps:

  1. create test_%E-.5 bucket on CB
  2. connect sg to the CB with "%" character in the bucket name
./couchbase-cli bucket-create -c localhost:8091 --bucket=test_%E-.5  --bucket-type=couchbase  --bucket-ramsize=105 --bucket-replica=1 --bucket-priority=low --wait -u Administrator -p password
..SUCCESS: bucket-create
[centos6 64:/opt/couchbase/bin ] $ cat /root/gateway_config.json{
    "log": ["HTTP", "HTTP+", "CRUD", "Feed", "Bucket"],
    "adminInterface": ":4985",
    "databases": {
        "db": {
            "server": "http://172.23.121.251:8091/",
            "bucket": "test_%E-.5",
            "feed_type":"tap",
            "users": {
                "GUEST": {"disabled": false, "admin_channels": ["*"] }
            }
        }
    }
}
[centos6 64:/opt/couchbase/bin ] $ /opt/couchbase-sync-gateway/bin/sync_gateway  /root/gateway_config.json2015-05-25T03:57:15.076-07:00 Enabling logging: [HTTP HTTP+ CRUD Feed Bucket]
2015-05-25T03:57:15.076-07:00 ==== Couchbase Sync Gateway/1.1.0(18;ad03ad6) ====
2015-05-25T03:57:15.076-07:00 Opening db /db as bucket "test_%E-.5", pool "default", server <http://172.23.121.251:8091/>
2015-05-25T03:57:15.076-07:00 Opening Couchbase database test_%E-.5 on <http://172.23.121.251:8091/>
2015-05-25T03:57:15.118-07:00 FATAL: Error opening database: 502 Unable to connect to server: HTTP error 404 Object Not Found getting "http://172.23.121.251:8091/pools/default/buckets/test_%2525E-.5?bucket_uuid=7d285850aa3941739536a10331eae8d7": Requested resource not found.
 -- rest.RunServer() at config.go:479

observation:
instead of
http://172.23.121.251:8091/pools/default/buckets/test_%2525E-.5?bucket_uuid=7d285850aa3941739536a10331eae8d7
url should be
http://172.23.121.251:8091/pools/default/buckets/test_%25E-.5?bucket_uuid=7d285850aa3941739536a10331eae8d7

@ajres
Copy link

ajres commented May 25, 2015

Could you retry this on master branch, we switched to the master branch of go-couchbase

@andreibaranouski
Copy link
Author

it works fine on master

./bin/sync_gateway gateway_config.json 
2015-05-25T15:45:12.659+03:00 Enabling logging: [HTTP HTTP+ CRUD Feed Bucket]
2015-05-25T15:45:12.659+03:00 ==== Couchbase Sync Gateway/master(8546803+CHANGES) ====
2015-05-25T15:45:12.659+03:00 Configured Go to use all 8 CPUs; setenv GOMAXPROCS to override this
2015-05-25T15:45:12.659+03:00 Opening db /db as bucket "test_%E-.5", pool "default", server <http://127.0.0.1:8091/>
2015-05-25T15:45:12.659+03:00 Opening Couchbase database test_%E-.5 on <http://127.0.0.1:8091/>
2015/05/25 15:45:12  Trying with selected node 0
2015-05-25T15:45:12.752+03:00 Bucket: PutDDoc("sync_gateway", ...) [77.97477ms]
2015/05/25 15:45:12  Trying with selected node 0
2015-05-25T15:45:12.976+03:00 Bucket: PutDDoc("sync_housekeeping", ...) [224.021031ms]
2015-05-25T15:45:13.085+03:00 Bucket: Incr("_sync:seq", 0, 0, 0) [109.352803ms]
2015-05-25T15:45:13.086+03:00 Bucket: Incr("_sync:seq", 0, 0, 0) [176.376us]
2015-05-25T15:45:13.086+03:00 Feed: Using TAP feed for bucket: "test_%E-.5" (based on feed_type specified in config file
2015-05-25T15:45:13.086+03:00 Bucket: StartTapFeed(...) [27.022us]
2015-05-25T15:45:13.087+03:00 Bucket: Update("_sync:syncdata", 0, ...) --> <nil> [1.411331ms]
2015-05-25T15:45:13.087+03:00 Using default sync function 'channel(doc.channels)' for database "db"
2015-05-25T15:45:13.087+03:00 Bucket: Update("_sync:user:", 0, ...) --> CAS quit [50.881us]
2015-05-25T15:45:13.087+03:00 Bucket: Incr("_sync:seq", 1, 1, 0) [47.271us]
2015-05-25T15:45:13.087+03:00 Bucket: SetRaw("_sync:user:", 0, ...) [58.434us]
2015-05-25T15:45:13.087+03:00     Reset guest user to config
2015-05-25T15:45:13.087+03:00 Starting admin server on :4985
2015-05-25T15:45:13.092+03:00 Starting server on :4984 ...

but doesn't work with 1.1.0-18.
@ajres what we do with the ticket?

@adamcfraser
Copy link
Collaborator

@andreibaranouski The 1.1.0 branch was recently moved to the latest go-couchbase (to fix issue #859). If you can confirm that this fixes the '%' bucket name issue on 1.1.0, we can close this ticket.

@andreibaranouski
Copy link
Author

hi,
I don't see the issue when I build sg from source:

git log -n 1
commit 7a79bf754c755ce90563c92683f68d929f9cc21f
Merge: 936c73f 672935b
Author: Traun Leyden <[email protected]>
Date:   Mon Jun 1 20:04:24 2015 -0700

    Merge pull request #896 from couchbase/feature/issue_859_1.1.0

    Expose TCP keep alive settings via Sync Gateway Config
andrei@abv:~/couchbase_src/sync_gateway$ vim gateway_config.json 
andrei@abv:~/couchbase_src/sync_gateway$ ./bin/sync_gateway gateway_config.json 
2015-06-03T00:28:46.947+03:00 Enabling logging: [HTTP HTTP+ CRUD Feed Bucket]
2015-06-03T00:28:46.947+03:00 ==== Couchbase Sync Gateway/release/1.1.0(7a79bf7+CHANGES) ====
2015-06-03T00:28:46.947+03:00 Configured Go to use all 8 CPUs; setenv GOMAXPROCS to override this
2015-06-03T00:28:46.947+03:00 Opening db /db as bucket "test_%E-.5", pool "default", server <http://127.0.0.1:8091/>
2015-06-03T00:28:46.947+03:00 Opening Couchbase database test_%E-.5 on <http://127.0.0.1:8091/>
2015/06/03 00:28:46  Trying with selected node 0
2015-06-03T00:28:47.016+03:00 Bucket: PutDDoc("sync_gateway", ...) [50.220768ms]
2015/06/03 00:28:47  Trying with selected node 0
2015-06-03T00:28:47.047+03:00 Bucket: PutDDoc("sync_housekeeping", ...) [30.798365ms]
2015-06-03T00:28:47.049+03:00 Bucket: Incr("_sync:seq", 0, 0, 0) [1.510411ms]
2015-06-03T00:28:47.049+03:00 Bucket: Incr("_sync:seq", 0, 0, 0) [100.015us]
2015-06-03T00:28:47.049+03:00 Feed: Using TAP feed for bucket: "test_%E-.5" (based on feed_type specified in config file
2015-06-03T00:28:47.049+03:00 Bucket: StartTapFeed(...) [22.14us]
2015-06-03T00:28:47.052+03:00 Bucket: Update("_sync:syncdata", 0, ...) --> CAS quit [3.289327ms]
2015-06-03T00:28:47.052+03:00 Using default sync function 'channel(doc.channels)' for database "db"
2015/06/03 00:28:47 go-couchbase: call to ViewCustom("sync_gateway", "access") in github.com/couchbase/sync_gateway/base.(*LoggingBucket).ViewCustom took 243.032301ms
2015-06-03T00:28:47.295+03:00 Bucket: ViewCustom("sync_gateway", "access", ...) [243.088878ms]
2015-06-03T00:28:47.313+03:00 Bucket: ViewCustom("sync_gateway", "role_access", ...) [17.429376ms]
2015-06-03T00:28:47.313+03:00 Bucket: Update("_sync:user:", 0, ...) --> <nil> [261.074111ms]
2015-06-03T00:28:47.313+03:00     Reset guest user to config
2015-06-03T00:28:47.313+03:00 Starting admin server on :4985
2015-06-03T00:28:47.320+03:00 Starting server on :4984 ...
^Candrei@abv:~/couchbase_src/sync_gateway$ cat gateway_config.json 
{
    "log": ["HTTP", "HTTP+", "CRUD", "Feed", "Bucket"],
    "adminInterface": ":4985",
    "databases": {
        "db": {
            "server": "http://127.0.0.1:8091/",
            "bucket": "test_%E-.5",
            "feed_type":"tap",
            "users": {
                "GUEST": {"disabled": false, "admin_channels": ["*"] }
            }
        }
    }
}

but it still reproduced on the latest binary build for 1.1.0 http://latestbuilds.hq.couchbase.com/couchbase-sync-gateway/release/1.1.0/1.1.0-25/couchbase-sync-gateway-community_1.1.0-25_x86_64.rpm

 cat /opt/couchbase-sync-gateway/VERSION.txt
1.1.0-25
[centos6 64:~ ] $ cat /root/gateway_config.json
{
    "log": ["HTTP", "HTTP+", "CRUD", "Feed", "Bucket"],
    "adminInterface": ":4985",
    "databases": {
        "db": {
            "server": "http://test_%25E-.5%3Apassword%40172.23.121.251:8091/",
            "bucket": "test_%E-.5",
            "feed_type":"tap",
            "users": {
                "GUEST": {"disabled": false, "admin_channels": ["*"] }
            }
        }
    }
}[centos6 64:~ ] $wget  "http://Administrator:[email protected]:8091/pools/default/buckets/test_%E-.5"
--2015-06-02 14:35:50--  http://Administrator:*password*@172.23.121.251:8091/pools/default/buckets/test_%25E-.5
Connecting to 172.23.121.251:8091... connected.
HTTP request sent, awaiting response... 401 Unauthorized
Connecting to 172.23.121.251:8091... connected.
HTTP request sent, awaiting response... 200 OK
Length: 9913 (9.7K) [application/json]
Saving to: “test_%E-.5.1”

100%[===================================================================================================================================================================>] 9,913       --.-K/s   in 0s      

2015-06-02 14:35:50 (330 MB/s) - “test_%E-.5.1” saved [9913/9913]

[centos6 64:~ ] $ /opt/couchbase-sync-gateway/bin/sync_gateway  /root/gateway_config.json 
2015-06-02T14:36:05.755-07:00 Enabling logging: [HTTP HTTP+ CRUD Feed Bucket]
2015-06-02T14:36:05.755-07:00 ==== Couchbase Sync Gateway/1.1.0(25;7a79bf7) ====
2015-06-02T14:36:05.756-07:00 Opening db /db as bucket "test_%E-.5", pool "default", server <http://test_%25E-.5%3Apassword%40172.23.121.251:8091/>
2015-06-02T14:36:05.756-07:00 Opening Couchbase database test_%E-.5 on <http://test_%25E-.5%3Apassword%40172.23.121.251:8091/>
2015-06-02T14:36:05.756-07:00 FATAL: Error opening database: 502 Unable to connect to server: parse http://test_%25E-.5%3Apassword%40172.23.121.251:8091/: hexadecimal escape in host -- rest.RunServer() at config.go:480

1.1.0-25 was build based on the latest sg commit 7a79bf7
so, seams like it should be the same version but it doesn't work when use rpm package

I still do not understand how this can be....

@andreibaranouski
Copy link
Author

oh, I found the difference:
"db": { "server" : "http://test_%25E-.5%3Apassword%40172.23.121.251:8091/",
reviewing now...

@andreibaranouski
Copy link
Author

it works fine with "server": "http://172.23.121.251:8091/"

@zgramana zgramana modified the milestone: 1.1.0 Jun 11, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants