From 6ce9cd500b98181930f23371cdc1764d65752bcb Mon Sep 17 00:00:00 2001 From: Olivier Michallat Date: Fri, 10 May 2024 16:34:38 -0700 Subject: [PATCH] Update nodeStatuses info when a pod is recreated (fixes #652) --- CHANGELOG.md | 2 ++ pkg/reconciliation/reconcile_racks.go | 8 ++++---- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d5110fbf..ab6d64f5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,8 @@ Changelog for Cass Operator, new PRs should update the `main / unreleased` secti ## unreleased +* [BUGFIX] [#652](https://github.com/k8ssandra/cass-operator/issues/652) Update nodeStatuses info when a pod is recreated + ## v1.20.0 * [CHANGE] [#566](https://github.com/k8ssandra/cass-operator/issues/566) BREAKING: StatefulSets will no longer be automatically updated if CassandraDatacenter is not modified, unless an annotation "cassandra.datastax.com/autoupdate-spec" is set to the CassandraDatacenter with value "always" or "once". This means users of config secret should set this variable to "always" to keep their existing behavior. For other users, this means that for example the upgrades of operator will no longer automatically apply updated settings or system-logger image. The benefit is that updating the operator no longer causes the cluster to have a rolling restart. A new condition to indicate such change could be necessary is called "RequiresUpdate" and it will be set to True until the next refresh of reconcile has happened. diff --git a/pkg/reconciliation/reconcile_racks.go b/pkg/reconciliation/reconcile_racks.go index d048cf6a..af914313 100644 --- a/pkg/reconciliation/reconcile_racks.go +++ b/pkg/reconciliation/reconcile_racks.go @@ -989,21 +989,21 @@ func (rc *ReconciliationContext) UpdateCassandraNodeStatus(force bool) error { } if pod.Status.PodIP != "" && isMgmtApiRunning(pod) { + ip := getRpcAddress(dc, pod) + nodeStatus.IP = ip + nodeStatus.Rack = pod.Labels[api.RackLabel] + // Getting the HostID requires a call to the node management API which is // moderately expensive, so if we already have a HostID, don't bother. This // would only change if something has gone horribly horribly wrong. - if force || nodeStatus.HostID == "" { endpointsResponse, err := rc.NodeMgmtClient.CallMetadataEndpointsEndpoint(pod) if err == nil { - ip := getRpcAddress(dc, pod) nodeStatus.HostID = findHostIdForIpFromEndpointsData( endpointsResponse.Entity, ip) if nodeStatus.HostID == "" { logger.Info("Failed to find host ID", "pod", pod.Name) } - nodeStatus.IP = ip - nodeStatus.Rack = pod.Labels[api.RackLabel] } } }