Skip to content
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

Upgrade microceph dependencies #371

Merged
merged 1 commit into from
Jun 20, 2024
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
2 changes: 1 addition & 1 deletion microceph/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ endif
.PHONY: update-gomod
update-gomod:
go get -u ./...
go mod tidy --go=1.21
go mod tidy
go get toolchain@none

# Update lxd-generate generated database helpers.
Expand Down
3 changes: 2 additions & 1 deletion microceph/api/client_configs.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@ import (
"database/sql"
"encoding/json"
"fmt"
"net/http"

"github.com/canonical/microceph/microceph/constants"
"github.com/canonical/microceph/microceph/interfaces"
"net/http"

"github.com/canonical/lxd/lxd/response"
"github.com/canonical/lxd/shared/logger"
Expand Down
28 changes: 0 additions & 28 deletions microceph/api/endpoints.go

This file was deleted.

7 changes: 4 additions & 3 deletions microceph/api/pool.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@ package api

import (
"encoding/json"
"github.com/canonical/lxd/shared/logger"
"net/http"

"github.com/canonical/lxd/shared/logger"

"github.com/canonical/lxd/lxd/response"
"github.com/canonical/microcluster/rest"
"github.com/canonical/microcluster/state"
Expand All @@ -13,10 +14,10 @@ import (
"github.com/canonical/microceph/microceph/ceph"
)

// /1.0/pool endpoint.
// /1.0/pools-op endpoint.
var poolsCmd = rest.Endpoint{
Path: "pools-op",
Put: rest.EndpointAction{Handler: cmdPoolsPut, ProxyTarget: true},
Put: rest.EndpointAction{Handler: cmdPoolsPut, ProxyTarget: true},
}

func cmdPoolsPut(s *state.State, r *http.Request) response.Response {
Expand Down
38 changes: 38 additions & 0 deletions microceph/api/servers.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
package api

import (
"github.com/canonical/microcluster/rest"

"github.com/canonical/microceph/microceph/api/types"
)

var Servers = []rest.Server{
{
CoreAPI: true,
Resources: []rest.Resources{
{
PathPrefix: types.ExtendedPathPrefix,
Endpoints: []rest.Endpoint{
disksCmd,
disksDelCmd,
resourcesCmd,
servicesCmd,
rgwServiceCmd,
configsCmd,
restartServiceCmd,
mdsServiceCmd,
mgrServiceCmd,
monServiceCmd,
rgwServiceCmd,
poolsCmd,
clientCmd,
clientConfigsCmd,
clientConfigsKeyCmd,
microcephCmd,
microcephConfigsCmd,
logLevelCmd,
},
},
},
},
}
10 changes: 10 additions & 0 deletions microceph/api/types/endpoint_prefix.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package types

import (
"github.com/canonical/microcluster/rest/types"
)

const (
// ExtendedPathPrefix is the path prefix that will be used for the extended endpoints.
ExtendedPathPrefix types.EndpointPrefix = "1.0"
)
10 changes: 5 additions & 5 deletions microceph/client/client_configs.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ func SetClientConfig(ctx context.Context, c *client.Client, data *types.ClientCo
queryCtx, cancel := context.WithTimeout(ctx, time.Second*200)
defer cancel()

err := c.Query(queryCtx, "PUT", api.NewURL().Path("client", "configs", data.Key), data, nil)
err := c.Query(queryCtx, "PUT", types.ExtendedPathPrefix, api.NewURL().Path("client", "configs", data.Key), data, nil)
if err != nil {
return fmt.Errorf("failed setting client config: %w, Key: %s, Value: %s", err, data.Key, data.Value)
}
Expand All @@ -29,7 +29,7 @@ func ResetClientConfig(ctx context.Context, c *client.Client, data *types.Client
queryCtx, cancel := context.WithTimeout(ctx, time.Second*200)
defer cancel()

err := c.Query(queryCtx, "DELETE", api.NewURL().Path("client", "configs", data.Key), data, nil)
err := c.Query(queryCtx, "DELETE", types.ExtendedPathPrefix, api.NewURL().Path("client", "configs", data.Key), data, nil)
if err != nil {
return fmt.Errorf("failed clearing client config: %w, Key: %s", err, data.Key)
}
Expand All @@ -43,7 +43,7 @@ func GetClientConfig(ctx context.Context, c *client.Client, data *types.ClientCo

configs := types.ClientConfigs{}

err := c.Query(queryCtx, "GET", api.NewURL().Path("client", "configs", data.Key), data, &configs)
err := c.Query(queryCtx, "GET", types.ExtendedPathPrefix, api.NewURL().Path("client", "configs", data.Key), data, &configs)
if err != nil {
return nil, fmt.Errorf("failed to fetch client config: %w, Key: %s", err, data.Key)
}
Expand All @@ -57,7 +57,7 @@ func ListClientConfig(ctx context.Context, c *client.Client, data *types.ClientC

configs := types.ClientConfigs{}

err := c.Query(queryCtx, "GET", api.NewURL().Path("client", "configs"), data, &configs)
err := c.Query(queryCtx, "GET", types.ExtendedPathPrefix, api.NewURL().Path("client", "configs"), data, &configs)
if err != nil {
return nil, fmt.Errorf("failed to fetch client config: %w, Key: %s", err, data.Key)
}
Expand All @@ -70,7 +70,7 @@ func UpdateClientConf(ctx context.Context, c *client.Client) error {
queryCtx, cancel := context.WithTimeout(ctx, time.Second*20)
defer cancel()

err := c.Query(queryCtx, "PUT", api.NewURL().Path("client", "configs"), nil, nil)
err := c.Query(queryCtx, "PUT", types.ExtendedPathPrefix, api.NewURL().Path("client", "configs"), nil, nil)
if err != nil {
return fmt.Errorf("failed to update the configuration file: %w", err)
}
Expand Down
6 changes: 3 additions & 3 deletions microceph/client/configs.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ func SetConfig(ctx context.Context, c *microCli.Client, data *types.Config) erro
queryCtx, cancel := context.WithTimeout(ctx, time.Second*200)
defer cancel()

err := c.Query(queryCtx, "PUT", api.NewURL().Path("configs"), data, nil)
err := c.Query(queryCtx, "PUT", types.ExtendedPathPrefix, api.NewURL().Path("configs"), data, nil)
if err != nil {
return fmt.Errorf("failed setting cluster config: %w, Key: %s, Value: %s", err, data.Key, data.Value)
}
Expand All @@ -26,7 +26,7 @@ func ClearConfig(ctx context.Context, c *microCli.Client, data *types.Config) er
queryCtx, cancel := context.WithTimeout(ctx, time.Second*200)
defer cancel()

err := c.Query(queryCtx, "DELETE", api.NewURL().Path("configs"), data, nil)
err := c.Query(queryCtx, "DELETE", types.ExtendedPathPrefix, api.NewURL().Path("configs"), data, nil)
if err != nil {
return fmt.Errorf("failed clearing cluster config: %w, Key: %s", err, data.Key)
}
Expand All @@ -40,7 +40,7 @@ func GetConfig(ctx context.Context, c *microCli.Client, data *types.Config) (typ

configs := types.Configs{}

err := c.Query(queryCtx, "GET", api.NewURL().Path("configs"), data, &configs)
err := c.Query(queryCtx, "GET", types.ExtendedPathPrefix, api.NewURL().Path("configs"), data, &configs)
if err != nil {
return nil, fmt.Errorf("failed to fetch cluster config: %w, Key: %s", err, data.Key)
}
Expand Down
8 changes: 4 additions & 4 deletions microceph/client/disks.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ func AddDisk(ctx context.Context, c *microCli.Client, data *types.DisksPost) (ty
defer cancel()

errors := types.DiskAddResponse{}
err := c.Query(queryCtx, "POST", api.NewURL().Path("disks"), data, &errors)
err := c.Query(queryCtx, "POST", types.ExtendedPathPrefix, api.NewURL().Path("disks"), data, &errors)
if err != nil {
return errors, fmt.Errorf("failed to request disk addition %w", err)
}
Expand All @@ -35,7 +35,7 @@ func GetDisks(ctx context.Context, c *microCli.Client) (types.Disks, error) {

disks := types.Disks{}

err := c.Query(queryCtx, "GET", api.NewURL().Path("disks"), nil, &disks)
err := c.Query(queryCtx, "GET", types.ExtendedPathPrefix, api.NewURL().Path("disks"), nil, &disks)
if err != nil {
return nil, fmt.Errorf("failed listing disks: %w", err)
}
Expand All @@ -50,7 +50,7 @@ func GetResources(ctx context.Context, c *microCli.Client) (*api.ResourcesStorag

storage := api.ResourcesStorage{}

err := c.Query(queryCtx, "GET", api.NewURL().Path("resources"), nil, &storage)
err := c.Query(queryCtx, "GET", types.ExtendedPathPrefix, api.NewURL().Path("resources"), nil, &storage)
if err != nil {
return nil, fmt.Errorf("failed listing storage devices: %w", err)
}
Expand Down Expand Up @@ -81,7 +81,7 @@ func RemoveDisk(ctx context.Context, c *microCli.Client, data *types.DisksDelete
}
c = c.UseTarget(location)

err = c.Query(queryCtx, "DELETE", api.NewURL().Path("disks", strconv.FormatInt(data.OSD, 10)), data, nil)
err = c.Query(queryCtx, "DELETE", types.ExtendedPathPrefix, api.NewURL().Path("disks", strconv.FormatInt(data.OSD, 10)), data, nil)
if err != nil {
// Checking if the error is a context deadline exceeded error
if errors.Is(err, context.DeadlineExceeded) {
Expand Down
4 changes: 2 additions & 2 deletions microceph/client/log.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ func LogLevelSet(ctx context.Context, c *microCli.Client, data *types.LogLevelPu
queryCtx, cancel := context.WithTimeout(ctx, time.Second*120)
defer cancel()

err := c.Query(queryCtx, "PUT", api.NewURL().Path("microceph", "configs", "log-level"), data, nil)
err := c.Query(queryCtx, "PUT", types.ExtendedPathPrefix, api.NewURL().Path("microceph", "configs", "log-level"), data, nil)
if err != nil {
return fmt.Errorf("failed setting log level: %w", err)
}
Expand All @@ -29,7 +29,7 @@ func LogLevelGet(ctx context.Context, c *microCli.Client) (uint32, error) {

level := uint32(0)

err := c.Query(queryCtx, "GET", api.NewURL().Path("microceph", "configs", "log-level"), nil, &level)
err := c.Query(queryCtx, "GET", types.ExtendedPathPrefix, api.NewURL().Path("microceph", "configs", "log-level"), nil, &level)
if err != nil {
return 0, fmt.Errorf("failed getting log level: %w", err)
}
Expand Down
2 changes: 1 addition & 1 deletion microceph/client/pool.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ func PoolSetReplicationFactor(ctx context.Context, c *microCli.Client, data *typ
queryCtx, cancel := context.WithTimeout(ctx, time.Second*120)
defer cancel()

err := c.Query(queryCtx, "PUT", api.NewURL().Path("pools-op"), data, nil)
err := c.Query(queryCtx, "PUT", types.ExtendedPathPrefix, api.NewURL().Path("pools-op"), data, nil)
if err != nil {
return fmt.Errorf("failed setting replication factor: %w", err)
}
Expand Down
8 changes: 4 additions & 4 deletions microceph/client/services.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ func GetServices(ctx context.Context, c *client.Client) (types.Services, error)

services := types.Services{}

err := c.Query(queryCtx, "GET", api.NewURL().Path("services"), nil, &services)
err := c.Query(queryCtx, "GET", types.ExtendedPathPrefix, api.NewURL().Path("services"), nil, &services)
if err != nil {
return nil, fmt.Errorf("failed listing services: %w", err)
}
Expand All @@ -37,7 +37,7 @@ func DeleteService(ctx context.Context, c *client.Client, target string, service
// Send this request to target.
c = c.UseTarget(target)

err := c.Query(queryCtx, "DELETE", api.NewURL().Path("services", service), nil, nil)
err := c.Query(queryCtx, "DELETE", types.ExtendedPathPrefix, api.NewURL().Path("services", service), nil, nil)
if err != nil {
return fmt.Errorf("failed disabling service %s: %w", service, err)
}
Expand All @@ -53,7 +53,7 @@ func SendServicePlacementReq(ctx context.Context, c *client.Client, data *types.
// Send this request to target.
c = c.UseTarget(target)

err := c.Query(queryCtx, "PUT", api.NewURL().Path("services", data.Name), data, nil)
err := c.Query(queryCtx, "PUT", types.ExtendedPathPrefix, api.NewURL().Path("services", data.Name), data, nil)
if err != nil {
return fmt.Errorf("failed placing service %s: %w", data.Name, err)
}
Expand All @@ -67,7 +67,7 @@ func RestartService(ctx context.Context, c *client.Client, data *types.Services)
queryCtx, cancel := context.WithTimeout(ctx, time.Second*120)
defer cancel()

err := c.Query(queryCtx, "POST", api.NewURL().Path("services", "restart"), data, nil)
err := c.Query(queryCtx, "POST", types.ExtendedPathPrefix, api.NewURL().Path("services", "restart"), data, nil)
if err != nil {
url := c.URL()
return fmt.Errorf("failed Forwarding To: %s: %w", url.String(), err)
Expand Down
8 changes: 4 additions & 4 deletions microceph/cmd/microceph/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,11 +69,11 @@ func main() {
var cmdClient = cmdClient{common: &commonCmd}
app.AddCommand(cmdClient.Command())

var cmdPool = cmdPool{common: &commonCmd}
app.AddCommand(cmdPool.Command())
var cmdPool = cmdPool{common: &commonCmd}
app.AddCommand(cmdPool.Command())

var cmdLog = cmdLog{common: &commonCmd}
app.AddCommand(cmdLog.Command())
var cmdLog = cmdLog{common: &commonCmd}
app.AddCommand(cmdLog.Command())

app.InitDefaultHelpCmd()

Expand Down
4 changes: 2 additions & 2 deletions microceph/cmd/microcephd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ func (c *cmdDaemon) Command() *cobra.Command {
}

func (c *cmdDaemon) Run(cmd *cobra.Command, args []string) error {
m, err := microcluster.App(microcluster.Args{StateDir: c.flagStateDir, Verbose: c.global.flagLogVerbose, Debug: c.global.flagLogDebug})
m, err := microcluster.App(microcluster.Args{StateDir: c.flagStateDir, Verbose: c.global.flagLogVerbose, Debug: c.global.flagLogDebug, ExtensionServers: api.Servers})
if err != nil {
return err
}
Expand All @@ -86,7 +86,7 @@ func (c *cmdDaemon) Run(cmd *cobra.Command, args []string) error {
return ceph.Start(interf)
}

return m.Start(context.Background(), api.Endpoints, database.SchemaExtensions, nil, h)
return m.Start(context.Background(), database.SchemaExtensions, nil, h)
}

func init() {
Expand Down
Loading
Loading