flag to allow osds to use all devices
This commit is contained in:
1 parent
eea62192db
commit
a07afb2e10
6 files changed
+34
-17
No files matched your search
@@ -47,6 +47,7 @@ type config struct {
|
||||
cephConfigOverride string
|
||||
clusterInfo mon.ClusterInfo
|
||||
monEndpoints string
|
||||
useAllDevices bool
|
||||
}
|
||||
|
||||
var logLevelRaw string
|
||||
@@ -74,6 +75,8 @@ func init() {
|
||||
rootCmd.PersistentFlags().StringVar(&cfg.dataDir, "data-dir", "/var/lib/rook", "directory for storing configuration")
|
||||
rootCmd.PersistentFlags().StringVar(&logLevelRaw, "log-level", "INFO", "logging level for logging/tracing output (valid values: CRITICAL,ERROR,WARNING,NOTICE,INFO,DEBUG,TRACE)")
|
||||
|
||||
rootCmd.Flags().BoolVar(&cfg.useAllDevices, "use-all-devices", false, "true to use all storage devices, false to require local device selection")
|
||||
|
||||
// load the environment variables
|
||||
flags.SetFlagsFromEnv(rootCmd.Flags(), "ROOK_OPERATOR")
|
||||
flags.SetFlagsFromEnv(rootCmd.PersistentFlags(), "ROOK_OPERATOR")
|
||||
@@ -96,7 +99,7 @@ func startOperator(cmd *cobra.Command, args []string) error {
|
||||
}
|
||||
|
||||
logger.Infof("starting operator. containerVersion=%s", cfg.containerVersion)
|
||||
op := operator.New(k8sutil.Namespace, cephd.New(), clientset, cfg.containerVersion)
|
||||
op := operator.New(k8sutil.Namespace, cephd.New(), clientset, cfg.containerVersion, cfg.useAllDevices)
|
||||
err = op.Run()
|
||||
if err != nil {
|
||||
fmt.Printf("failed to run operator. %+v\n", err)
|
||||
|
||||
+6
-3
@@ -33,10 +33,14 @@ var osdCmd = &cobra.Command{
|
||||
Hidden: true,
|
||||
}
|
||||
var (
|
||||
osdCluster mon.ClusterInfo
|
||||
osdCluster mon.ClusterInfo
|
||||
osdDataDevices string
|
||||
)
|
||||
|
||||
func init() {
|
||||
osdCmd.Flags().StringVar(&osdDataDevices, "data-devices", "", "the device names to use, or \"all\"")
|
||||
flags.SetFlagsFromEnv(monCmd.Flags(), "ROOKD")
|
||||
|
||||
osdCmd.RunE = startOSD
|
||||
}
|
||||
|
||||
@@ -47,13 +51,12 @@ func startOSD(cmd *cobra.Command, args []string) error {
|
||||
|
||||
setLogLevel()
|
||||
|
||||
devices := ""
|
||||
metadataDevice := ""
|
||||
forceFormat := false
|
||||
location := ""
|
||||
bluestoreConfig := partition.BluestoreConfig{DatabaseSizeMB: 512} // FIX
|
||||
clusterInfo.Monitors = mon.ParseMonEndpoints(cfg.monEndpoints)
|
||||
agent := osd.NewAgent(cephd.New(), devices, metadataDevice, forceFormat, location, bluestoreConfig, &clusterInfo)
|
||||
agent := osd.NewAgent(cephd.New(), osdDataDevices, metadataDevice, forceFormat, location, bluestoreConfig, &clusterInfo)
|
||||
context := clusterd.NewDaemonContext(cfg.dataDir, cfg.cephConfigOverride, cfg.logLevel)
|
||||
|
||||
return osd.Run(context, agent)
|
||||
|
||||
@@ -61,7 +61,7 @@ func Run(dcontext *clusterd.DaemonContext, agent *OsdAgent) error {
|
||||
}
|
||||
|
||||
// initialize the desired osds
|
||||
devices, err := getAvailableDevices(dcontext, hardware.Disks)
|
||||
devices, err := getAvailableDevices(dcontext, hardware.Disks, agent.devices)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to get available devices. %+v", err)
|
||||
}
|
||||
@@ -93,7 +93,7 @@ func Run(dcontext *clusterd.DaemonContext, agent *OsdAgent) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func getAvailableDevices(context *clusterd.DaemonContext, devices []*inventory.LocalDisk) (*DeviceOsdMapping, error) {
|
||||
func getAvailableDevices(context *clusterd.DaemonContext, devices []*inventory.LocalDisk, desiredDevices string) (*DeviceOsdMapping, error) {
|
||||
available := &DeviceOsdMapping{Entries: map[string]*DeviceOsdIDEntry{}}
|
||||
for _, device := range devices {
|
||||
if device.Type == sys.PartType {
|
||||
@@ -104,8 +104,11 @@ func getAvailableDevices(context *clusterd.DaemonContext, devices []*inventory.L
|
||||
return nil, fmt.Errorf("failed to get device %s info. %+v", device.Name, err)
|
||||
}
|
||||
if fs == "" && ownPartitions {
|
||||
logger.Infof("skipping device %s until the admin specifies it can be used by an osd", device.Name)
|
||||
//available.Entries[device.Name] = &DeviceOsdIDEntry{Data: (for existing osds get their ids) unassignedOSDID}
|
||||
if desiredDevices == "all" {
|
||||
available.Entries[device.Name] = &DeviceOsdIDEntry{Data: unassignedOSDID}
|
||||
} else {
|
||||
logger.Infof("skipping device %s until the admin specifies it can be used by an osd", device.Name)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -36,14 +36,16 @@ type Operator struct {
|
||||
clientset *kubernetes.Clientset
|
||||
waitCluster sync.WaitGroup
|
||||
factory client.ConnectionFactory
|
||||
useAllDevices bool
|
||||
}
|
||||
|
||||
func New(namespace string, factory client.ConnectionFactory, clientset *kubernetes.Clientset, containerVersion string) *Operator {
|
||||
func New(namespace string, factory client.ConnectionFactory, clientset *kubernetes.Clientset, containerVersion string, useAllDevices bool) *Operator {
|
||||
return &Operator{
|
||||
Namespace: namespace,
|
||||
factory: factory,
|
||||
clientset: clientset,
|
||||
containerVersion: containerVersion,
|
||||
useAllDevices: useAllDevices,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -63,7 +65,7 @@ func (o *Operator) Run() error {
|
||||
}
|
||||
|
||||
// Start the OSDs
|
||||
osds := osd.New(o.Namespace, o.containerVersion)
|
||||
osds := osd.New(o.Namespace, o.containerVersion, o.useAllDevices)
|
||||
err = osds.Start(o.clientset, cluster)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to start the osds. %+v", err)
|
||||
|
||||
@@ -18,5 +18,5 @@ package operator
|
||||
import "testing"
|
||||
|
||||
func TestOperator(t *testing.T) {
|
||||
New("foo", nil, nil, "version")
|
||||
New("foo", nil, nil, "version", true)
|
||||
}
|
||||
+12
-6
@@ -31,15 +31,17 @@ const (
|
||||
)
|
||||
|
||||
type Cluster struct {
|
||||
Namespace string
|
||||
Keyring string
|
||||
Version string
|
||||
Namespace string
|
||||
Keyring string
|
||||
Version string
|
||||
useAllDevices bool
|
||||
}
|
||||
|
||||
func New(namespace, version string) *Cluster {
|
||||
func New(namespace, version string, useAllDevices bool) *Cluster {
|
||||
return &Cluster{
|
||||
Namespace: namespace,
|
||||
Version: version,
|
||||
Namespace: namespace,
|
||||
Version: version,
|
||||
useAllDevices: useAllDevices,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -97,6 +99,10 @@ func (c *Cluster) osdContainer(cluster *mon.ClusterInfo) v1.Container {
|
||||
|
||||
command := fmt.Sprintf("/usr/bin/rookd osd --data-dir=%s --mon-endpoints=%s --cluster-name=%s ",
|
||||
k8sutil.DataDir, mon.FlattenMonEndpoints(cluster.Monitors), cluster.Name)
|
||||
if c.useAllDevices {
|
||||
command += fmt.Sprintf("--data-devices=all ")
|
||||
}
|
||||
|
||||
privileged := true
|
||||
return v1.Container{
|
||||
// TODO: fix "sleep 5".
|
||||
|
||||
Reference in new issue
Block a user