osd: ensure rook version label is not set on pod
The rook-version tag must not be set on the pod spec labels
since it will result in the ceph daemons being restarted every
time there is a rook version update, even if the ceph version
or pod spec was not otherwise updated.
The rook-version tag was being added to the OSD pod spec
due to a shared pointer to the labels. The code intended
to only add the version label to the deployment labels,
but since the pod labels shared the map variable, the
pod unintentionally also had the version label added.
Signed-off-by: Travis Nielsen <tnielsen@redhat.com>
(cherry picked from commit 1ba93b4047)
This commit is contained in:
1 parent
f3b00dce6f
commit
2d73ca4ff2
2 files changed
+19
-2
No files matched your search
@@ -436,6 +436,14 @@ func TestGetOSDInfo(t *testing.T) {
|
||||
DataPathMap: opconfig.NewDatalessDaemonDataPathMap(c.clusterInfo.Namespace, c.spec.DataDirHostPath),
|
||||
}
|
||||
|
||||
t.Run("version labels are on deployment and not pod spec", func(t *testing.T) {
|
||||
d1, _ := c.makeDeployment(osdProp, osd1, dataPathMap)
|
||||
assert.NotEqual(t, "", d1.Labels["rook-version"])
|
||||
assert.Equal(t, "", d1.Spec.Template.Labels["rook-version"])
|
||||
assert.NotEqual(t, "", d1.Labels["ceph-version"])
|
||||
assert.Equal(t, "", d1.Spec.Template.Labels["ceph-version"])
|
||||
})
|
||||
|
||||
t.Run("get info from PVC-based OSDs", func(t *testing.T) {
|
||||
d1, _ := c.makeDeployment(osdProp, osd1, dataPathMap)
|
||||
osdInfo1, _ := c.getOSDInfo(d1)
|
||||
|
||||
@@ -617,11 +617,21 @@ func (c *Cluster) makeDeployment(osdProps osdProperties, osd OSDInfo, provisionC
|
||||
|
||||
k8sutil.RemoveDuplicateEnvVars(&podTemplateSpec.Spec)
|
||||
|
||||
// Copy the pod labels into a new map so the deployment labels can
|
||||
// diverge from the pod labels. For example, we don't want the
|
||||
// rook-version label to be added to the pod labels or else it will
|
||||
// cause the osd pods to be updated with every rook upgrade even if
|
||||
// the osds don't need to restart.
|
||||
deploymentLabels := map[string]string{}
|
||||
for key, value := range podTemplateSpec.Labels {
|
||||
deploymentLabels[key] = value
|
||||
}
|
||||
|
||||
deployment := &apps.Deployment{
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
Name: deploymentName,
|
||||
Namespace: c.clusterInfo.Namespace,
|
||||
Labels: podTemplateSpec.Labels,
|
||||
Labels: deploymentLabels,
|
||||
},
|
||||
Spec: apps.DeploymentSpec{
|
||||
Selector: &metav1.LabelSelector{
|
||||
@@ -669,7 +679,6 @@ func (c *Cluster) makeDeployment(osdProps osdProperties, osd OSDInfo, provisionC
|
||||
cephv1.GetOSDLabels(c.spec.Labels).ApplyToObjectMeta(&deployment.ObjectMeta)
|
||||
cephv1.GetOSDLabels(c.spec.Labels).ApplyToObjectMeta(&deployment.Spec.Template.ObjectMeta)
|
||||
controller.AddCephVersionLabelToDeployment(c.clusterInfo.CephVersion, deployment)
|
||||
controller.AddCephVersionLabelToDeployment(c.clusterInfo.CephVersion, deployment)
|
||||
err := c.clusterInfo.OwnerInfo.SetControllerReference(deployment)
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(err, "failed to set owner reference to osd deployment %q", deployment.Name)
|
||||
|
||||
Reference in new issue
Block a user