Skip to content

After enable TTL, DeregisterCriticalServiceAfter not working . #490

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

Closed
nikotung opened this issue Jan 29, 2019 · 4 comments · Fixed by #500
Closed

After enable TTL, DeregisterCriticalServiceAfter not working . #490

nikotung opened this issue Jan 29, 2019 · 4 comments · Fixed by #500

Comments

@nikotung
Copy link
Contributor

I used the following config to enable the TTL and DeregisterCriticalServiceAfter.

spring:
   cloud:
     consul:
        host: localhost
        port: 8500
        discovery:
          instance-id: ${spring.application.name}:${vcap.application.instance_id:${spring.application.instance_id:${random.value}}}
         health-check-critical-timeout: 3m
         heartbeat:
            enabled: true
            ttl-value: 30

When the application crash(exit without executing the deregister ),the application will be in the critical status on consul ui and never be removed by consul.

I read the code and found that the other parameters are ignored when the ttl are enable.

public static NewService.Check createCheck(Integer port, HeartbeatProperties ttlConfig,
									 ConsulDiscoveryProperties properties) {
	NewService.Check check = new NewService.Check();
	if (ttlConfig.isEnabled()) {
		check.setTtl(ttlConfig.getTtl());
		return check;
	}
	...
	return check;
}

So my question is: Why the DeregisterCriticalServiceAfter is ignored.

Since it is not conflict with the ttl. And I check the consul.io document.

I alse test with the following curl script.The application:test-critical will be removed by consul automatically after 1 minute

curl -X "PUT" "http://localhost:8500/v1/agent/service/register" \
 -H 'Content-Type: application/json' \
 -d $'{
    "ID": "test-critical-9e7433ac909aaf67ce256818b8e14e28",
    "Address": "10.0.11.179",
    "Name": "test-critical",
    "Check": {
      "TTL": "20s",
      "DeregisterCriticalServiceAfter": "1m"
    },
    "Port": 8080
  }'
@spencergibb
Copy link
Member

I think that the consul-api library used to only support one Check, that is not the case anymore.

@nikotung
Copy link
Contributor Author

I know the consul-api library used to only support one Check. I think that the DeregisterCriticalServiceAfter is kind of consul agent behavior, and no matter what kind of check we specified ,the DeregisterCriticalServiceAfter should not be ignored when it is config.

@scrat98
Copy link

scrat98 commented Feb 20, 2019

Same issue. Could you please add DeregisterCriticalServiceAfter feature on TTL checks. Thanks!

@spencergibb
Copy link
Member

@scrat98 PRs welcome

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants