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

consul watch handler runs multiple times when changing a key #4179

Closed
giladsh1 opened this issue May 30, 2018 · 0 comments
Closed

consul watch handler runs multiple times when changing a key #4179

giladsh1 opened this issue May 30, 2018 · 0 comments

Comments

@giladsh1
Copy link

I'm running Consul v1.1.0.
here is the consul info output -

agent:
	check_monitors = 0
	check_ttls = 0
	checks = 0
	services = 0
build:
	prerelease =
	revision = 5174058f
	version = 1.1.0
consul:
	known_servers = 3
	server = false
runtime:
	arch = amd64
	cpu_count = 2
	goroutines = 157
	max_procs = 2
	os = linux
	version = go1.10.1
serf_lan:
	coordinate_resets = 0
	encrypted = true
	event_queue = 0
	event_time = 2
	failed = 0
	health_score = 0
	intent_queue = 0
	left = 0
	member_time = 5
	members = 4
	query_queue = 0
	query_time = 1

I've created the following configuration for watching a key -

$>  cat /etc/consul.d/check.json
{
  "watches": [
    {
      "type": "key",
      "key": "environments/config/daniel/traps_version",
      "handler_type": "script",
      "args": ["sh", "-c", "/tmp/test.sh"]
    }
  ]
}

when changing the key "environments/config/daniel/traps_version", the agent gets the key and runs the script multiple times.
here is a part of the log file -

2018/05/30 15:06:59 [DEBUG] http: Request GET /v1/kv/environments/config/daniel/traps_version?index=188358 (7.079140117s) from=127.0.0.1:49467
    2018/05/30 15:06:59 [DEBUG] http: Request GET /v1/kv/environments/config/daniel/traps_version?index=188358 (7.080088558s) from=127.0.0.1:49469
    2018/05/30 15:06:59 [DEBUG] http: Request GET /v1/kv/environments/config/daniel/traps_version?index=188358 (7.08265912s) from=127.0.0.1:49475
    2018/05/30 15:06:59 [DEBUG] http: Request GET /v1/kv/environments/config/daniel/traps_version?index=188358 (7.086552636s) from=127.0.0.1:49461
    2018/05/30 15:06:59 [DEBUG] http: Request GET /v1/kv/environments/config/daniel/traps_version?index=188358 (7.089281657s) from=127.0.0.1:49459
    2018/05/30 15:06:59 [DEBUG] http: Request GET /v1/kv/environments/config/daniel/traps_version?index=188358 (7.080948755s) from=127.0.0.1:49471
    2018/05/30 15:06:59 [DEBUG] http: Request GET /v1/kv/environments/config/daniel/traps_version?index=188358 (7.089535884s) from=127.0.0.1:49463
    2018/05/30 15:06:59 [DEBUG] http: Request GET /v1/kv/environments/config/daniel/traps_version?index=188358 (7.094883838s) from=127.0.0.1:49465
    2018/05/30 15:06:59 [DEBUG] http: Request GET /v1/kv/environments/config/daniel/traps_version?index=188358 (7.093992461s) from=127.0.0.1:49473
    2018/05/30 15:06:59 [DEBUG] agent: watch handler '[sh -c /tmp/test.sh]' output:
    2018/05/30 15:06:59 [DEBUG] agent: watch handler '[sh -c /tmp/test.sh]' output:
    2018/05/30 15:06:59 [DEBUG] agent: watch handler '[sh -c /tmp/test.sh]' output:
    2018/05/30 15:06:59 [DEBUG] agent: watch handler '[sh -c /tmp/test.sh]' output:
    2018/05/30 15:06:59 [DEBUG] agent: watch handler '[sh -c /tmp/test.sh]' output:
    2018/05/30 15:06:59 [DEBUG] agent: watch handler '[sh -c /tmp/test.sh]' output:
    2018/05/30 15:06:59 [DEBUG] agent: watch handler '[sh -c /tmp/test.sh]' output:
    2018/05/30 15:06:59 [DEBUG] agent: watch handler '[sh -c /tmp/test.sh]' output:
    2018/05/30 15:06:59 [DEBUG] agent: watch handler '[sh -c /tmp/test.sh]' output:

it's important to note that this error does not happen when running watch from the command line - the script only runs once.

here is my consul.json config file -

{
  "addresses": {
    "dns": "0.0.0.0",
    "http": "0.0.0.0"
  },
  "dns_config": {
    "node_ttl": "1s",
    "service_ttl": {
      "*": "1s"
    },
    "allow_stale": true,
    "max_stale": "5s"
  },
  "enable_script_checks": true,
  "disable_host_node_id": true,
  "log_level": "trace",
  "enable_syslog": false,
  "syslog_facility": "LOCAL3",
  "rejoin_after_leave": true,
  "skip_leave_on_interrupt": false,
  "disable_remote_exec": false,
  "check_update_interval": "5m",
  "enable_debug": false,
  "node_meta": {
    "instance_type": "t2.medium"
  },
  "limits": {
    "rpc_max_burst": 1000,
    "rpc_rate": -1
  },
  "data_dir": "/var/lib/consul",
  "retry_join": ["provider=aws tag_key=Role tag_value=<tag>"],
  "bind_addr": "<lan-ip>",
  "datacenter": "dc1",
  "node_name": "node",
  "ports": {
    "dns": 8600,
    "http": 8500,
    "serf_lan": 8301,
    "serf_wan": 8302,
    "server": 8300
  },
  "encrypt": "encrypt-key"
}
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