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

Problem synchronizing binary files #175

Open
marcindulak opened this issue Mar 17, 2018 · 0 comments
Open

Problem synchronizing binary files #175

marcindulak opened this issue Mar 17, 2018 · 0 comments

Comments

@marcindulak
Copy link

marcindulak commented Mar 17, 2018

The setup, latest git2consul (on localhost) and consul (on consul):

[root@localhost ~]# npm list -g
/usr/lib
├─┬ [email protected]
│ ├─┬ [email protected]
│ │ ├── [email protected]
│ │ ├── [email protected]
│ │ ├── [email protected]
│ │ ├── [email protected]
│ │ ├── [email protected]
│ │ ├── [email protected]
│ │ └─┬ [email protected]
│ │   └── [email protected]
...

[root@localhost ~]# curl -s http://consul:8500/v1/agent/self | jq -r '.Config.Version'
1.0.6

Create a repository with a gzip compressed file, and curl the file into consul.
The contents of the file is retrieved correctly:

[root@localhost ~]# mkdir test-repo
[root@localhost ~]# cd test-repo/
[root@localhost test-repo]# git init
Initialized empty Git repository in /root/test-repo/.git/
[root@localhost test-repo]# 
[root@localhost test-repo]# echo 123 > gzip && gzip gzip
[root@localhost test-repo]# git add gzip.gz 
[root@localhost test-repo]# git commit -m"added gz"
[master (root-commit) b7fb3b5] added gz
 1 file changed, 0 insertions(+), 0 deletions(-)
 create mode 100644 gzip.gz

[root@localhost test-repo]# curl --request PUT --data-binary @/root/test-repo/gzip.gz http://consul:8500/v1/kv/gzip.gz
[root@localhost test-repo]# curl -s http://consul:8500/v1/kv/gzip.gz | jq -r '.[].Value' | base64 --decode | gunzip -
123

Synchronize the repository into consul with git2consul, and the retrieved file contents is incorrect.

[root@localhost test-repo]# cat <<EOF > /tmp/git2consul.json
{
  "version": "1.0",
  "repos" : [{
    "name" : "test-repo",
    "url" : "/root/test-repo",
    "branches" : ["master"],
    "hooks": [{
      "type" : "polling",
      "interval" : "1"
    }]
  }]
}
EOF

[root@localhost test-repo]# git2consul --endpoint consul --port 8500 --config-file /tmp/git2consul.json
{"name":"git2consul","hostname":"localhost","pid":5341,"level":30,"msg":"Adding /tmp/git2consul.json to KV git2consul/config as: \n{\n  \"version\": \"1.0\",\n  \"repos\" : [{\n    \"name\" : \"test-repo\",\n    \"url\" : \"/root/test-repo\",\n    \"branches\" : [\"master\"],\n    \"hooks\": [{\n      \"type\" : \"polling\",\n      \"interval\" : \"1\"\n    }]\n  }]\n}\n","time":"2018-03-17T09:10:31.992Z","v":0}
{"name":"git2consul","hostname":"localhost","pid":5341,"level":30,"msg":"git2consul is running","time":"2018-03-17T09:10:32.227Z","v":0}
{"name":"git2consul","hostname":"localhost","pid":5341,"level":30,"msg":"Initting repo test-repo","time":"2018-03-17T09:10:32.230Z","v":0}
{"name":"git2consul","hostname":"localhost","pid":5341,"level":30,"msg":"Initting branch /tmp/test-repo /tmp/test-repo/master","time":"2018-03-17T09:10:32.230Z","v":0}
{"name":"git2consul","hostname":"localhost","pid":5341,"level":40,"msg":"Purging branch cache /tmp/test-repo/master for branch master in repo test-repo","time":"2018-03-17T09:10:32.231Z","v":0}
{"name":"git2consul","hostname":"localhost","pid":5341,"level":30,"msg":"Initialized branch master from test-repo","time":"2018-03-17T09:10:32.293Z","v":0}
{"name":"git2consul","hostname":"localhost","pid":5341,"level":30,"msg":"Loaded repo test-repo","time":"2018-03-17T09:10:32.294Z","v":0}
^C

[root@consul ~]# consul kv get -recurse
git2consul/config:{
  "version": "1.0",
  "repos" : [{
    "name" : "test-repo",
    "url" : "/root/test-repo",
    "branches" : ["master"],
    "hooks": [{
      "type" : "polling",
      "interval" : "1"
    }]
  }]
}

gzip.gz:�٬Z�gzip342���Z�
test-repo/master.ref:b7fb3b56d5099a0cda0418fdb05f17915d6881b2
test-repo/master/gzip.gz:�٬Z�gzip342���Z�

[root@localhost test-repo]# curl -s http://consul:8500/v1/kv/test-repo/master/gzip.gz | jq -r '.[].Value' | base64 --decode | gunzip -
gzip: stdin: not in gzip format

There is no problem sychronizing text file with git2consul:

[root@localhost test-repo]# echo 0345 > plain
[root@localhost test-repo]# git add plain 
[root@localhost test-repo]# git commit -m"plain"
[master 87f6397] plain
 1 file changed, 1 insertion(+)
 create mode 100644 plain
[root@localhost test-repo]# git2consul --endpoint consul --port 8500 --config-file /tmp/git2consul.json
{"name":"git2consul","hostname":"localhost","pid":5375,"level":30,"msg":"Adding /tmp/git2consul.json to KV git2consul/config as: \n{\n  \"version\": \"1.0\",\n  \"repos\" : [{\n    \"name\" : \"test-repo\",\n    \"url\" : \"/root/test-repo\",\n    \"branches\" : [\"master\"],\n    \"hooks\": [{\n      \"type\" : \"polling\",\n      \"interval\" : \"1\"\n    }]\n  }]\n}\n","time":"2018-03-17T09:16:06.572Z","v":0}
{"name":"git2consul","hostname":"localhost","pid":5375,"level":30,"msg":"git2consul is running","time":"2018-03-17T09:16:06.738Z","v":0}
{"name":"git2consul","hostname":"localhost","pid":5375,"level":30,"msg":"Initting repo test-repo","time":"2018-03-17T09:16:06.740Z","v":0}
{"name":"git2consul","hostname":"localhost","pid":5375,"level":30,"msg":"Initting branch /tmp/test-repo /tmp/test-repo/master","time":"2018-03-17T09:16:06.740Z","v":0}
{"name":"git2consul","hostname":"localhost","pid":5375,"level":30,"msg":"Initialized branch master from test-repo","time":"2018-03-17T09:16:06.829Z","v":0}
{"name":"git2consul","hostname":"localhost","pid":5375,"level":30,"msg":"Loaded repo test-repo","time":"2018-03-17T09:16:06.830Z","v":0}
^C

[root@localhost test-repo]# curl -s http://consul:8500/v1/kv/test-repo/master/plain | jq -r '.[].Value' | base64 --decode
0345
This was referenced Mar 17, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant