Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The operator keeps on altering keyspace replications at each reconcile #1188

Closed
adejanovski opened this issue Jan 29, 2024 · 0 comments · Fixed by #1189
Closed

The operator keeps on altering keyspace replications at each reconcile #1188

adejanovski opened this issue Jan 29, 2024 · 0 comments · Fixed by #1189
Assignees
Labels
bug Something isn't working done Issues in the state 'done'

Comments

@adejanovski
Copy link
Contributor

It looks like k8ssandra-operator could be altering keyspace replication a little too often and even without justification in some cases:

2024-01-29T15:55:26.639Z	INFO	keyspace reaper_db already exists in cluster alex2 but has wrong replication, altering it	{"controller": "k8ssandracluster", "controllerGroup": "k8ssandra.io", "controllerKind": "K8ssandraCluster", "K8ssandraCluster": {"name":"alex2","namespace":"alex-n50118bo"}, "namespace": "alex-n50118bo", "name": "alex2", "reconcileID": "e8b816df-eb31-4c73-8716-ea6512d3f8d3", "K8ssandraCluster": "alex-n50118bo/alex2", "CassandraDatacenter": "alex-n50118bo/alex2-dc1", "K8SContext": ""}

This happens when two clusters coexist in the same namespace, using dc names overrides which makes them both have a dc1 dc for example, while the cassdc objects are named cluster1-dc1 and cluster2-dc1.
The DC label will be dc1 for pods from both clusters and the following piece of code will misbehave as it's not filtering the pods on the cluster name as well:

func (r *defaultManagementApiFacade) fetchDatacenterPods() ([]corev1.Pod, error) {
	podList := &corev1.PodList{}
	labels := client.MatchingLabels{cassdcapi.DatacenterLabel: r.dc.DatacenterName()}
	if err := r.k8sClient.List(r.ctx, podList, labels); err != nil {
		return nil, err
	} else {
		pods := r.filterPods(podList.Items, func(pod corev1.Pod) bool {
			status := r.getCassandraContainerStatus(pod)
			return status != nil && status.Ready
		})
		if len(pods) == 0 {
			err = fmt.Errorf("no pods in READY state found in datacenter %v", r.dc.Name)
			return nil, err
		}
		return pods, nil
	}
}
@adejanovski adejanovski added bug Something isn't working in-progress Issues in the state 'in-progress' labels Jan 29, 2024
@adejanovski adejanovski self-assigned this Jan 29, 2024
@adejanovski adejanovski added done Issues in the state 'done' and removed in-progress Issues in the state 'in-progress' labels Jan 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working done Issues in the state 'done'
Projects
Archived in project
1 participant