Skip to content

Commit

Permalink
Set ScyllaCluster placement requirements on cleanup Jobs
Browse files Browse the repository at this point in the history
Missing placement might cause cleanup Jobs to be stuck in Pending state
forever, preventing ScyllaCluster from fully boostrapping.
Placement requirements are copied into cleanup Jobs from ScyllaCluster
spec.
  • Loading branch information
zimnx committed Oct 19, 2023
1 parent 458f9bb commit 4fe4e28
Show file tree
Hide file tree
Showing 2 changed files with 389 additions and 0 deletions.
13 changes: 13 additions & 0 deletions pkg/controller/scyllacluster/resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -1053,6 +1053,17 @@ func MakeJobs(sc *scyllav1.ScyllaCluster, services map[string]*corev1.Service, i
naming.CleanupJobTokenRingHashAnnotation: currentTokenRingHash,
}

var tolerations []corev1.Toleration
var affinity *corev1.Affinity
if rack.Placement != nil {
tolerations = rack.Placement.Tolerations
affinity = &corev1.Affinity{
NodeAffinity: rack.Placement.NodeAffinity,
PodAffinity: rack.Placement.PodAffinity,
PodAntiAffinity: rack.Placement.PodAntiAffinity,
}
}

jobs = append(jobs, &batchv1.Job{
ObjectMeta: metav1.ObjectMeta{
Name: naming.CleanupJobForService(svc.Name),
Expand All @@ -1070,6 +1081,8 @@ func MakeJobs(sc *scyllav1.ScyllaCluster, services map[string]*corev1.Service, i
Annotations: annotations,
},
Spec: corev1.PodSpec{
Tolerations: tolerations,
Affinity: affinity,
RestartPolicy: corev1.RestartPolicyOnFailure,
Containers: []corev1.Container{
{
Expand Down
Loading

0 comments on commit 4fe4e28

Please sign in to comment.