{"action":"created","issue":{"url":"https://api.github.com/repos/hashicorp/consul/issues/4960","repository_url":"https://api.github.com/repos/hashicorp/consul","labels_url":"https://api.github.com/repos/hashicorp/consul/issues/4960/labels{/name}","comments_url":"https://api.github.com/repos/hashicorp/consul/issues/4960/comments","events_url":"https://api.github.com/repos/hashicorp/consul/issues/4960/events","html_url":"https://github.com/hashicorp/consul/issues/4960","id":380993092,"node_id":"MDU6SXNzdWUzODA5OTMwOTI=","number":4960,"title":"Service resynced every ~2mins, causes consul index to grow","user":{"login":"duanxuelin","id":30339830,"node_id":"MDQ6VXNlcjMwMzM5ODMw","avatar_url":"https://avatars0.githubusercontent.com/u/30339830?v=4","gravatar_id":"","url":"https://api.github.com/users/duanxuelin","html_url":"https://github.com/duanxuelin","followers_url":"https://api.github.com/users/duanxuelin/followers","following_url":"https://api.github.com/users/duanxuelin/following{/other_user}","gists_url":"https://api.github.com/users/duanxuelin/gists{/gist_id}","starred_url":"https://api.github.com/users/duanxuelin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/duanxuelin/subscriptions","organizations_url":"https://api.github.com/users/duanxuelin/orgs","repos_url":"https://api.github.com/users/duanxuelin/repos","events_url":"https://api.github.com/users/duanxuelin/events{/privacy}","received_events_url":"https://api.github.com/users/duanxuelin/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":6,"created_at":"2018-11-15T04:15:41Z","updated_at":"2018-11-20T19:29:58Z","closed_at":null,"author_association":"NONE","body":"We are running agent in a k8s pod. After register a service, the agent syned service continuously。\r\n```\r\n    2018/11/15 02:04:41 [INFO] agent: Synced node info\r\n    2018/11/15 02:04:46 [INFO] agent: Synced service \"54ebba0c-841d-4d6a-8f09-734bab38d390\"\r\n    2018/11/15 02:04:46 [INFO] agent: Synced check \"service:54ebba0c-841d-4d6a-8f09-734bab38d390\"\r\n==&gt; Newer Consul version available: 1.4.0 (currently running: 1.2.3)\r\n    2018/11/15 02:06:08 [INFO] agent: Synced service \"54ebba0c-841d-4d6a-8f09-734bab38d390\"\r\n    2018/11/15 02:07:46 [INFO] agent: Synced service \"54ebba0c-841d-4d6a-8f09-734bab38d390\"\r\n    2018/11/15 02:09:03 [INFO] agent: Synced service \"54ebba0c-841d-4d6a-8f09-734bab38d390\"\r\n    2018/11/15 02:10:34 [INFO] agent: Synced service \"54ebba0c-841d-4d6a-8f09-734bab38d390\"\r\n    2018/11/15 02:11:46 [INFO] agent: Synced service \"54ebba0c-841d-4d6a-8f09-734bab38d390\"\r\n    2018/11/15 02:13:34 [INFO] agent: Synced service \"54ebba0c-841d-4d6a-8f09-734bab38d390\"\r\n    2018/11/15 02:14:52 [INFO] agent: Synced service \"54ebba0c-841d-4d6a-8f09-734bab38d390\"\r\n    2018/11/15 02:16:04 [INFO] agent: Synced service \"54ebba0c-841d-4d6a-8f09-734bab38d390\"\r\n```\r\nThe k8s deploymend file is like:  \r\n\r\n```\r\n      - image: consul:1.2.3\r\n        imagePullPolicy: IfNotPresent\r\n        name: consul-agent\r\n        lifecycle:\r\n          preStop:\r\n            exec:\r\n              command: [\"/bin/sh\", \"-c\", \"sleep 5; consul leave -http-addr=http://$BIND_IP:8500\"]\r\n       args:\r\n        - \"agent\"\r\n        - \"-bind=0.0.0.0\"\r\n        - \"-retry-join=consul-server.base\"\r\n        - \"-datacenter=dc\"\r\n```"},"comment":{"url":"https://api.github.com/repos/hashicorp/consul/issues/comments/440401193","html_url":"https://github.com/hashicorp/consul/issues/4960#issuecomment-440401193","issue_url":"https://api.github.com/repos/hashicorp/consul/issues/4960","id":440401193,"node_id":"MDEyOklzc3VlQ29tbWVudDQ0MDQwMTE5Mw==","user":{"login":"pierresouchay","id":8089033,"node_id":"MDQ6VXNlcjgwODkwMzM=","avatar_url":"https://avatars3.githubusercontent.com/u/8089033?v=4","gravatar_id":"","url":"https://api.github.com/users/pierresouchay","html_url":"https://github.com/pierresouchay","followers_url":"https://api.github.com/users/pierresouchay/followers","following_url":"https://api.github.com/users/pierresouchay/following{/other_user}","gists_url":"https://api.github.com/users/pierresouchay/gists{/gist_id}","starred_url":"https://api.github.com/users/pierresouchay/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pierresouchay/subscriptions","organizations_url":"https://api.github.com/users/pierresouchay/orgs","repos_url":"https://api.github.com/users/pierresouchay/repos","events_url":"https://api.github.com/users/pierresouchay/events{/privacy}","received_events_url":"https://api.github.com/users/pierresouchay/received_events","type":"User","site_admin":false},"created_at":"2018-11-20T19:29:58Z","updated_at":"2018-11-20T19:29:58Z","author_association":"CONTRIBUTOR","body":"@duanxuelin\r\n\r\nUse this script named `consul_check_services_changes.sh`:\r\n```shell\r\n#!/bin/bash\r\nif test ${1:-none} = \"none\"\r\nthen\r\n  echo \"USAGE: $0 Consul_URL\"\r\n  echo \"       Example: localhost:8500/v1/health/service/MY_SUPER_SERVICE\"\r\n  exit 1\r\nfi\r\nurl_to_check=$1\r\n\r\nheaders=$(mktemp)\r\ncolor_diff=$(which colordiff||which cdiff||echo diff)\r\ncontent=$(mktemp)\r\nindex=0\r\nwhile true;\r\ndo\r\n  url=\"${url_to_check}?wait=10m&index=${index}&pretty=true&stale\"\r\n  curl -fs --dump-header \"$headers\" -o \"${content}.new\" \"${url}\" || { echo \"Failed to query ${url}\"; exit 1; }\r\n  if test $index -ne 0\r\n  then\r\n    ${color_diff} -u \"$content\" \"$content.new\" && echo \" diff: No Differences found in service\"\r\n  fi\r\n  index=$(grep \"X-Consul-Index\" \"$headers\" | sed 's/[^0-9]*\\([0-9][0-9]*\\)[^0-9]*/\\1/g')\r\n  if test \"${index:-not_found}\" = \"not_found\"\r\n  then\r\n    # We are in a part of Consul that does not output X-Consul-Index in headers, switch to poll\r\n    sleep 5\r\n    index=1\r\n  fi\r\n  if test ${CONSUL_SLEEP_DELAY:-0} -gt 0\r\n  then\r\n    sleep ${CONSUL_SLEEP_DELAY}\r\n  fi\r\n  mv \"$content.new\" \"$content\"\r\n  printf \"X-Consul-Index: $index at $(date) \\b\"\r\ndone\r\n```\r\n\r\nAnd launch it against your agent this way (if your agent is remove, you can replace `localhost` by the name of any consul agent in your cluster):\r\n\r\n`consul_check_services_changes.sh localhost:8500/v1/health/service/:service_name`\r\n\r\nIt will display the changes in real time and help you a lot (we are using it intensively)\r\n"}}
{"actor":{"display_login":"pierresouchay"}}