quarkus-unleash icon indicating copy to clipboard operation
quarkus-unleash copied to clipboard

Invalid quarkus.unleash.url generated for shared Dev Services container scenario

Open matjazs opened this issue 1 year ago • 0 comments

If the Unleash devservice is started after the same devservice has been initiated in another Quarkus app, the UnleashDevServiceProcessor generates a different quarkus.unleash.url compared to when an existing Unleash container is not found.

When the container is actually started by the processor, the URL built below is passed to the config map:

public String getUrl() {
    return String.format("http://%s:%d/api", this.getUnleashHost(), this.getPort());
}

However, when an existing container is found, the container address in the form localhost:port is passed to the config map:

return maybeContainerAddress
        .map(containerAddress -> new UnleashRunningDevService(FEATURE_NAME,
                containerAddress.getId(),
                null, configMap(containerAddress.getUrl(), null)))
        .orElseGet(defaultUnleashSupplier);

The latter causes the Unleash API is not a valid URL: localhost:4242 error because "localhost" is not a valid protocol when creating client URLs.

A workaround is to explicitly configure the quarkus.unleash.url for the shared container scenario, but this involves changing the configuration each time the startup order of the Quarkus apps changes.

For comparison, the Keycloak devservice allows for configuring the two applications so that when container sharing is active, no additional changes are needed in either application regardless of the startup order.

matjazs avatar Jun 23 '24 17:06 matjazs