Merge pull request #10101 from rook/mergify/bp/release-1.9/pr-10099
block: validate updating names in BlockPool CR (backport #10099)
This commit is contained in:
2 files changed
+9
No files matched your search
@@ -112,6 +112,9 @@ func (p *CephBlockPool) ValidateUpdate(old runtime.Object) error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if ocbp.Spec.Name != p.Spec.Name {
|
||||
return errors.New("invalid update: pool name cannot be changed")
|
||||
}
|
||||
if p.Spec.ErasureCoded.CodingChunks > 0 || p.Spec.ErasureCoded.DataChunks > 0 || p.Spec.ErasureCoded.Algorithm != "" {
|
||||
if ocbp.Spec.Replicated.Size > 0 || ocbp.Spec.Replicated.TargetSizeRatio > 0 {
|
||||
return errors.New("invalid update: replicated field is set already in previous object. cannot be changed to use erasurecoded")
|
||||
|
||||
@@ -61,6 +61,12 @@ func TestCephBlockPoolValidateUpdate(t *testing.T) {
|
||||
up.Spec.ErasureCoded.CodingChunks = 1
|
||||
err := up.ValidateUpdate(p)
|
||||
assert.Error(t, err)
|
||||
|
||||
// validate with different name in Spec.Name
|
||||
ip := p.DeepCopy()
|
||||
ip.Spec.Name = "new-ec-pool"
|
||||
err = ip.ValidateUpdate(p)
|
||||
assert.Error(t, err)
|
||||
}
|
||||
|
||||
func TestMirroringSpec_SnapshotSchedulesEnabled(t *testing.T) {
|
||||
|
||||
Reference in new issue
Block a user