Skip to content

Commit

Permalink
Fix schema updates by allowing healthy dcs to get the schema changes
Browse files Browse the repository at this point in the history
  • Loading branch information
adejanovski committed Apr 11, 2024
1 parent d509dd1 commit c663b10
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 1 deletion.
12 changes: 12 additions & 0 deletions apis/k8ssandra/v1alpha1/k8ssandracluster_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,18 @@ func (in *K8ssandraCluster) GetInitializedDatacenters() []CassandraDatacenterTem
return datacenters
}

func (in *K8ssandraCluster) GetHealthyDatacenters() []CassandraDatacenterTemplate {
datacenters := make([]CassandraDatacenterTemplate, 0)
if in != nil && in.Spec.Cassandra != nil {
for _, dc := range in.Spec.Cassandra.Datacenters {
if status, found := in.Status.Datacenters[dc.Meta.Name]; found && status.Cassandra.GetConditionStatus(cassdcapi.DatacenterHealthy) == corev1.ConditionTrue {
datacenters = append(datacenters, dc)
}
}
}
return datacenters
}

// SanitizedName returns a sanitized version of the name returned by CassClusterName()
func (in *K8ssandraCluster) SanitizedName() string {
return cassdcapi.CleanupForKubernetes(in.CassClusterName())
Expand Down
2 changes: 1 addition & 1 deletion controllers/k8ssandra/schemas.go
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ func (r *K8ssandraClusterReconciler) updateReplicationOfSystemKeyspaces(
return recResult
}

replication := cassandra.ComputeReplicationFromDatacenters(3, kc.Spec.ExternalDatacenters, kc.GetInitializedDatacenters()...)
replication := cassandra.ComputeReplicationFromDatacenters(3, kc.Spec.ExternalDatacenters, kc.GetHealthyDatacenters()...)

logger.Info("Preparing to update replication for system keyspaces", "replication", replication)

Expand Down
10 changes: 10 additions & 0 deletions test/framework/framework.go
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,11 @@ func (f *Framework) SetDatacenterStatusReady(ctx context.Context, key ClusterKey
Status: corev1.ConditionTrue,
LastTransitionTime: now,
})
dc.Status.SetCondition(cassdcapi.DatacenterCondition{
Type: cassdcapi.DatacenterHealthy,
Status: corev1.ConditionTrue,
LastTransitionTime: now,
})
dc.Status.ObservedGeneration = dc.Generation
dc.Status.NodeStatuses = cassdcapi.CassandraStatusMap{}
for i := 0; i < int(dc.Spec.Size); i++ {
Expand Down Expand Up @@ -373,6 +378,11 @@ func (f *Framework) SetDatacenterStatusStopped(ctx context.Context, key ClusterK
Status: corev1.ConditionTrue,
LastTransitionTime: now,
})
dc.Status.SetCondition(cassdcapi.DatacenterCondition{
Type: cassdcapi.DatacenterHealthy,
Status: corev1.ConditionTrue,
LastTransitionTime: now,
})
dc.Status.ObservedGeneration = dc.Generation
})
}
Expand Down

0 comments on commit c663b10

Please sign in to comment.