You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cassandra.apache.org by "Stefan Miklosovic (Jira)" <ji...@apache.org> on 2026/03/27 10:02:00 UTC

[jira] [Created] (CASSSIDECAR-417) CdcManager.getInstanceId(instanceIp) returns -1 as it resolves ipAddress to null

Stefan Miklosovic created CASSSIDECAR-417:
---------------------------------------------

             Summary: CdcManager.getInstanceId(instanceIp) returns -1 as it resolves ipAddress to null
                 Key: CASSSIDECAR-417
                 URL: https://issues.apache.org/jira/browse/CASSSIDECAR-417
             Project: Sidecar for Apache Cassandra
          Issue Type: Bug
            Reporter: Stefan Miklosovic


I am gettingĀ 
{code}
CdcManager.java:222 - Requested IP 172.19.0.5 does not match with any instances
{code}

Looking at it, this returns null to configuredIpAddress

{code}
    private Integer getInstanceId(String instanceIp)
    {
        for (InstanceMetadata instance : instanceFetcher.allLocalInstances())
        {
            String configuredIpAddress = instance.ipAddress();
{code}


then resolveToSameAddress fails equality test so it returns -1.

What seems to help is to fallback to host() instead of ipAddress() like this:

{code}
    private Integer getInstanceId(String instanceIp)
    {
        for (InstanceMetadata instance : instanceFetcher.allLocalInstances())
        {
            String configuredIpAddress = instance.ipAddress();
            String configuredHost = instance.host();

            LOGGER.info("Matching instanceIp={} against instance id={} host={} ipAddress={}",
                        instanceIp, instance.id(), configuredHost, configuredIpAddress);

            // Try IP-based comparison first
            if (resolveToSameAddress(instanceIp, configuredIpAddress))
            {
                LOGGER.info("Matched instance id={} by IP address", instance.id());
                return instance.id();
            }

            // Fallback: try comparing against the configured hostname
            if (resolveToSameAddress(instanceIp, configuredHost))
            {
                LOGGER.info("Matched instance id={} by hostname={} (IP comparison failed for cachedIp={})",
                            instance.id(), configuredHost, configuredIpAddress);
                return instance.id();
            }
        }
        LOGGER.warn("Requested IP {} does not match with any instances", instanceIp);
        return -1;
    }
{code}

It is questionable why we see null in {{configuredIpAddress}}, it seems like {{dns_resolver}} returns null. I have dockerized environment, maybe that's to blame. I tried to change default dns_resolver to resolve_to_ip but no difference.

Anyway, I guess falling back to hostname resolution is not a bad idea.

Patch included.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cassandra.apache.org
For additional commands, e-mail: commits-help@cassandra.apache.org