core: on crash pod ensure rook version label is not set
ceph crash pod gets rook version label added unintentionally, which is only for deployment label.
changes include:
1, make a copy of the labels for pod spec from deployment labels just before adding rook version label.
2, add unit test to make sure it works as designed.
This fix along with pr 11674 is to stop ceph daemons pod restarting unnecessarily after upgrading rook operator.
Signed-off-by: Ben Gao <bengao168@msn.com>
(cherry picked from commit ed6ed25257)
This commit is contained in:
1 parent
7300dc6142
commit
dcdffce9ff
2 files changed
+11
-2
No files matched your search
@@ -96,13 +96,20 @@ func (r *ReconcileNode) createOrUpdateCephCrash(node corev1.Node, tolerations []
|
||||
|
||||
deploy.ObjectMeta.Labels = deploymentLabels
|
||||
cephv1.GetCrashCollectorLabels(cephCluster.Spec.Labels).ApplyToObjectMeta(&deploy.ObjectMeta)
|
||||
k8sutil.AddRookVersionLabelToDeployment(deploy)
|
||||
if cephVersion != nil {
|
||||
controller.AddCephVersionLabelToDeployment(*cephVersion, deploy)
|
||||
}
|
||||
|
||||
// make a copy labels for pod to avoid rook version gets added to pod spec
|
||||
podLabels := map[string]string{}
|
||||
for key, value := range deploymentLabels {
|
||||
podLabels[key] = value
|
||||
}
|
||||
k8sutil.AddRookVersionLabelToDeployment(deploy)
|
||||
|
||||
deploy.Spec.Template = corev1.PodTemplateSpec{
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
Labels: deploymentLabels,
|
||||
Labels: podLabels,
|
||||
},
|
||||
Spec: corev1.PodSpec{
|
||||
NodeSelector: nodeSelector,
|
||||
|
||||
@@ -169,4 +169,6 @@ func TestCreateOrUpdateCephCrash(t *testing.T) {
|
||||
assert.Equal(t, tolerations, podSpec.Spec.Tolerations)
|
||||
assert.Equal(t, true, podSpec.Spec.HostNetwork)
|
||||
assert.Equal(t, "test-priority-class", podSpec.Spec.PriorityClassName)
|
||||
assert.NotEqual(t, "", deploy.ObjectMeta.Labels["rook-version"])
|
||||
assert.Equal(t, "", podSpec.ObjectMeta.Labels["rook-version"])
|
||||
}
|
||||
Reference in new issue
Block a user