spring-cloud-netflix icon indicating copy to clipboard operation
spring-cloud-netflix copied to clipboard

eureka.client.initial-instance-info-replication-interval-seconds with initial delay can not take effect bug

Open irwinai opened this issue 3 years ago • 0 comments

Describe the bug Spring Boot Version: 2.7.2 || 1.9.8

Hello, team When I want to use the eureka delay initial function, I found that is not effect in the case. such as I set the property:eureka.client.initial-instance-info-replication-interval-seconds=100 But, in the EurekaServiceRegistry -- register function, used the setInstanceStatus to update initial status

@Override
	public void register(EurekaRegistration reg) {
		maybeInitializeClient(reg);

		if (log.isInfoEnabled()) {
			log.info("Registering application "
					+ reg.getApplicationInfoManager().getInfo().getAppName()
					+ " with eureka with status "
					+ reg.getInstanceConfig().getInitialStatus());
		}

		reg.getApplicationInfoManager()
				.setInstanceStatus(reg.getInstanceConfig().getInitialStatus());

		reg.getHealthCheckHandler().ifAvailable(healthCheckHandler -> reg
				.getEurekaClient().registerHealthCheck(healthCheckHandler));
	}

and then will trigger StatusChangeEvent. So, DiscoveryClient will be goto instanceInfoReplicator.onDemandUpdate() to register client to Eureka Server.

 statusChangeListener = new ApplicationInfoManager.StatusChangeListener() {
                @Override
                public String getId() {
                    return "statusChangeListener";
                }

                @Override
                public void notify(StatusChangeEvent statusChangeEvent) {
                    if (InstanceStatus.DOWN == statusChangeEvent.getStatus() ||
                            InstanceStatus.DOWN == statusChangeEvent.getPreviousStatus()) {
                        // log at warn level if DOWN was involved
                        logger.warn("Saw local status change event {}", statusChangeEvent);
                    } else {
                        logger.info("Saw local status change event {}", statusChangeEvent);
                    }
                    instanceInfoReplicator.onDemandUpdate();
                }
            };

            if (clientConfig.shouldOnDemandUpdateStatusChange()) {
                applicationInfoManager.registerStatusChangeListener(statusChangeListener);
            }

At last, the eureka.client.initial-instance-info-replication-interval-seconds can not take effect.

Sample

eureka.client.initial-instance-info-replication-interval-seconds=99999
eureka.client.instance-info-replication-interval-seconds=88888

irwinai avatar Jul 27 '22 08:07 irwinai