2017-08-16 117 views
0

我正在使用Consul-Template來呈現從Consul收集的數據的屬性。該文件被渲染成功但事後領事模板失敗,一遍又一遍,直到它崩潰:Consul-Template意外的響應代碼:504

2017/08/16 10:43:04.900637 [WARN] (view) kv.list(...): Unexpected response code: 504 (retry attempt 5 after "4s") 

達到極限,直到這推移和較長的停頓/崩潰。

配置從日誌中提取:

2017/08/16 10:38:02.403969 [DEBUG] (runner) final config: 
{ 
    "Consul": { 
     "Address": "consul-client.development.discovery", 
     "Auth": { 
      "Enabled": false, 
      "Username": "", 
      "Password": "" 
     }, 
     "Retry": { 
      "Attempts": 12, 
      "Backoff": 250000000, 
      "MaxBackoff": 60000000000, 
      "Enabled": true 
     }, 
     "SSL": { 
      "CaCert": "", 
      "CaPath": "", 
      "Cert": "", 
      "Enabled": false, 
      "Key": "", 
      "ServerName": "", 
      "Verify": true 
     }, 
     "Token": "", 
     "Transport": { 
      "DialKeepAlive": 30000000000, 
      "DialTimeout": 30000000000, 
      "DisableKeepAlives": false, 
      "IdleConnTimeout": 90000000000, 
      "MaxIdleConns": 100, 
      "MaxIdleConnsPerHost": 3, 
      "TLSHandshakeTimeout": 10000000000 
     } 
    }, 
    "Dedup": { 
     "Enabled": false, 
     "MaxStale": 2000000000, 
     "Prefix": "consul-template/dedup/", 
     "TTL": 15000000000 
    }, 
    "Exec": { 
     "Command": "", 
     "Enabled": false, 
     "Env": { 
      "Blacklist": [], 
      "Custom": [], 
      "Pristine": false, 
      "Whitelist": [] 
     }, 
     "KillSignal": 2, 
     "KillTimeout": 30000000000, 
     "ReloadSignal": null, 
     "Splay": 0, 
     "Timeout": 0 
    }, 
    "KillSignal": 2, 
    "LogLevel": "DEBUG", 
    "MaxStale": 2000000000, 
    "PidFile": "", 
    "ReloadSignal": 1, 
    "Syslog": { 
     "Enabled": false, 
     "Facility": "LOCAL0" 
    }, 
    "Templates": [ 
     { 
      "Backup": false, 
      "Command": "", 
      "CommandTimeout": 30000000000, 
      "Contents": "", 
      "Destination": "/consul-template/output/service.properties", 
      "Exec": { 
       "Command": "", 
       "Enabled": false, 
       "Env": { 
        "Blacklist": [], 
        "Custom": [], 
        "Pristine": false, 
        "Whitelist": [] 
       }, 
       "KillSignal": 2, 
       "KillTimeout": 30000000000, 
       "ReloadSignal": null, 
       "Splay": 0, 
       "Timeout": 30000000000 
      }, 
      "Perms": 420, 
      "Source": "/consul-template/data/service.properties.tpl", 
      "Wait": { 
       "Enabled": false, 
       "Min": 0, 
       "Max": 0 
      }, 
      "LeftDelim": "", 
      "RightDelim": "" 
     }, 
     { 
      "Backup": false, 
      "Command": "", 
      "CommandTimeout": 30000000000, 
      "Contents": "", 
      "Destination": "/consul-template/output/application.properties", 
      "Exec": { 
       "Command": "", 
       "Enabled": false, 
       "Env": { 
        "Blacklist": [], 
        "Custom": [], 
        "Pristine": false, 
        "Whitelist": [] 
       }, 
       "KillSignal": 2, 
       "KillTimeout": 30000000000, 
       "ReloadSignal": null, 
       "Splay": 0, 
       "Timeout": 30000000000 
      }, 
      "Perms": 420, 
      "Source": "/consul-template/data/application.properties.tpl", 
      "Wait": { 
       "Enabled": false, 
       "Min": 0, 
       "Max": 0 
      }, 
      "LeftDelim": "", 
      "RightDelim": "" 
     }, 
     { 
      "Backup": false, 
      "Command": "", 
      "CommandTimeout": 30000000000, 
      "Contents": "", 
      "Destination": "/consul-template/output/anotherMicroConsul.properties", 
      "Exec": { 
       "Command": "", 
       "Enabled": false, 
       "Env": { 
        "Blacklist": [], 
        "Custom": [], 
        "Pristine": false, 
        "Whitelist": [] 
       }, 
       "KillSignal": 2, 
       "KillTimeout": 30000000000, 
       "ReloadSignal": null, 
       "Splay": 0, 
       "Timeout": 30000000000 
      }, 
      "Perms": 420, 
      "Source": "/consul-template/data/anotherMicroConsul.properties.tpl", 
      "Wait": { 
       "Enabled": false, 
       "Min": 0, 
       "Max": 0 
      }, 
      "LeftDelim": "", 
      "RightDelim": "" 
     }, 
     { 
      "Backup": false, 
      "Command": "", 
      "CommandTimeout": 30000000000, 
      "Contents": "", 
      "Destination": "/consul-template/output/master.properties", 
      "Exec": { 
       "Command": "", 
       "Enabled": false, 
       "Env": { 
        "Blacklist": [], 
        "Custom": [], 
        "Pristine": false, 
        "Whitelist": [] 
       }, 
       "KillSignal": 2, 
       "KillTimeout": 30000000000, 
       "ReloadSignal": null, 
       "Splay": 0, 
       "Timeout": 30000000000 
      }, 
      "Perms": 420, 
      "Source": "/consul-template/data/master.properties.tpl", 
      "Wait": { 
       "Enabled": false, 
       "Min": 0, 
       "Max": 0 
      }, 
      "LeftDelim": "", 
      "RightDelim": "" 
     }, 
     { 
      "Backup": false, 
      "Command": "", 
      "CommandTimeout": 30000000000, 
      "Contents": "", 
      "Destination": "/consul-template/output/microConsul.properties", 
      "Exec": { 
       "Command": "", 
       "Enabled": false, 
       "Env": { 
        "Blacklist": [], 
        "Custom": [], 
        "Pristine": false, 
        "Whitelist": [] 
       }, 
       "KillSignal": 2, 
       "KillTimeout": 30000000000, 
       "ReloadSignal": null, 
       "Splay": 0, 
       "Timeout": 30000000000 
      }, 
      "Perms": 420, 
      "Source": "/consul-template/data/microConsul.properties.tpl", 
      "Wait": { 
       "Enabled": false, 
       "Min": 0, 
       "Max": 0 
      }, 
      "LeftDelim": "", 
      "RightDelim": "" 
     } 
    ], 
    "Vault": { 
     "Address": "", 
     "Enabled": false, 
     "Grace": 15000000000, 
     "RenewToken": true, 
     "Retry": { 
      "Attempts": 12, 
      "Backoff": 250000000, 
      "MaxBackoff": 60000000000, 
      "Enabled": true 
     }, 
     "SSL": { 
      "CaCert": "", 
      "CaPath": "", 
      "Cert": "", 
      "Enabled": true, 
      "Key": "", 
      "ServerName": "", 
      "Verify": true 
     }, 
     "Transport": { 
      "DialKeepAlive": 30000000000, 
      "DialTimeout": 30000000000, 
      "DisableKeepAlives": false, 
      "IdleConnTimeout": 90000000000, 
      "MaxIdleConns": 100, 
      "MaxIdleConnsPerHost": 3, 
      "TLSHandshakeTimeout": 10000000000 
     }, 
     "UnwrapToken": false 
    }, 
    "Wait": { 
     "Enabled": false, 
     "Min": 0, 
     "Max": 0 
    } 
} 

通過此錯誤消息似乎來自Renewsession.go未來的代碼貨物篩選。

我是不是應該在領事看?我有多個Consul-Template容器正在運行(每個主機都有一個) - 我應該看幾個會話嗎?現在,我看不出有什麼...

curl localhost:8500/v1/session/list 
[] 

回答

0

原因:你有一個代理或者領事模板和領事之間的負載均衡。

解決方法:增加空閒連接負載平衡器或代理超時的東西上面60秒(如:65sec或120秒),因爲之後的keepalive會踢,將保持連接:)

詳細

  • HTTP 504網關超時,這意味着連接已經被「腰斬」,或服務變得反應遲鈍,但我會假設你領事集羣仍然因此工作是由於活動的網絡設備中(betw een領事模板和領事)
  • 領事模板打開持久連接來監聽變化。因此,如果連接被負載平衡器無聲地終止,則最終會出現這504個錯誤。
  • 這些消息是良性的,因爲consul-template重新連接正常。不過,他們是討厭,將在填寫您的日誌和磁盤空間使用相同的警告及以上;-)
  • 如果AWS,請將您的ELB空閒超時65sec這些消息將會消失
相關問題