osd: add expand-bluefs init container for host-based cluster
OSD is not resized in host-based clusters even though expanding
the backing block device. It's due to the lack of bluefs-bdev-expand
init container.
Closes: https://github.com/rook/rook/issues/10930
Signed-off-by: Yuma Ogami <yuma-ogami@cybozu.co.jp>
(cherry picked from commit 7599f1bc6b)
This commit is contained in:
1 parent
a9a8517086
commit
304734cf7d
2 files changed
+29
-3
No files matched your search
@@ -51,7 +51,7 @@ const (
|
||||
blockPVCMetadataMapperInitContainer = "blkdevmapper-metadata"
|
||||
blockPVCWalMapperInitContainer = "blkdevmapper-wal"
|
||||
activatePVCOSDInitContainer = "activate"
|
||||
expandPVCOSDInitContainer = "expand-bluefs"
|
||||
expandOSDInitContainer = "expand-bluefs"
|
||||
expandEncryptedPVCOSDInitContainer = "expand-encrypted-bluefs"
|
||||
encryptedPVCStatusOSDInitContainer = "encrypted-block-status"
|
||||
encryptionKeyFileName = "luks_key"
|
||||
@@ -542,6 +542,7 @@ func (c *Cluster) makeDeployment(osdProps osdProperties, osd OSDInfo, provisionC
|
||||
volumes = append(volumes, activateOSDVolume...)
|
||||
volumeMounts = append(volumeMounts, activateOSDContainer.VolumeMounts[0])
|
||||
initContainers = append(initContainers, *activateOSDContainer)
|
||||
initContainers = append(initContainers, c.getExpandInitContainer(osdProps, c.spec.DataDirHostPath, c.clusterInfo.Namespace, osdID, osd))
|
||||
}
|
||||
|
||||
// Doing a chown in a post start lifecycle hook does not reliably complete before the OSD
|
||||
@@ -1167,7 +1168,7 @@ func (c *Cluster) getExpandPVCInitContainer(osdProps osdProperties, osdID string
|
||||
osdDataPath := activateOSDMountPath + osdID
|
||||
|
||||
return v1.Container{
|
||||
Name: expandPVCOSDInitContainer,
|
||||
Name: expandOSDInitContainer,
|
||||
Image: c.spec.CephVersion.Image,
|
||||
ImagePullPolicy: controller.GetContainerImagePullPolicy(c.spec.CephVersion.ImagePullPolicy),
|
||||
Command: []string{
|
||||
@@ -1180,6 +1181,27 @@ func (c *Cluster) getExpandPVCInitContainer(osdProps osdProperties, osdID string
|
||||
}
|
||||
}
|
||||
|
||||
func (c *Cluster) getExpandInitContainer(osdProps osdProperties, configDir, namespace, osdID string, osdInfo OSDInfo) v1.Container {
|
||||
// Output example is in the comments at the beginning of `getExpandPVCInitContainer()`.
|
||||
osdDataPath := activateOSDMountPath + osdID
|
||||
|
||||
return v1.Container{
|
||||
Name: expandOSDInitContainer,
|
||||
Image: c.spec.CephVersion.Image,
|
||||
ImagePullPolicy: controller.GetContainerImagePullPolicy(c.spec.CephVersion.ImagePullPolicy),
|
||||
Command: []string{
|
||||
"ceph-bluestore-tool",
|
||||
},
|
||||
Args: []string{"bluefs-bdev-expand", "--path", osdDataPath},
|
||||
VolumeMounts: []v1.VolumeMount{
|
||||
{Name: activateOSDVolumeName, MountPath: osdDataPath},
|
||||
{Name: "devices", MountPath: "/dev"},
|
||||
},
|
||||
SecurityContext: controller.PrivilegedContext(true),
|
||||
Resources: osdProps.resources,
|
||||
}
|
||||
}
|
||||
|
||||
func (c *Cluster) getExpandEncryptedPVCInitContainer(mountPath string, osdProps osdProperties) v1.Container {
|
||||
/* Command example
|
||||
[root@rook-ceph-osd-0-59b9947547-w8mdq /]# cryptsetup resize set1-data-2-8n462-block-dmcrypt
|
||||
|
||||
@@ -159,13 +159,17 @@ func testPodDevices(t *testing.T, dataDir, deviceName string, allDevices bool) {
|
||||
assert.Equal(t, c.clusterInfo.Namespace, deployment.Spec.Template.ObjectMeta.Labels["rook_cluster"])
|
||||
assert.Equal(t, 1, len(deployment.Spec.Template.ObjectMeta.Annotations))
|
||||
|
||||
assert.Equal(t, 2, len(deployment.Spec.Template.Spec.InitContainers))
|
||||
assert.Equal(t, 3, len(deployment.Spec.Template.Spec.InitContainers))
|
||||
initCont := deployment.Spec.Template.Spec.InitContainers[0]
|
||||
assert.Equal(t, "quay.io/ceph/ceph:v15", initCont.Image)
|
||||
assert.Equal(t, "activate", initCont.Name)
|
||||
assert.Equal(t, 4, len(initCont.VolumeMounts))
|
||||
initCont = deployment.Spec.Template.Spec.InitContainers[1]
|
||||
assert.Equal(t, "quay.io/ceph/ceph:v15", initCont.Image)
|
||||
assert.Equal(t, "expand-bluefs", initCont.Name)
|
||||
assert.Equal(t, 2, len(initCont.VolumeMounts))
|
||||
initCont = deployment.Spec.Template.Spec.InitContainers[2]
|
||||
assert.Equal(t, "quay.io/ceph/ceph:v15", initCont.Image)
|
||||
assert.Equal(t, "chown-container-data-dir", initCont.Name)
|
||||
assert.Equal(t, 7, len(initCont.VolumeMounts))
|
||||
|
||||
|
||||
Reference in new issue
Block a user