spring-cloud / spring-cloud/spring-cloud-consul
Ttl Heartbeats don't send acl token if configured
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 822
- Forks
- 539
- Avg merge
- 9h 31m
- Merged PRs (30d)
- 7
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?)
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with TtlScheduler.java and the ConsulHeartbeatTask.run entry point shown in the issue, then inspect how the ACL token is configured for the heartbeat. Done means TTL heartbeats pass the configured token to Consul, while still allowing a null token.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, spring
- Domain
- backend, distributed-systems
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 45/100