[ 
https://issues.apache.org/jira/browse/CASSSIDECAR-417?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Stefan Miklosovic reassigned CASSSIDECAR-417:
---------------------------------------------

    Assignee: Jyothsna Konisa  (was: Stefan Miklosovic)

> 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
>          Components: CDC
>            Reporter: Stefan Miklosovic
>            Assignee: Jyothsna Konisa
>            Priority: Major
>             Fix For: 0.x
>
>          Time Spent: 1h
>  Remaining Estimate: 0h
>
> 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: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to