Skip to content

Commit

Permalink
Merge pull request #495 from avanthakkar/fix-podvolume-osd
Browse files Browse the repository at this point in the history
Bug 2203795: core: empty ceph-daemons-sock-dir for osd onPVC
  • Loading branch information
travisn authored Jun 1, 2023
2 parents cafcddb + 9ef22a4 commit b57f0c7
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 10 deletions.
2 changes: 1 addition & 1 deletion pkg/operator/ceph/cluster/osd/provision_spec.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ func (c *Cluster) provisionPodTemplateSpec(osdProps osdProperties, restart v1.Re

// ceph-volume is currently set up to use /etc/ceph/ceph.conf; this means no user config
// overrides will apply to ceph-volume, but this is unnecessary anyway
volumes := append(controller.PodVolumes(provisionConfig.DataPathMap, c.spec.DataDirHostPath, true), copyBinariesVolume)
volumes := append(controller.PodVolumes(provisionConfig.DataPathMap, c.spec.DataDirHostPath, c.spec.DataDirHostPath, true), copyBinariesVolume)

// create a volume on /dev so the pod can access devices on the host
devVolume := v1.Volume{Name: "devices", VolumeSource: v1.VolumeSource{HostPath: &v1.HostPathVolumeSource{Path: "/dev"}}}
Expand Down
2 changes: 1 addition & 1 deletion pkg/operator/ceph/cluster/osd/spec.go
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ func (c *Cluster) makeDeployment(osdProps osdProperties, osd OSDInfo, provisionC
if osdProps.onPVC() {
dataDirHostPath = ""
}
volumes := controller.PodVolumes(provisionConfig.DataPathMap, dataDirHostPath, false)
volumes := controller.PodVolumes(provisionConfig.DataPathMap, dataDirHostPath, c.spec.DataDirHostPath, false)
failureDomainValue := osdProps.crushHostname
doConfigInit := true // initialize ceph.conf in init container?
doBinaryCopyInit := true // copy rook binary in an init container?
Expand Down
7 changes: 3 additions & 4 deletions pkg/operator/ceph/controller/spec.go
Original file line number Diff line number Diff line change
Expand Up @@ -167,15 +167,14 @@ func ConfGeneratedInPodVolumeAndMount() (v1.Volume, v1.VolumeMount) {

// PodVolumes fills in the volumes parameter with the common list of Kubernetes volumes for use in Ceph pods.
// This function is only used for OSDs.
func PodVolumes(dataPaths *config.DataPathMap, dataDirHostPath string, confGeneratedInPod bool) []v1.Volume {
func PodVolumes(dataPaths *config.DataPathMap, dataDirHostPath string, exporterHostPath string, confGeneratedInPod bool) []v1.Volume {

dataDirSource := v1.VolumeSource{EmptyDir: &v1.EmptyDirVolumeSource{}}
sockDirSource := v1.VolumeSource{EmptyDir: &v1.EmptyDirVolumeSource{}}
if dataDirHostPath != "" {
dataDirSource = v1.VolumeSource{HostPath: &v1.HostPathVolumeSource{Path: dataDirHostPath}}
hostPathType := v1.HostPathDirectoryOrCreate
sockDirSource = v1.VolumeSource{HostPath: &v1.HostPathVolumeSource{Path: path.Join(dataDirHostPath, daemonSocketsSubPath), Type: &hostPathType}}
}
hostPathType := v1.HostPathDirectoryOrCreate
sockDirSource := v1.VolumeSource{HostPath: &v1.HostPathVolumeSource{Path: path.Join(exporterHostPath, daemonSocketsSubPath), Type: &hostPathType}}
configVolume, _ := configOverrideConfigMapVolumeAndMount()
if confGeneratedInPod {
configVolume, _ = ConfGeneratedInPodVolumeAndMount()
Expand Down
14 changes: 10 additions & 4 deletions pkg/operator/ceph/controller/spec_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,23 +40,29 @@ import (
)

func TestPodVolumes(t *testing.T) {
clusterSpec := cephv1.ClusterSpec{
DataDirHostPath: "/var/lib/rook/",
}
dataPathMap := config.NewDatalessDaemonDataPathMap("rook-ceph", "/var/lib/rook")

if err := test.VolumeIsEmptyDir(k8sutil.DataDirVolume, PodVolumes(dataPathMap, "", false)); err != nil {
if err := test.VolumeIsEmptyDir(k8sutil.DataDirVolume, PodVolumes(dataPathMap, "", clusterSpec.DataDirHostPath, false)); err != nil {
t.Errorf("PodVolumes(\"\") - data dir source is not EmptyDir: %s", err.Error())
}
if err := test.VolumeIsHostPath(k8sutil.DataDirVolume, "/dev/sdb", PodVolumes(dataPathMap, "/dev/sdb", false)); err != nil {
if err := test.VolumeIsHostPath(k8sutil.DataDirVolume, "/dev/sdb", PodVolumes(dataPathMap, "/dev/sdb", clusterSpec.DataDirHostPath, false)); err != nil {
t.Errorf("PodVolumes(\"/dev/sdb\") - data dir source is not HostPath: %s", err.Error())
}
}

func TestMountsMatchVolumes(t *testing.T) {
clusterSpec := cephv1.ClusterSpec{
DataDirHostPath: "/var/lib/rook/",
}

dataPathMap := config.NewDatalessDaemonDataPathMap("rook-ceph", "/var/lib/rook")

volsMountsTestDef := test.VolumesAndMountsTestDefinition{
VolumesSpec: &test.VolumesSpec{
Moniker: "PodVolumes(\"/dev/sdc\")", Volumes: PodVolumes(dataPathMap, "/dev/sdc", false)},
Moniker: "PodVolumes(\"/dev/sdc\")", Volumes: PodVolumes(dataPathMap, "/dev/sdc", clusterSpec.DataDirHostPath, false)},
MountsSpecItems: []*test.MountsSpec{
{Moniker: "CephVolumeMounts(true)", Mounts: CephVolumeMounts(dataPathMap, false)},
{Moniker: "RookVolumeMounts(true)", Mounts: RookVolumeMounts(dataPathMap, false)}},
Expand All @@ -65,7 +71,7 @@ func TestMountsMatchVolumes(t *testing.T) {

volsMountsTestDef = test.VolumesAndMountsTestDefinition{
VolumesSpec: &test.VolumesSpec{
Moniker: "PodVolumes(\"/dev/sdc\")", Volumes: PodVolumes(dataPathMap, "/dev/sdc", true)},
Moniker: "PodVolumes(\"/dev/sdc\")", Volumes: PodVolumes(dataPathMap, "/dev/sdc", clusterSpec.DataDirHostPath, true)},
MountsSpecItems: []*test.MountsSpec{
{Moniker: "CephVolumeMounts(false)", Mounts: CephVolumeMounts(dataPathMap, true)},
{Moniker: "RookVolumeMounts(false)", Mounts: RookVolumeMounts(dataPathMap, true)}},
Expand Down

0 comments on commit b57f0c7

Please sign in to comment.