core: fix Ceph monitor deployment in separate zones
Previously, Rook would fail to create monitors for a `CephCluster` spec that
required them to be located in distinct failure domains:
```yaml
spec:
mon:
count: 3
failureDomainLabel: topology.kubernetes.io/zone
zones:
- eu-central-1a
- eu-central-1b
- eu-central-1c
```
This was due to the fact that Rook was mistakenly getting the
`failureDomainLabel` from `spec.mon.stretchCluster.failureDomainLabel`.
This commit ensures `spec.mon.failureDomainLabel` is being used instead, which
fixes the cluster deployment for the spec above.
Signed-off-by: Benoît Knecht <bknecht@protonmail.ch>
(cherry picked from commit 1c45677f5e)
This commit is contained in:
1 parent
279eaa3d18
commit
83a20249d1
2 files changed
+67
-1
No files matched your search
@@ -79,7 +79,7 @@ func GetFailureDomainLabel(spec cephv1.ClusterSpec) string {
|
||||
}
|
||||
|
||||
if spec.ZonesRequired() && spec.Mon.FailureDomainLabel != "" {
|
||||
return spec.Mon.StretchCluster.FailureDomainLabel
|
||||
return spec.Mon.FailureDomainLabel
|
||||
}
|
||||
// The default topology label is for a zone
|
||||
return corev1.LabelZoneFailureDomainStable
|
||||
|
||||
@@ -256,3 +256,69 @@ func TestRequiredDuringScheduling(t *testing.T) {
|
||||
testRequiredDuringScheduling(t, true, true, true)
|
||||
testRequiredDuringScheduling(t, false, true, false)
|
||||
}
|
||||
|
||||
func TestGetFailureDomainLabel(t *testing.T) {
|
||||
type args struct {
|
||||
spec cephv1.ClusterSpec
|
||||
}
|
||||
tests := []struct {
|
||||
name string
|
||||
args args
|
||||
want string
|
||||
}{
|
||||
{
|
||||
name: "stretch",
|
||||
args: args{
|
||||
spec: cephv1.ClusterSpec{
|
||||
Mon: cephv1.MonSpec{
|
||||
Count: 3,
|
||||
StretchCluster: &cephv1.StretchClusterSpec{
|
||||
FailureDomainLabel: "topology.kubernetes.io/region",
|
||||
Zones: []cephv1.MonZoneSpec{
|
||||
{Name: "eu-central-1"},
|
||||
{Name: "eu-central-2"},
|
||||
{Name: "eu-central-3"},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
want: "topology.kubernetes.io/region",
|
||||
},
|
||||
{
|
||||
name: "zones",
|
||||
args: args{
|
||||
spec: cephv1.ClusterSpec{
|
||||
Mon: cephv1.MonSpec{
|
||||
Count: 3,
|
||||
FailureDomainLabel: "topology.kubernetes.io/zone",
|
||||
Zones: []cephv1.MonZoneSpec{
|
||||
{Name: "eu-central-1a"},
|
||||
{Name: "eu-central-1b"},
|
||||
{Name: "eu-central-1c"},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
want: "topology.kubernetes.io/zone",
|
||||
},
|
||||
{
|
||||
name: "default",
|
||||
args: args{
|
||||
spec: cephv1.ClusterSpec{
|
||||
Mon: cephv1.MonSpec{
|
||||
Count: 3,
|
||||
},
|
||||
},
|
||||
},
|
||||
want: "topology.kubernetes.io/zone",
|
||||
},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
if got := GetFailureDomainLabel(tt.args.spec); got != tt.want {
|
||||
t.Errorf("GetFailureDomainLabel() = %v, want %v", got, tt.want)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user