ceph: do not enable ShareProcessNamespace if HostPID

If HostPID is enabled, this means the Ceph version is older than Octopus
and we are still running OSD with HostPID due to an internal
inter-process check.
If the log collector is enabled we need to enable ShareProcessNamespace
**only** if HostIPC is disabled.

Both HostPID and ShareProcessNamespace cannot be enabled.

Signed-off-by: Sébastien Han <seb@redhat.com>
This commit is contained in:
Sébastien Han
2021-02-01 18:23:19 +01:00
parent efefb557a8
commit 8b65eb6126
2 changed files with 39 additions and 3 deletions
+3 -3
View File
@@ -548,9 +548,9 @@ func (c *Cluster) makeDeployment(osdProps osdProperties, osd OSDInfo, provisionC
// If the log collector is enabled we add the side-car container
if c.spec.LogCollector.Enabled {
shareProcessNamespace := true
// If HostIPC is already enabled we don't need to activate shareProcessNamespace since all pods already see each others
if !podTemplateSpec.Spec.HostIPC {
// If HostPID is already enabled we don't need to activate shareProcessNamespace since all pods already see each others
if !podTemplateSpec.Spec.HostPID {
shareProcessNamespace := true
podTemplateSpec.Spec.ShareProcessNamespace = &shareProcessNamespace
}
podTemplateSpec.Spec.Containers = append(podTemplateSpec.Spec.Containers, *controller.LogCollectorContainer(fmt.Sprintf("ceph-osd.%s", osdID), c.clusterInfo.Namespace, c.spec))
@@ -407,6 +407,42 @@ func testPodDevices(t *testing.T, dataDir, deviceName string, allDevices bool) {
for _, flag := range defaultTuneSlowSettings {
assert.Contains(t, deployment.Spec.Template.Spec.Containers[0].Args, flag)
}
// Test shareProcessNamespace presence
assert.True(t, deployment.Spec.Template.Spec.HostPID)
if deployment.Spec.Template.Spec.ShareProcessNamespace != nil {
panic("ShareProcessNamespace should be nil")
}
// Turn on log collector
c.spec.LogCollector.Enabled = true
deployment, err = c.makeDeployment(osdProp, osd, dataPathMap)
assert.NoError(t, err)
assert.True(t, deployment.Spec.Template.Spec.HostPID, deployment.Spec.Template.Spec.HostPID)
if deployment.Spec.Template.Spec.ShareProcessNamespace != nil {
panic("ShareProcessNamespace should be nil")
}
// Test hostPID and ShareProcessNamespace
{
// now set ceph version to nautilus
clusterInfo := &cephclient.ClusterInfo{
Namespace: "ns",
CephVersion: cephver.Octopus,
}
c := New(context, clusterInfo, spec, "rook/rook:myversion")
deployment, err = c.makeDeployment(osdProp, osd, dataPathMap)
assert.NoError(t, err)
assert.False(t, deployment.Spec.Template.Spec.HostPID, deployment.Spec.Template.Spec.HostPID)
// Turn on log collector
c.spec.LogCollector.Enabled = true
deployment, err = c.makeDeployment(osdProp, osd, dataPathMap)
assert.NoError(t, err)
shareProcessNamespace := *deployment.Spec.Template.Spec.ShareProcessNamespace
assert.True(t, shareProcessNamespace)
}
}
func verifyEnvVar(t *testing.T, envVars []v1.EnvVar, expectedName, expectedValue string, expectedFound bool) {