Skip to content

Commit

Permalink
Merge pull request #80 from gboutry/fix/microcluster
Browse files Browse the repository at this point in the history
Housekeeping on sunbeamd
  • Loading branch information
hemanthnakkina authored Jan 16, 2024
2 parents 6b440b4 + 1fb35ba commit 366d961
Show file tree
Hide file tree
Showing 15 changed files with 122 additions and 54 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build-golang.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
- name: Setup GO
uses: actions/setup-go@v4
with:
go-version: '1.19'
go-version: '1.21'
- name: Install dependencies
run: |
sudo add-apt-repository -y ppa:dqlite/dev
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/test-golang.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
- name: Setup GO
uses: actions/setup-go@v4
with:
go-version: '1.19'
go-version: '1.21'
- name: Install dependencies
run: |
sudo add-apt-repository -y ppa:dqlite/dev
Expand All @@ -31,7 +31,7 @@ jobs:
- name: Setup GO
uses: actions/setup-go@v4
with:
go-version: '1.19'
go-version: '1.21'
- name: Install dependencies
run: |
sudo add-apt-repository -y ppa:dqlite/dev
Expand Down
6 changes: 3 additions & 3 deletions snap/snapcraft.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -110,16 +110,16 @@ parts:
source: ./sunbeam-microcluster
source-type: local
build-snaps:
- go
- go/1.21/stable
build-environment:
- GOFLAGS: "-mod=readonly"
- GOFLAGS: -mod=readonly -ldflags=-s
override-build: |
set -ex
# Setup build environment
export CGO_CFLAGS="-I${SNAPCRAFT_STAGE}/include/ -I${SNAPCRAFT_STAGE}/usr/local/include/"
export CGO_LDFLAGS="-L${SNAPCRAFT_STAGE}/lib/ -L${SNAPCRAFT_STAGE}/usr/local/lib/"
export CGO_LDFLAGS_ALLOW="(-Wl,-wrap,pthread_create)|(-Wl,-z,now)"
export CGO_LDFLAGS_ALLOW="(-Wl,-wrap,pthread_create)|(-Wl,-z,now)|(-s)"
# Build the binaries
go build -o "${SNAPCRAFT_PART_INSTALL}/bin/sunbeamd" -tags=libsqlite3 ./cmd/sunbeamd
Expand Down
2 changes: 1 addition & 1 deletion sunbeam-microcluster/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ This requires a few dependencies to be installed:

sudo add-apt-repository -y ppa:dqlite/dev
sudo apt install gcc make dqlite-tools libdqlite-dev libraft-dev -y
sudo snap install --channel 1.19 --classic go
sudo snap install --channel 1.21 --classic go

after which is possible to build sunbeam-microcluster:

Expand Down
2 changes: 1 addition & 1 deletion sunbeam-microcluster/api/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (
"github.com/canonical/microcluster/state"
"github.com/gorilla/mux"

"github.com/openstack-snaps/snap-openstack/sunbeam-microcluster/sunbeam"
"github.com/canonical/snap-openstack/sunbeam-microcluster/sunbeam"
)

// /1.0/config/<name> endpoint.
Expand Down
4 changes: 2 additions & 2 deletions sunbeam-microcluster/api/jujuuser.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ import (
"github.com/canonical/microcluster/state"
"github.com/gorilla/mux"

"github.com/openstack-snaps/snap-openstack/sunbeam-microcluster/api/types"
"github.com/openstack-snaps/snap-openstack/sunbeam-microcluster/sunbeam"
"github.com/canonical/snap-openstack/sunbeam-microcluster/api/types"
"github.com/canonical/snap-openstack/sunbeam-microcluster/sunbeam"
)

// /1.0/jujuusers endpoint.
Expand Down
4 changes: 2 additions & 2 deletions sunbeam-microcluster/api/nodes.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ import (
"github.com/canonical/microcluster/state"
"github.com/gorilla/mux"

"github.com/openstack-snaps/snap-openstack/sunbeam-microcluster/api/types"
"github.com/openstack-snaps/snap-openstack/sunbeam-microcluster/sunbeam"
"github.com/canonical/snap-openstack/sunbeam-microcluster/api/types"
"github.com/canonical/snap-openstack/sunbeam-microcluster/sunbeam"
)

// /1.0/nodes endpoint.
Expand Down
2 changes: 1 addition & 1 deletion sunbeam-microcluster/api/terraform.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (
"github.com/canonical/microcluster/state"
"github.com/gorilla/mux"

"github.com/openstack-snaps/snap-openstack/sunbeam-microcluster/sunbeam"
"github.com/canonical/snap-openstack/sunbeam-microcluster/sunbeam"
)

// /1.0/terraformstate endpoint.
Expand Down
18 changes: 9 additions & 9 deletions sunbeam-microcluster/cmd/sunbeamd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ import (
"github.com/canonical/microcluster/state"
"github.com/spf13/cobra"

"github.com/openstack-snaps/snap-openstack/sunbeam-microcluster/api"
"github.com/openstack-snaps/snap-openstack/sunbeam-microcluster/database"
"github.com/openstack-snaps/snap-openstack/sunbeam-microcluster/version"
"github.com/canonical/snap-openstack/sunbeam-microcluster/api"
"github.com/canonical/snap-openstack/sunbeam-microcluster/database"
"github.com/canonical/snap-openstack/sunbeam-microcluster/version"
)

// Debug indicates whether to log debug messages or not.
Expand Down Expand Up @@ -69,7 +69,7 @@ func (c *cmdDaemon) Run(_ *cobra.Command, _ []string) error {
// Placeholder for post-action hooks that can be run by MicroCluster.
h := &config.Hooks{
// OnBootstrap is run after the daemon is initialized and bootstrapped.
OnBootstrap: func(s *state.State) error {
OnBootstrap: func(s *state.State, initConfig map[string]string) error {
logger.Info("This is a hook that runs after the daemon is initialized and bootstrapped")

return nil
Expand All @@ -83,28 +83,28 @@ func (c *cmdDaemon) Run(_ *cobra.Command, _ []string) error {
},

// PostJoin is run after the daemon is initialized and joins a cluster.
PostJoin: func(s *state.State) error {
PostJoin: func(s *state.State, initConfig map[string]string) error {
logger.Info("This is a hook that runs after the daemon is initialized and joins an existing cluster, after OnNewMember runs on all peers")

return nil
},

// PreJoin is run after the daemon is initialized and joins a cluster.
PreJoin: func(s *state.State) error {
PreJoin: func(s *state.State, initConfig map[string]string) error {
logger.Info("This is a hook that runs after the daemon is initialized and joins an existing cluster, before OnNewMember runs on all peers")

return nil
},

// PostRemove is run after the daemon is removed from a cluster.
PostRemove: func(s *state.State) error {
PostRemove: func(s *state.State, force bool) error {
logger.Infof("This is a hook that is run on peer %q after a cluster member is removed", s.Name())

return nil
},

// PreRemove is run before the daemon is removed from the cluster.
PreRemove: func(s *state.State) error {
PreRemove: func(s *state.State, force bool) error {
logger.Infof("This is a hook that is run on peer %q just before it is removed", s.Name())

return nil
Expand All @@ -129,7 +129,7 @@ func (c *cmdDaemon) Run(_ *cobra.Command, _ []string) error {
}

func init() {
rand.Seed(time.Now().UnixNano())
rand.New(rand.NewSource(time.Now().UnixNano()))
}

func main() {
Expand Down
52 changes: 26 additions & 26 deletions sunbeam-microcluster/go.mod
Original file line number Diff line number Diff line change
@@ -1,56 +1,56 @@
module github.com/openstack-snaps/snap-openstack/sunbeam-microcluster
module github.com/canonical/snap-openstack/sunbeam-microcluster

go 1.18
go 1.21

require (
github.com/canonical/lxd v0.0.0-20230705090120-570f7071eeb2
github.com/canonical/microcluster v0.0.0-20230705140256-7726061a60bb
github.com/gorilla/mux v1.8.0
github.com/spf13/cobra v1.7.0
github.com/canonical/lxd v0.0.0-20240115081802-6605050f32f5
github.com/canonical/microcluster v0.0.0-20231129081021-39c3a6d3e1b6
github.com/gorilla/mux v1.8.1
github.com/spf13/cobra v1.8.0
)

require (
github.com/Rican7/retry v0.3.1 // indirect
github.com/armon/go-proxyproto v0.0.0-20210323213023-7e956b284f0a // indirect
github.com/canonical/go-dqlite v1.20.0 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/armon/go-proxyproto v0.1.0 // indirect
github.com/canonical/go-dqlite v1.21.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/fsnotify/fsnotify v1.6.0 // indirect
github.com/fsnotify/fsnotify v1.7.0 // indirect
github.com/go-macaroon-bakery/macaroon-bakery/v3 v3.0.1 // indirect
github.com/go-macaroon-bakery/macaroonpb v1.0.0 // indirect
github.com/golang/protobuf v1.5.3 // indirect
github.com/google/renameio v1.0.1 // indirect
github.com/google/uuid v1.3.0 // indirect
github.com/gorilla/schema v1.2.0 // indirect
github.com/gorilla/securecookie v1.1.1 // indirect
github.com/gorilla/websocket v1.5.0 // indirect
github.com/google/uuid v1.5.0 // indirect
github.com/gorilla/schema v1.2.1 // indirect
github.com/gorilla/securecookie v1.1.2 // indirect
github.com/gorilla/websocket v1.5.1 // indirect
github.com/inconshreveable/mousetrap v1.1.0 // indirect
github.com/juju/webbrowser v1.0.0 // indirect
github.com/julienschmidt/httprouter v1.3.0 // indirect
github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51 // indirect
github.com/kr/fs v0.1.0 // indirect
github.com/mattn/go-sqlite3 v1.14.17 // indirect
github.com/mattn/go-sqlite3 v1.14.19 // indirect
github.com/muhlemmer/gu v0.3.1 // indirect
github.com/pborman/uuid v1.2.1 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/pkg/sftp v1.13.5 // indirect
github.com/pkg/sftp v1.13.6 // indirect
github.com/pkg/xattr v0.4.9 // indirect
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
github.com/robfig/cron/v3 v3.0.1 // indirect
github.com/rogpeppe/fastuuid v1.2.0 // indirect
github.com/sirupsen/logrus v1.9.3 // indirect
github.com/spf13/pflag v1.0.5 // indirect
github.com/stretchr/testify v1.8.4 // indirect
github.com/zitadel/oidc/v2 v2.6.4 // indirect
golang.org/x/crypto v0.11.0 // indirect
golang.org/x/net v0.12.0 // indirect
golang.org/x/oauth2 v0.9.0 // indirect
golang.org/x/sync v0.3.0 // indirect
golang.org/x/sys v0.10.0 // indirect
golang.org/x/term v0.10.0 // indirect
golang.org/x/text v0.11.0 // indirect
google.golang.org/appengine v1.6.7 // indirect
google.golang.org/protobuf v1.31.0 // indirect
github.com/zitadel/oidc/v2 v2.12.0 // indirect
golang.org/x/crypto v0.18.0 // indirect
golang.org/x/net v0.20.0 // indirect
golang.org/x/oauth2 v0.16.0 // indirect
golang.org/x/sync v0.6.0 // indirect
golang.org/x/sys v0.16.0 // indirect
golang.org/x/term v0.16.0 // indirect
golang.org/x/text v0.14.0 // indirect
google.golang.org/appengine v1.6.8 // indirect
google.golang.org/protobuf v1.32.0 // indirect
gopkg.in/errgo.v1 v1.0.1 // indirect
gopkg.in/httprequest.v1 v1.2.1 // indirect
gopkg.in/macaroon.v2 v2.1.0 // indirect
Expand Down
Loading

0 comments on commit 366d961

Please sign in to comment.