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

Can't run example from Quick Start Guide #67

Closed
juicedM3 opened this issue Mar 24, 2016 · 9 comments
Closed

Can't run example from Quick Start Guide #67

juicedM3 opened this issue Mar 24, 2016 · 9 comments
Labels

Comments

@juicedM3
Copy link

I'm just trying to run the example from your quick start guide. So I'm pointing at your test repository and my instance of Consul.

$ cat /tmp/git2consul.json
{
  "version": "1.0",
  "repos": [{
    "name": "sample_configuration",
    "url":  "https://github.com/ryanbreen/git2consul_data.git",
    "branches": ["dev"],
    "hooks": [{
      "type": "polling",
      "interval": "1"
    }]
  }]
}
$ node . --endpoint consul.service.consul --port 8500 --token $MASTER_TOKEN --config-file /tmp/git2consul.json

I get:

{
  "name":"git2consul",
  "hostname":"host.example.com",
  "pid":16987,
  "level":30,
  "msg":"Adding /tmp/git2consul.json to KV git2consul/config as
: \n{\n  \"version\": \"1.0\",\n  \"repos\": [{\n    \"name\": \"poc\",\n    \"url\":  \"https://github.com/ryanbreen/git2consul_data.git\",\n\    "branches\": [\"dev\"],\n    \"hooks\": [{\n      \"type\": \"polling\",\n      \"interval\": \"1\"\n    }]\n  }]\n}\n",
  "time":"2016-03-24T20:15:29.262Z",
  "v":0
}  
{
  "name":"git2consul",
  "hostname":"host.example.com",
  "pid":16987,
  "level":30,
  "msg":"item:  undefined",
  "time":"2016-03-24T20:15:29.359Z",
  "v":0
}  
Config value is not valid JSON: undefined

I look in Consul and the config for git2consul is there but I do not see any of the keys for sample_configuration. I've validated the JSON in /tmp/git2consul.json and it's valid.

  • OS: CentOS Linux release 7.1.1503 (Core)
  • Consul: v0.6.3
  • node: v5.9.1
  • git2consul: v0.12.8

Before I try different versions of node or git2consul or reverse engineering, do you have any suggestions? Thanks!

@calvn
Copy link
Contributor

calvn commented Mar 24, 2016

Can you try running it again, but without the --config-file flag? Looking at that log message, I suspect something is wrong with config_reader.read(), but I want to double check that it is not related to config_seeder.js

@juicedM3
Copy link
Author

Same result (minus writing to consul) as with the flag.

Thanks!
Justin

On Thu, Mar 24, 2016 at 5:57 PM, Calvin Leung Huang < notifications@github.com [notifications@github.com] > wrote:
Can you try running it again, but without the --config-file flag? Looking at that log message, I suspect something is wrong with config_reader.read() , but I want to double check that it is not related to config_seeder.js


You are receiving this because you authored the thread.
Reply to this email directly or view it on GitHub [https://github.com//issues/67#issuecomment-201043010]

@juicedM3
Copy link
Author

Adding example:

$ node . --endpoint consul.service.consul --port 8500 --token $MASTER_TOKEN | python -mjson.tool
Config value is not valid JSON: undefined
{
    "hostname": "host.example.com",
    "level": 30,
    "msg": "item:  undefined",
    "name": "git2consul",
    "pid": 8245,
    "time": "2016-03-25T13:57:50.383Z",
    "v": 0
}

Is it having an issue parsing the config when it fetches it from Consul?

@juicedM3
Copy link
Author

Looking at the config in Consul:

$ curl http://consul.service.consul:8500/v1/kv/git2consul/config?raw\&token=$MASTER_TOKEN
{
  "version": "1.0",
  "repos": [{
    "name": "sample_configuration",
    "url":  "https://github.com/ryanbreen/git2consul_data.git",
    "branches": ["dev"],
    "hooks": [{
      "type": "polling",
      "interval": "1"
    }]
  }]
}

@juicedM3
Copy link
Author

The Consul ACL token is not being passed along for reads. When I export the ENV variable TOKEN, it works as expected.

$ TOKEN=$MASTER_TOKEN node . --endpoint jb11 --port 8500 --token $MASTER_TOKEN
{"name":"git2consul","hostname":"host.example.com","pid":9905,"level":30,"msg":"git2consul is running","time":"2016-03-25T14:09:20.777Z","v":0}
{"name":"git2consul","hostname":"host.example.com","pid":9905,"level":30,"msg":"Initting repo sample_configuration","time":"2016-03-25T14:09:20.786Z","v":0}
{"name":"git2consul","hostname":"host.example.com","pid":9905,"level":30,"msg":"Initting branch /tmp/sample_configuration /tmp/sample_configuration/dev","time":"2016-03-25T14:09:20.786Z","v":0}
{"name":"git2consul","hostname":"host.example.com","pid":9905,"level":30,"msg":"Initialized branch dev from sample_configuration","time":"2016-03-25T14:09:21.174Z","v":0}
{"name":"git2consul","hostname":"host.example.com","pid":9905,"level":30,"msg":"Loaded repo sample_configuration","time":"2016-03-25T14:09:21.177Z","v":0}
$ curl http://consul.service.consul:8500/v1/kv/sample_configuration/dev/sample.json?raw\&token=$MASTER_TOKEN
{
        "sample": "configuration"
}
$ curl http://consul.service.consul:8500/v1/kv/sample_configuration/dev/sample.conf?raw\&token=$MASTER_TOKEN
sample = configuration
$ curl http://consul.service.consul:8500/v1/kv/sample_configuration/dev/sample.yaml?raw\&token=$MASTER_TOKEN
sample: configuration

@calvn
Copy link
Contributor

calvn commented Mar 25, 2016

You're right, it looks like /lib/config_reader.js#L17 is using process.env.TOKEN instead of global.token

@calvn calvn added the bug label Mar 25, 2016
@calvn
Copy link
Contributor

calvn commented Mar 28, 2016

The changes has been released on v0.12.9

I did not change /test/git2consul_halt_on_change.js to use global.token since that test case doesn't go through index.js and therefore there is no option to pass in the token.

@calvn calvn closed this as completed Mar 28, 2016
@juicedM3
Copy link
Author

It works. Thanks guys!

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

2 participants