cass-operator icon indicating copy to clipboard operation
cass-operator copied to clipboard

fix address comparison for ipv6 cases

Open tom-code opened this issue 3 years ago • 3 comments

What this PR does: fixes address comparison in findHostIdForIpFromEndpointsData to work properly for ipv6.

Which issue(s) this PR fixes: Fixes #1787

Checklist

  • [x] Changes manually tested
  • [ ] Automated Tests added/updated
  • [ ] Documentation added/updated
  • [ ] CHANGELOG.md updated (not required for documentation PRs)
  • [x] CLA Signed: DataStax CLA

tom-code avatar Sep 30 '22 14:09 tom-code

Note, GHA does not allow to test IPv6 functionality - so we need a solution to test that IPv6 only + IPv6/IPv4 combinations work also.

burmanm avatar Sep 30 '22 14:09 burmanm

Note, GHA does not allow to test IPv6 functionality - so we need a solution to test that IPv6 only + IPv6/IPv4 combinations work also.

Is this something we can unit test?

bradfordcp avatar Sep 30 '22 15:09 bradfordcp

Is this something we can unit test?

Probably some parts (which we can identify as places), but that's not really a replacement for real e2e smoke test - given that our outputs won't actually go all the way to Cassandra in unit tests. This place which is fixed here could be unit tested.

burmanm avatar Sep 30 '22 17:09 burmanm

Hey, could you add something along the lines of:

diff --git a/CHANGELOG.md b/CHANGELOG.md
index 7dae3a9..2921100 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -14,6 +14,7 @@ Changelog for Cass Operator, new PRs should update the `main / unreleased` secti
 * [CHANGE] [#447](https://github.com/k8ssandra/cass-operator/issues/447) Update Github actions to remove all deprecated features (set-outputs, node v12 actions)
 * [CHANGE] [#448](https://github.com/k8ssandra/cass-operator/issues/448) Update to operator-sdk 1.25.1, update to go 1.19, update to Kubernetes 1.25, remove amd64 restriction on local builds (cass-operator and system-logger will be built for aarch64 also)
 * [FEATURE] [#441](https://github.com/k8ssandra/cass-operator/issues/441) Implement a CassandraTask for moving single-token nodes
+* [BUGFIX] [#410](https://github.com/k8ssandra/cass-operator/issues/410) Fix installation in IPv6 only environment
 
 ## v1.13.1
 
diff --git a/pkg/reconciliation/reconcile_racks_test.go b/pkg/reconciliation/reconcile_racks_test.go
index 05d22bc..f4d2203 100644
--- a/pkg/reconciliation/reconcile_racks_test.go
+++ b/pkg/reconciliation/reconcile_racks_test.go
@@ -1955,3 +1955,25 @@ func TestStartOneNodePerRack(t *testing.T) {
                })
        }
 }
+
+func TestFindHostIdForIpFromEndpointsData(t *testing.T) {
+       endpoints := []httphelper.EndpointState{
+               {
+                       HostID:     "1",
+                       RpcAddress: "127.0.0.1",
+               },
+               {
+                       HostID:     "2",
+                       RpcAddress: "::1",
+               },
+               {
+                       HostID:     "3",
+                       RpcAddress: "2001:0DB8:0:0:8:800:200C:417A",
+               },
+       }
+
+       assert.Equal(t, "1", findHostIdForIpFromEndpointsData(endpoints, "127.0.0.1"))
+       assert.Equal(t, "2", findHostIdForIpFromEndpointsData(endpoints, "0:0:0:0:0:0:0:1"))
+       assert.Equal(t, "3", findHostIdForIpFromEndpointsData(endpoints, "2001:0DB8::8:800:200C:417A"))
+       assert.Equal(t, "", findHostIdForIpFromEndpointsData(endpoints, "192.168.1.0"))
+}

To this PR? That would add a test for the method as well as update the CHANGELOG.

burmanm avatar Nov 16 '22 15:11 burmanm

thanks for help. I added test and changelog record.

tom-code avatar Nov 19 '22 09:11 tom-code

Thank you for the contribution (this fix will appear in 1.14.0).

burmanm avatar Nov 21 '22 14:11 burmanm