Open
Description
If heartbeat is enabled paired with acl tokens, then the heartbeat task does not configure the token to use when communicating with the consul server
spring.cloud.consul.discovery:
acl-token: ${uuid}
heartbeat.enabled: true
ConsulHeartbeatTask has this method call to agentCheckPass:
@Override
public void run() {
TtlScheduler.this.client.agentCheckPass(this.checkId);
if (log.isDebugEnabled()) {
log.debug("Sending consul heartbeat for: " + this.checkId);
}
}
Which without a token, you'll see the following stack trace:
com.ecwid.consul.v1.OperationException: OperationException(statusCode=403, statusMessage='Forbidden', statusContent='Permission denied')
at com.ecwid.consul.v1.agent.AgentConsulClient.agentCheckPass(AgentConsulClient.java:211) ~[consul-api-1.4.1.jar:na]
at com.ecwid.consul.v1.agent.AgentConsulClient.agentCheckPass(AgentConsulClient.java:198) ~[consul-api-1.4.1.jar:na]
at com.ecwid.consul.v1.agent.AgentConsulClient.agentCheckPass(AgentConsulClient.java:193) ~[consul-api-1.4.1.jar:na]
at com.ecwid.consul.v1.ConsulClient.agentCheckPass(ConsulClient.java:259) ~[consul-api-1.4.1.jar:na]
at org.springframework.cloud.consul.discovery.TtlScheduler$ConsulHeartbeatTask.run(TtlScheduler.java:95) ~[spring-cloud-consul-discovery-2.1.1.RELEASE.jar:2.1.1.RELEASE]
Which can be overridden to pass a token too (can be null too):
@Override
public void run() {
TtlScheduler.this.client.agentCheckPass(this.checkId, this.aclToken);
if (log.isDebugEnabled()) {
log.debug("Sending consul heartbeat for: " + this.checkId);
}
}
So any reason why i can't submit a simple PR to fix this (Ie am i missing something?)
Activity
spencergibb commentedon May 16, 2019
PRs welcome
chriswhite199 commentedon May 16, 2019
An AOP based approach to patch while a PR is worked on: