Skip to content

Fix ceph disk validation #227

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

Merged
merged 3 commits into from
Nov 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions microcloud/cmd/microcloud/main_init_preseed.go
Original file line number Diff line number Diff line change
Expand Up @@ -214,8 +214,8 @@ func (p *Preseed) validate(name string, bootstrap bool) error {
}

containsCephStorage = directCephCount > 0
if containsCephStorage && directCephCount < len(p.Systems) && len(p.Storage.Ceph) == 0 {
return fmt.Errorf("Some systems are missing ceph storage disks")
if containsCephStorage && directCephCount < 3 && len(p.Storage.Ceph) == 0 && bootstrap {
return fmt.Errorf("At least 3 systems must specify ceph storage disks")
}

containsLocalStorage = directLocalCount > 0
Expand Down
33 changes: 29 additions & 4 deletions microcloud/cmd/microcloud/preseed_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,14 +94,35 @@ func (s *preseedSuite) Test_preseedValidateInvalid() {
subnet: "10.0.0.1/24",
systems: []System{{Name: "n1", Storage: InitStorage{Ceph: []DirectStorage{{Path: "def"}}}}, {Name: "n2", Storage: InitStorage{Ceph: []DirectStorage{{Path: "def"}}}}},
addErr: false,
err: errors.New("At least 3 systems are required to configure distributed storage"),
err: errors.New("At least 3 systems must specify ceph storage disks"),
},
{
desc: "Incomplete ceph direct selection",
subnet: "10.0.0.1/24",
systems: []System{{Name: "n1", Storage: InitStorage{Ceph: []DirectStorage{{Path: "def"}}}}, {Name: "n2", Storage: InitStorage{Ceph: []DirectStorage{{Path: "def"}}}}, {Name: "n3"}},
addErr: true,
err: errors.New("Some systems are missing ceph storage disks"),
addErr: false,
err: errors.New("At least 3 systems must specify ceph storage disks"),
},
{
desc: "Minimum ceph direct selection (3) with more systems (4)",
subnet: "10.0.0.1/24",
systems: []System{
{Name: "n1", Storage: InitStorage{Ceph: []DirectStorage{{Path: "def"}}}},
{Name: "n2", Storage: InitStorage{Ceph: []DirectStorage{{Path: "def"}}}},
{Name: "n3", Storage: InitStorage{Ceph: []DirectStorage{{Path: "def"}}}},
{Name: "n4"}},
addErr: false,
err: nil,
},
{
desc: "Multiple disks on the same system don't count towards the minimum quota:",
subnet: "10.0.0.1/24",
systems: []System{
{Name: "n1", Storage: InitStorage{Ceph: []DirectStorage{{Path: "def"}}}},
{Name: "n2", Storage: InitStorage{Ceph: []DirectStorage{{Path: "def"}, {Path: "def2"}}}},
{Name: "n3"}},
addErr: false,
err: errors.New("At least 3 systems must specify ceph storage disks"),
},
{
desc: "Incomplete zfs direct selection",
Expand Down Expand Up @@ -232,7 +253,11 @@ func (s *preseedSuite) Test_preseedValidateInvalid() {
}

err := p.validate("n1", true)
s.EqualError(err, c.err.Error())
if c.err == nil {
s.NoError(err)
} else {
s.EqualError(err, c.err.Error())
}

s.T().Logf("%s in add mode", c.desc)
err = p.validate("n0", false)
Expand Down