spring-cloud / spring-cloud/spring-cloud-netflix

Document uses of eureka appName, vipAddress, with regards to spring cloud uses of serviceId, etc...

Open
#1,788 7 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

documentation
Dominant language
Java
Stars
5k
Forks
2.5k
Avg merge
1d 2h
Merged PRs (30d)
10

Description

EurekaDiscoveryClient.getIntsances(String) doesn't use the serviceId or application name but the VIP Address to lookup instances:

	public List<ServiceInstance> getInstances(String serviceId) {
		List<InstanceInfo> infos = this.eurekaClient.getInstancesByVipAddress(serviceId,
				false);
		List<ServiceInstance> instances = new ArrayList<>();
		for (InstanceInfo info : infos) {
			instances.add(new EurekaServiceInstance(info));
		}
		return instances;
	}

here's the doc for DiscoverClient.getInstances(String serviceId)

	/**
	 * Get all ServiceInstances associated with a particular serviceId
	 * @param serviceId the serviceId to query
	 * @return a List of ServiceInstance
	 */
	List<ServiceInstance> getInstances(String serviceId);

So far I haven't noticed this as EurekaInstanceConfigBean uses spring.application.name as virtualHostName which is used by InstanceInfoFactory as VIPAddress

here's the doc for InstanceInfo:

    /**
     * Gets the Virtual Internet Protocol address for this instance. Defaults to
     * hostname if not specified.
     *
     * @return - The Virtual Internet Protocol address
     */
    @JsonProperty("vipAddress")
    public String getVIPAddress() {
        return vipAddress;
    }

        /**
         * Sets the Virtual Internet Protocol address for this instance. The
         * address should follow the format <code><hostname:port></code> This
         * address needs to be resolved into a real address for communicating
         * with this instance.
         *
         * @param vipAddress - The Virtual Internet Protocol address of this instance.
         * @return the instance builder.
         */
        public Builder setVIPAddress(String vipAddress) {
            result.vipAddressUnresolved = StringCache.intern(vipAddress);
            result.vipAddress = StringCache.intern(resolveDeploymentContextBasedVipAddresses(vipAddress));
            return this;
        }

so it looks like this implementation treats application name and VIP address as synonyms - and don't rely use VIP addresses anywhere - so that's why this bug went undetected.

So the proper implementation would be this:

	@Override
	public List<ServiceInstance> getInstances(String serviceId) {
		Application application = this.eurekaClient.getApplication(serviceId);
		List<ServiceInstance> instances = new ArrayList<>();
		if (application != null) {
			for (InstanceInfo info : application.getInstances()) {
				instances.add(new EurekaServiceInstance(info));
			}
		}
		return instances;
	}

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at EurekaDiscoveryClient.getInstances(String) and compare its VIP-address lookup with DiscoverClient.getInstances(String). Read EurekaInstanceConfigBean, InstanceInfoFactory, and InstanceInfo to clarify how application name and VIP address relate. Done means serviceId lookup behavior and the appName/VIP documentation are corrected, with relevant tests passing.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, spring
Domain
backend, distributed-systems
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.