Skip to content

After enable TTL, DeregisterCriticalServiceAfter not working . #490

Closed
@nikotung

Description

@nikotung
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
  }'

Activity

spencergibb

spencergibb commented on Jan 29, 2019

@spencergibb
Member

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

added this to the 2.0.3.RELEASE milestone on Jan 29, 2019
nikotung

nikotung commented on Jan 29, 2019

@nikotung
ContributorAuthor

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

scrat98 commented on Feb 20, 2019

@scrat98

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

spencergibb

spencergibb commented on Feb 20, 2019

@spencergibb
Member

@scrat98 PRs welcome

added this to the 2.1.1.RELEASE milestone on Mar 4, 2019

3 remaining items

Loading
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

      Participants

      @ryanjbaxter@spencergibb@nikotung@spring-projects-issues@scrat98

      Issue actions

        After enable TTL, DeregisterCriticalServiceAfter not working . · Issue #490 · spring-cloud/spring-cloud-consul