Merge branch 'master' into ceph-restart

This commit is contained in:
Jared Watts
2016-09-02 16:11:05 -07:00
8 changed files with 54 additions and 22 deletions
+1 -1
View File
@@ -7,7 +7,7 @@ cd $GOPATH/src/github.com/quantum
git clone https://github.com/quantum/castle.git
cd castle
git submodule update --init --recursive
sudo apt-get install cmake python-sphinx libudev-dev libaio-dev libblkid-dev libldap2-dev xfslibs-dev libleveldb-dev libexpat1-dev cython libfcgi-dev libatomic-ops-dev libsnappy-dev libgoogle-perftools-dev libjemalloc-dev libkeyutils-dev libcurl4-openssl-dev libcrypto++-dev libssl-dev libboost-dev libboost-thread-dev libboost-system-dev libboost-regex-dev libboost-random-dev libboost-program-options-dev libboost-date-time-dev libboost-iostreams-dev
sudo apt-get install cmake python-sphinx libudev-dev libaio-dev libblkid-dev libldap2-dev xfslibs-dev libleveldb-dev libexpat1-dev cython libfcgi-dev libatomic-ops-dev libsnappy-dev libgoogle-perftools-dev libjemalloc-dev libkeyutils-dev libcurl4-openssl-dev libcrypto++-dev libssl-dev libboost-dev libboost-thread-dev libboost-system-dev libboost-regex-dev libboost-random-dev libboost-program-options-dev libboost-date-time-dev libboost-iostreams-dev python3-all-dev cython3
make -j2 V=1 STATIC=1 ALLOCATOR=tcmalloc build
./bin/castled
```
+1 -1
Submodule ceph updated: 56131a5545...0cbdba99b4
+1 -1
View File
@@ -8,6 +8,6 @@ import (
func main() {
if err := cmd.Execute(); err != nil {
fmt.Printf("castlectl error: %+v", err)
fmt.Printf("castlectl error: %+v\n", err)
}
}
+1 -1
View File
@@ -8,6 +8,6 @@ import (
func main() {
if err := cmd.Execute(); err != nil {
fmt.Printf("castled error: %+v", err)
fmt.Printf("castled error: %+v\n", err)
}
}
Generated
+1 -1
View File
@@ -15,7 +15,7 @@ imports:
- name: github.com/inconshreveable/mousetrap
version: 76626ae9c91c4f2a10f34cad8ce83ea42c93bb75
- name: github.com/quantum/clusterd
version: 7409e697f6eee196a05dce7c86c1499dd878eb71
version: d124d39e6d7b5cc80968d62d65a6ce8d372f8c36
subpackages:
- pkg/inventory
- pkg/orchestrator
+22 -14
View File
@@ -5,12 +5,14 @@ import (
"io/ioutil"
"log"
"os"
"path"
"path/filepath"
"time"
ctx "golang.org/x/net/context"
"github.com/quantum/clusterd/pkg/orchestrator"
"github.com/quantum/clusterd/pkg/util"
)
const (
@@ -19,17 +21,24 @@ const (
type monAgent struct {
cluster *clusterInfo
context *orchestrator.ClusterContext
}
func (a *monAgent) GetName() string {
func (a *monAgent) Name() string {
return monitorAgentName
}
func (a *monAgent) ConfigureLocalService(context *orchestrator.ClusterContext) error {
a.context = context
var err error
// check if the monitor is in the desired state for this node
key := path.Join(cephKey, monitorAgentName, desiredKey, context.NodeID)
monDesired, err := util.EtcdDirExists(context.EtcdClient, key)
if err != nil {
return err
}
if !monDesired {
return nil
}
a.cluster, err = loadClusterInfo(context.EtcdClient)
if err != nil {
return fmt.Errorf("failed to load cluster info: %+v", err)
@@ -41,13 +50,13 @@ func (a *monAgent) ConfigureLocalService(context *orchestrator.ClusterContext) e
return fmt.Errorf("failed to find monitor during config")
}
// initialize the file system for the monitor
if err := a.makeMonitorFileSystem(monitor.Name); err != nil {
// initialze the file system for the monitor
if err := a.makeMonitorFileSystem(context, monitor.Name); err != nil {
return fmt.Errorf("failed to make monitor filesystems: %+v", err)
}
// run the monitor
err = a.runMonitor(monitor)
err = a.runMonitor(context, monitor)
if err != nil {
return fmt.Errorf("failed to run monitors: %+v", err)
}
@@ -58,19 +67,18 @@ func (a *monAgent) ConfigureLocalService(context *orchestrator.ClusterContext) e
}
func (a *monAgent) DestroyLocalService(context *orchestrator.ClusterContext) error {
a.context = context
return nil
}
// wait for all expected initial monitors to register (report their names/endpoints)
func (a *monAgent) waitForMonitorRegistration(monName string) error {
func (a *monAgent) waitForMonitorRegistration(context *orchestrator.ClusterContext, monName string) error {
key := getMonitorEndpointKey(monName)
retryCount := 0
retryMax := 40
sleepTime := 5
for {
resp, err := a.context.EtcdClient.Get(ctx.Background(), key, nil)
resp, err := context.EtcdClient.Get(ctx.Background(), key, nil)
if err == nil && resp != nil && resp.Node != nil && resp.Node.Value != "" {
log.Printf("monitor %s registered at %s", monName, resp.Node.Value)
break
@@ -88,7 +96,7 @@ func (a *monAgent) waitForMonitorRegistration(monName string) error {
}
// creates and initializes the given monitors file systems
func (a *monAgent) makeMonitorFileSystem(monName string) error {
func (a *monAgent) makeMonitorFileSystem(context *orchestrator.ClusterContext, monName string) error {
// write the keyring to disk
if err := writeMonitorKeyring(monName, a.cluster); err != nil {
return err
@@ -107,7 +115,7 @@ func (a *monAgent) makeMonitorFileSystem(monName string) error {
}
// call mon --mkfs in a child process
err = a.context.ProcMan.Run(
err = context.ProcMan.Run(
"mon",
"--mkfs",
fmt.Sprintf("--cluster=%s", a.cluster.Name),
@@ -123,14 +131,14 @@ func (a *monAgent) makeMonitorFileSystem(monName string) error {
}
// runs the monitor in a child process
func (a *monAgent) runMonitor(monitor *CephMonitorConfig) error {
func (a *monAgent) runMonitor(context *orchestrator.ClusterContext, monitor *CephMonitorConfig) error {
if monitor.Endpoint == "" {
return fmt.Errorf("missing endpoint for mon %s", monitor.Name)
}
// start the monitor daemon in the foreground with the given config
log.Printf("starting monitor %s", monitor.Name)
err := a.context.ProcMan.Start(
err := context.ProcMan.Start(
"mon",
"--foreground",
fmt.Sprintf("--cluster=%v", a.cluster.Name),
+13 -2
View File
@@ -4,6 +4,7 @@ import (
"fmt"
"log"
"os"
"path"
"path/filepath"
"strconv"
"strings"
@@ -12,6 +13,7 @@ import (
"github.com/quantum/castle/pkg/cephd"
"github.com/quantum/clusterd/pkg/orchestrator"
"github.com/quantum/clusterd/pkg/util"
)
const (
@@ -29,13 +31,22 @@ func newOSDAgent(rawDevices string, forceFormat bool) *osdAgent {
return &osdAgent{devices: devices, forceFormat: forceFormat}
}
func (a *osdAgent) GetName() string {
func (a *osdAgent) Name() string {
return osdAgentName
}
func (a *osdAgent) ConfigureLocalService(context *orchestrator.ClusterContext) error {
var err error
// check if the osd is in the desired state for this node
key := path.Join(cephKey, osdAgentName, desiredKey, context.NodeID)
osdDesired, err := util.EtcdDirExists(context.EtcdClient, key)
if err != nil {
return err
}
if !osdDesired {
return nil
}
a.cluster, err = loadClusterInfo(context.EtcdClient)
if err != nil {
return fmt.Errorf("failed to load cluster info: %v", err)
+14 -1
View File
@@ -1,6 +1,12 @@
package castled
import "github.com/quantum/clusterd/pkg/orchestrator"
import (
"log"
"path"
"github.com/quantum/clusterd/pkg/orchestrator"
"github.com/quantum/clusterd/pkg/util"
)
// Load the state of the OSDs from etcd.
// Returns whether the service has updates to be applied.
@@ -19,6 +25,13 @@ func configureOSDs(context *orchestrator.ClusterContext) error {
// Trigger all of the nodes to configure their OSDs
osdNodes := []string{}
for nodeID := range context.Inventory.Nodes {
key := path.Join(cephKey, osdAgentName, desiredKey, nodeID)
err := util.CreateEtcdDir(context.EtcdClient, key)
if err != nil {
log.Printf("failed to trigger osd %s", nodeID)
continue
}
osdNodes = append(osdNodes, nodeID)
}