New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
file: allow to create CephFS dataPools with predefined names #9296
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,7 +14,7 @@ parameters: | |
|
||
# Ceph pool into which the volume shall be created | ||
# Required for provisionVolume: "true" | ||
pool: myfs-data0 | ||
pool: myfs-replicated | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We should change There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ok, updated. |
||
|
||
# The secrets contain Ceph admin credentials. These are generated automatically by the operator | ||
# in the same namespace as the cluster. | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -639,6 +639,14 @@ type PoolSpec struct { | |
Quotas QuotaSpec `json:"quotas,omitempty"` | ||
} | ||
|
||
// NamedPoolSpec represents the named ceph pool spec | ||
type NamedPoolSpec struct { | ||
// Name of the pool | ||
Name string `json:"name,omitempty"` | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm still struggling a bit with calling this We still might want to make this struct CephFilesystem specific (i.e., not reusing the named pool spec for CephBlockPool) and having the doc text be something like "unique identifier for the pool within the filesystem. will be prefixed with the metadata name." We should also mention that we do most definitely recommend setting the pool name here since it helps resolve errors that could arise from altering the pool list. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I like the NamedPoolSpec to use both for the CephBlockPool and the CephFilesystem. In the Filesystem docs sounds good to just be clear that the filesystem name is prepended to the name. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Yeah, we may add note that name for pool will be prepended to the filesystem name. |
||
// PoolSpec represents the spec of ceph pool | ||
PoolSpec `json:",inline"` | ||
} | ||
|
||
// MirrorHealthCheckSpec represents the health specification of a Ceph Storage Pool mirror | ||
type MirrorHealthCheckSpec struct { | ||
// +optional | ||
|
@@ -964,9 +972,9 @@ type FilesystemSpec struct { | |
// +nullable | ||
MetadataPool PoolSpec `json:"metadataPool"` | ||
|
||
// The data pool settings | ||
// The data pool settings, with optional predefined pool name. | ||
// +nullable | ||
DataPools []PoolSpec `json:"dataPools"` | ||
DataPools []NamedPoolSpec `json:"dataPools"` | ||
|
||
// Preserve pools on filesystem deletion | ||
// +optional | ||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -134,7 +134,7 @@ func validateFilesystem(context *clusterd.Context, clusterInfo *cephclient.Clust | |
return errors.Wrap(err, "invalid metadata pool") | ||
} | ||
for _, p := range f.Spec.DataPools { | ||
localpoolSpec := p | ||
localpoolSpec := p.PoolSpec | ||
if err := pool.ValidatePoolSpec(context, clusterInfo, clusterSpec, &localpoolSpec); err != nil { | ||
return errors.Wrap(err, "Invalid data pool") | ||
} | ||
|
@@ -163,7 +163,7 @@ func SetPoolSize(f *Filesystem, context *clusterd.Context, clusterInfo *cephclie | |
dataPoolNames := generateDataPoolNames(f, spec) | ||
for i, pool := range spec.DataPools { | ||
poolName := dataPoolNames[i] | ||
err := cephclient.CreatePoolWithProfile(context, clusterInfo, clusterSpec, poolName, pool, "") | ||
err := cephclient.CreatePoolWithProfile(context, clusterInfo, clusterSpec, poolName, pool.PoolSpec, "") | ||
if err != nil { | ||
return errors.Wrapf(err, "failed to update datapool %q", poolName) | ||
} | ||
|
@@ -243,7 +243,7 @@ func (f *Filesystem) doFilesystemCreate(context *clusterd.Context, clusterInfo * | |
for i, pool := range spec.DataPools { | ||
poolName := dataPoolNames[i] | ||
if _, poolFound := reversedPoolMap[poolName]; !poolFound { | ||
err = cephclient.CreatePoolWithProfile(context, clusterInfo, clusterSpec, poolName, pool, "") | ||
err = cephclient.CreatePoolWithProfile(context, clusterInfo, clusterSpec, poolName, pool.PoolSpec, "") | ||
if err != nil { | ||
return errors.Wrapf(err, "failed to create data pool %q", poolName) | ||
} | ||
|
@@ -278,10 +278,16 @@ func downFilesystem(context *clusterd.Context, clusterInfo *cephclient.ClusterIn | |
} | ||
|
||
// generateDataPoolName generates DataPool name by prefixing the filesystem name to the constant DataPoolSuffix | ||
// or get predefined name from spec | ||
func generateDataPoolNames(f *Filesystem, spec cephv1.FilesystemSpec) []string { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. How about a unit test for this name generation method? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sure, let me add it |
||
var dataPoolNames []string | ||
for i := range spec.DataPools { | ||
poolName := fmt.Sprintf("%s-%s%d", f.Name, dataPoolSuffix, i) | ||
for i, pool := range spec.DataPools { | ||
poolName := "" | ||
if pool.Name == "" { | ||
poolName = fmt.Sprintf("%s-%s%d", f.Name, dataPoolSuffix, i) | ||
} else { | ||
poolName = fmt.Sprintf("%s-%s", f.Name, pool.Name) | ||
} | ||
dataPoolNames = append(dataPoolNames, poolName) | ||
} | ||
return dataPoolNames | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are also some examples in
nfs.yaml
andnfs-test.yaml
IIRC. Those might have been gone for a bit, so rebasing and doing a search formyfs-data0
again might helpThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nsf.yaml
contains next:So i guess, it is clear, why used such name, isn't it?