Skip to content

Commit

Permalink
microcloud/cmd/microcloud: Use quincy client package
Browse files Browse the repository at this point in the history
The OSD API was changed with reef, but there is a manual patch that
makes it compatible with the quincy Go client.
https://github.com/canonical/microceph/blob/2bddc9d6280d903dcb52a993833e991873565550/microceph/api/disks.go#L163-L172

So we can use that instead to support both reef and quincy.

Signed-off-by: Max Asnaashari <[email protected]>
  • Loading branch information
masnax committed Jan 10, 2025
1 parent cb5c84b commit f51890a
Show file tree
Hide file tree
Showing 7 changed files with 10 additions and 28 deletions.
8 changes: 2 additions & 6 deletions microcloud/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,8 @@ update-gomod:
# Grab MicroOVN from the corresponding support branch.
go get github.com/canonical/microovn/[email protected]

# There is a reef branch, but its microcluster dependency has breaking changes.
# Also, the quincy branch has an outdated client for the MicroCeph API offered with reef/stable.
#
# As such, we have to grab the latest commit which uses a compatible microcluster,
# but recent enough to also account for reef's breaking API changes.
go get github.com/canonical/microceph/[email protected]
# There is a reef branch, but its microcluster dependency has breaking changes, so use quincy instead.
go get github.com/canonical/microceph/microceph@quincy

# Branches named `vN` where N is a number are reserved by go for module versions,
# So we are forced to grab the corresponding commit hash for the `v1` branch instead.
Expand Down
2 changes: 1 addition & 1 deletion microcloud/cmd/microcloud/ask.go
Original file line number Diff line number Diff line change
Expand Up @@ -485,7 +485,7 @@ func askRemotePool(systems map[string]InitSystem, autoSetup bool, wipeAllDisks b
system.MicroCephDisks = []cephTypes.DisksPost{}
}

system.MicroCephDisks = append(system.MicroCephDisks, cephTypes.DisksPost{Path: []string{path}, Wipe: wipeMap[entry]})
system.MicroCephDisks = append(system.MicroCephDisks, cephTypes.DisksPost{Path: path, Wipe: wipeMap[entry]})

systems[target] = system
}
Expand Down
9 changes: 1 addition & 8 deletions microcloud/cmd/microcloud/main_init.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package main

import (
"context"
"errors"
"fmt"
"net"
"os"
Expand Down Expand Up @@ -446,16 +445,10 @@ func setupCluster(s *service.Handler, systems map[string]InitSystem) error {
}

logger.Debug("Adding disk to MicroCeph", logger.Ctx{"peer": s.Name, "disk": disk.Path})
resp, err := cephClient.AddDisk(context.Background(), c, &disk)
err := cephClient.AddDisk(context.Background(), c, &disk)
if err != nil {
return err
}

for _, r := range resp.Reports {
if r.Error != "" {
return errors.New(r.Error)
}
}
}
}

Expand Down
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 @@ -486,7 +486,7 @@ func (p *Preseed) Parse(s *service.Handler, bootstrap bool) (map[string]InitSyst
}

for _, disk := range directCeph {
system.MicroCephDisks = append(system.MicroCephDisks, cephTypes.DisksPost{Path: []string{disk.Path}, Wipe: disk.Wipe})
system.MicroCephDisks = append(system.MicroCephDisks, cephTypes.DisksPost{Path: disk.Path, Wipe: disk.Wipe})
}

// Setup ceph pool for disks specified to MicroCeph.
Expand Down Expand Up @@ -555,7 +555,7 @@ func (p *Preseed) Parse(s *service.Handler, bootstrap bool) (map[string]InitSyst
}

for _, disk := range matched {
system.MicroCephDisks = append(system.MicroCephDisks, cephTypes.DisksPost{Path: []string{parseDiskPath(disk)}, Wipe: filter.Wipe})
system.MicroCephDisks = append(system.MicroCephDisks, cephTypes.DisksPost{Path: parseDiskPath(disk), Wipe: filter.Wipe})
// There should only be one ceph pool per system.
if !addedCephPool {
if bootstrap {
Expand Down
2 changes: 1 addition & 1 deletion microcloud/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ require (
github.com/AlecAivazis/survey/v2 v2.3.7
github.com/Netflix/go-expect v0.0.0-20220104043353-73e0943537d2
github.com/canonical/lxd v0.0.0-20241209143752-5a8ba0bdd60b
github.com/canonical/microceph/microceph v0.0.0-20240610102219-bc3fe1e7b68f
github.com/canonical/microceph/microceph v0.0.0-20231201205217-287ee689aa80
github.com/canonical/microcluster v0.0.0-20241212191815-dba2a1b44d4d
github.com/canonical/microovn/microovn v0.0.0-20241022125142-cad8ee9dc5e7
github.com/creack/pty v1.1.24
Expand Down
4 changes: 2 additions & 2 deletions microcloud/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ github.com/canonical/go-dqlite/v2 v2.0.0 h1:RNFcFVhHMh70muKKErbW35rSzqmAFswheHdA
github.com/canonical/go-dqlite/v2 v2.0.0/go.mod h1:IaIC8u4Z1UmPjuAqPzA2r83YMaMHRLoKZdHKI5uHCJI=
github.com/canonical/lxd v0.0.0-20241209143752-5a8ba0bdd60b h1:xrdihzBO8sC+dARb+g6qryKoWzrPA13qB37nSmA1xBo=
github.com/canonical/lxd v0.0.0-20241209143752-5a8ba0bdd60b/go.mod h1:2pcjouGIaU1Qv4q6gYzs+x3WCRqB8T2aTpRKHOK2RZo=
github.com/canonical/microceph/microceph v0.0.0-20240610102219-bc3fe1e7b68f h1:MYdE0HCKBclQPhkfvVhhNPOK5ofJ8WOzKBWdhyPtQrQ=
github.com/canonical/microceph/microceph v0.0.0-20240610102219-bc3fe1e7b68f/go.mod h1:rDBLUPhZuzxKnMVUmiucGsNz0mo9Tvg0QYL6ClJCln8=
github.com/canonical/microceph/microceph v0.0.0-20231201205217-287ee689aa80 h1:gqmSBYiCP1JKzviIq0dnJ1wm8vsupu7dvYWTAGQHlAE=
github.com/canonical/microceph/microceph v0.0.0-20231201205217-287ee689aa80/go.mod h1:tF7FxOcZrF7z9ZZ02oGOthRlZrvuSyDCFCCENm3aOMQ=
github.com/canonical/microcluster v0.0.0-20241212191815-dba2a1b44d4d h1:vHo2iYyK097ttggmtxWfx9glHMsPhTLqSfGXwoYz+Qg=
github.com/canonical/microcluster v0.0.0-20241212191815-dba2a1b44d4d/go.mod h1:1LFvUQ7h/6MQzDDmqbSTuYMHSbTAZtbvKSEIE3hADm8=
github.com/canonical/microovn/microovn v0.0.0-20241022125142-cad8ee9dc5e7 h1:b6qzw7P6lbVn8kP5v2buFQAfmNCdHhFSVdErhIJCaMw=
Expand Down
9 changes: 1 addition & 8 deletions microcloud/service/microceph.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package service

import (
"context"
"errors"
"fmt"
"net/http"
"net/url"
Expand Down Expand Up @@ -122,16 +121,10 @@ func (s CephService) Join(ctx context.Context, joinConfig JoinConfig) error {
}

for _, disk := range joinConfig.CephConfig {
resp, err := cephClient.AddDisk(ctx, c, &disk)
err := cephClient.AddDisk(ctx, c, &disk)
if err != nil {
return err
}

for _, r := range resp.Reports {
if r.Error != "" {
return errors.New(r.Error)
}
}
}

return nil
Expand Down

0 comments on commit f51890a

Please sign in to comment.