Skip to content

Commit

Permalink
Pin LXD dependency to stable-5.21 (#277)
Browse files Browse the repository at this point in the history
  • Loading branch information
tomponline authored Nov 6, 2024
2 parents 898ef9b + 3673c40 commit beb4f0b
Show file tree
Hide file tree
Showing 8 changed files with 46 additions and 579 deletions.
6 changes: 5 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,11 @@ endif
# Update targets.
.PHONY: update-gomod
update-gomod:
go get -t -v -d -u ./...
go get -t -v -u ./...

# Static pins
go get github.com/canonical/[email protected] # Stay on v2 dqlite and LXD LTS client

go mod tidy -go=$(GOMIN)

# Update lxd-generate generated database helpers.
Expand Down
9 changes: 4 additions & 5 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ go 1.22.7

require (
github.com/canonical/go-dqlite/v2 v2.0.0
github.com/canonical/lxd v0.0.0-20241022112222-538639622c38
github.com/fsnotify/fsnotify v1.7.0
github.com/canonical/lxd v0.0.0-20241105095730-921967798cb1
github.com/fsnotify/fsnotify v1.8.0
github.com/google/renameio v1.0.1
github.com/gorilla/mux v1.8.1
github.com/gorilla/websocket v1.5.3
Expand All @@ -20,7 +20,6 @@ require (
require (
github.com/Rican7/retry v0.3.1 // indirect
github.com/armon/go-proxyproto v0.1.0 // indirect
github.com/canonical/go-dqlite v1.22.0 // indirect
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
github.com/flosch/pongo2 v0.0.0-20200913210552-0d938eb266f3 // indirect
github.com/fvbommel/sortorder v1.1.0 // indirect
Expand All @@ -37,7 +36,7 @@ require (
github.com/mattn/go-runewidth v0.0.16 // indirect
github.com/muhlemmer/gu v0.3.1 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/pkg/sftp v1.13.6 // indirect
github.com/pkg/sftp v1.13.7 // indirect
github.com/pkg/xattr v0.4.10 // indirect
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
github.com/rivo/uniseg v0.4.7 // indirect
Expand All @@ -46,7 +45,7 @@ require (
github.com/sirupsen/logrus v1.9.3 // indirect
github.com/spf13/pflag v1.0.5 // indirect
github.com/zitadel/logging v0.6.1 // indirect
github.com/zitadel/oidc/v3 v3.31.0 // indirect
github.com/zitadel/oidc/v3 v3.32.1 // indirect
github.com/zitadel/schema v1.3.0 // indirect
go.opentelemetry.io/otel v1.31.0 // indirect
go.opentelemetry.io/otel/metric v1.31.0 // indirect
Expand Down
578 changes: 23 additions & 555 deletions go.sum

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions internal/daemon/daemon.go
Original file line number Diff line number Diff line change
Expand Up @@ -467,7 +467,7 @@ func (d *Daemon) initServer(resources ...rest.Resources) *http.Server {

mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Content-Type", "application/json")
err := response.SyncResponse(true, []string{"/1.0"}).Render(w, r)
err := response.SyncResponse(true, []string{"/1.0"}).Render(w)
if err != nil {
logger.Error("Failed to write HTTP response", logger.Ctx{"url": r.URL, "err": err})
}
Expand All @@ -476,7 +476,7 @@ func (d *Daemon) initServer(resources ...rest.Resources) *http.Server {
mux.NotFoundHandler = http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
logger.Info("Sending top level 404", logger.Ctx{"url": r.URL})
w.Header().Set("Content-Type", "application/json")
err := response.NotFound(nil).Render(w, r)
err := response.NotFound(nil).Render(w)
if err != nil {
logger.Error("Failed to write HTTP response", logger.Ctx{"url": r.URL, "err": err})
}
Expand Down
6 changes: 3 additions & 3 deletions internal/rest/resources/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,7 @@ func clusterMemberPut(s state.State, r *http.Request) response.Response {
go reExec()

return response.ManualResponse(func(w http.ResponseWriter) error {
err := response.EmptySyncResponse.Render(w, r)
err := response.EmptySyncResponse.Render(w)
if err != nil {
return err
}
Expand Down Expand Up @@ -448,7 +448,7 @@ func clusterMemberDelete(s state.State, r *http.Request) response.Response {
}

return response.ManualResponse(func(w http.ResponseWriter) error {
err := response.EmptySyncResponse.Render(w, r)
err := response.EmptySyncResponse.Render(w)
if err != nil {
return err
}
Expand Down Expand Up @@ -566,7 +566,7 @@ func clusterMemberDelete(s state.State, r *http.Request) response.Response {
}

return response.ManualResponse(func(w http.ResponseWriter) error {
err := response.EmptySyncResponse.Render(w, r)
err := response.EmptySyncResponse.Render(w)
if err != nil {
return err
}
Expand Down
8 changes: 2 additions & 6 deletions internal/rest/resources/hooks_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import (
"io"
"net/http"
"net/http/httptest"
"net/url"
"strings"
"testing"

Expand Down Expand Up @@ -117,10 +116,7 @@ func (t *hooksSuite) Test_hooks() {
ranHook = ""
isForce = false
expectForce := false
req := &http.Request{
// Set an URL for response.Render to not cause any panic.
URL: &url.URL{},
}
req := &http.Request{}
payload, ok := c.req.(internalTypes.HookRemoveMemberOptions)
if !ok {
payload, ok := c.req.(internalTypes.HookNewMemberOptions)
Expand All @@ -135,7 +131,7 @@ func (t *hooksSuite) Test_hooks() {

response := hooksPost(s, req)
recorder := httptest.NewRecorder()
err := response.Render(recorder, req)
err := response.Render(recorder)
require.NoError(t.T(), err)

var resp api.Response
Expand Down
2 changes: 1 addition & 1 deletion internal/rest/resources/shutdown.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ func shutdownPost(state state.State, r *http.Request) response.Response {

// Run shutdown sequence synchronously.
exit, stopErr := intState.Stop()
err := response.SmartError(stopErr).Render(w, r)
err := response.SmartError(stopErr).Render(w)
if err != nil {
return err
}
Expand Down
12 changes: 6 additions & 6 deletions internal/rest/rest.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ func handleAPIRequest(action rest.EndpointAction, state state.State, w http.Resp
}

if resp != nil {
err := resp.Render(w, r)
err := resp.Render(w)
if err != nil {
return response.InternalError(err)
}
Expand Down Expand Up @@ -194,7 +194,7 @@ func HandleEndpoint(state state.State, mux *mux.Router, version string, e rest.E

intState, err := internalState.ToInternal(state)
if err != nil {
err := response.BadRequest(err).Render(w, r)
err := response.BadRequest(err).Render(w)
if err != nil {
logger.Error("Failed to write HTTP response", logger.Ctx{"url": r.URL, "err": err})
}
Expand All @@ -204,7 +204,7 @@ func HandleEndpoint(state state.State, mux *mux.Router, version string, e rest.E

// Return Unavailable Error (503) if daemon is shutting down, except for endpoints with AllowedDuringShutdown.
if intState.Context.Err() == context.Canceled && !e.AllowedDuringShutdown {
err := response.Unavailable(fmt.Errorf("Daemon is shutting down")).Render(w, r)
err := response.Unavailable(fmt.Errorf("Daemon is shutting down")).Render(w)
if err != nil {
logger.Error("Failed to write HTTP response", logger.Ctx{"url": r.URL, "err": err})
}
Expand All @@ -215,7 +215,7 @@ func HandleEndpoint(state state.State, mux *mux.Router, version string, e rest.E
if !e.AllowedBeforeInit {
err := state.Database().IsOpen(r.Context())
if err != nil {
err := response.SmartError(err).Render(w, r)
err := response.SmartError(err).Render(w)
if err != nil {
logger.Error("Failed to write HTTP response", logger.Ctx{"url": r.URL, "err": err})
}
Expand Down Expand Up @@ -259,9 +259,9 @@ func HandleEndpoint(state state.State, mux *mux.Router, version string, e rest.E
// we can ensure that the connection wasn't yet hijacked and the actual error
// can be safely returned to the caller.
if e.Path != "database" || (e.Path == "database" && resp != response.EmptySyncResponse) {
err := resp.Render(w, r)
err := resp.Render(w)
if err != nil {
err := response.InternalError(err).Render(w, r)
err := response.InternalError(err).Render(w)
if err != nil {
logger.Error("Failed writing error for HTTP response", logger.Ctx{"url": url, "error": err})
}
Expand Down

0 comments on commit beb4f0b

Please sign in to comment.