cpp cassandra driver (2.12) doesn't seems to work properly in kuberenetes
After deleted the cassandra pods for testing I have the following errors in my app that uses the cpp driver
1592907111.602 [WARN] (src/connection_pool.cpp:272:void cass::ConnectionPool::on_reconnect(cass::DelayedConnector*)): Connection pool was unable to reconnect to host 10.244.135.3 because of the following error: Connect error 'connection refused' 1592907113.605 [WARN] (src/connection_pool.cpp:272:void cass::ConnectionPool::on_reconnect(cass::DelayedConnector*)): Connection pool was unable to reconnect to host 10.244.135.3 because of the following error: Connect error 'connection refused'
The ip address 10.244.135.3 doesn't exist, so it seems that cpp driver is using one of the old pod ip addresses:
# kubectl exec -it hf-apiserver-7748dd65cd-ftndw -c apiserver -- env | grep CASSANDRA_HOSTNAME CASSANDRA_HOSTNAME=hyperfile-cassandra-seed-service.cass-operator.svc.cluster.local
# kubectl exec -it hf-apiserver-7748dd65cd-ftndw -c apiserver -- nslookup hyperfile-cassandra-seed-service.cass-operator.svc.cluster.local Server: 10.96.0.10 Address: 10.96.0.10#53 Name: hyperfile-cassandra-seed-service.cass-operator.svc.cluster.local Address: 10.244.166.133 Name: hyperfile-cassandra-seed-service.cass-operator.svc.cluster.local Address: 10.244.104.7 Name: hyperfile-cassandra-seed-service.cass-operator.svc.cluster.local Address: 10.244.135.6
Note that cassandra pods are healthy and running:
# kubectl get pod -n cass-operator -o wide NAME READY STATUS RESTARTS AGE IP NODE NOMINATED NODE READINESS GATES cass-operator-6d89c5f54f-8ljgr 1/1 Running 0 176m 10.244.104.1 node2 <none> <none> hyperfile-cassandra-dc1-rack1-sts-0 2/2 Running 0 147m 10.244.104.7 node2 <none> <none> hyperfile-cassandra-dc1-rack1-sts-1 2/2 Running 0 136m 10.244.135.6 node3 <none> <none> hyperfile-cassandra-dc1-rack1-sts-2 2/2 Running 0 169m 10.244.166.133 node1 <none> <none>
[EDIT]
My app use the env variable CASSANDRA_HOSTNAME which is set to hyperfile-cassandra-seed-service.cass-operator.svc.cluster.local
# kubectl exec -it hf-apiserver-7748dd65cd-ftndw -c apiserver -- env | grep CASSANDRA_HOSTNAME CASSANDRA_HOSTNAME=hyperfile-cassandra-seed-service.cass-operator.svc.cluster.local
the name hyperfile-cassandra-seed-service.cass-operator.svc.cluster.local comes from the service created by the datastax cassandra operator:
# kubectl get svc hyperfile-cassandra-seed-service -n cass-operator -o yaml apiVersion: v1 kind: Service <snip> name: hyperfile-cassandra-seed-service namespace: cass-operator <snip>