Skip to content

Commit a24f3de

Browse files
Added ceph-exporter to service placement interface
Signed-off-by: utkarsh bhatt <utkarsh.bhatt@canonical.com>
1 parent 76028b8 commit a24f3de

File tree

5 files changed

+54
-9
lines changed

5 files changed

+54
-9
lines changed

microceph/ceph/ceph_exporter.go

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
package ceph
2+
3+
import (
4+
"fmt"
5+
"path/filepath"
6+
7+
"github.com/canonical/lxd/shared/logger"
8+
)
9+
10+
func bootstrapCephExporter(hostname string, path string) error {
11+
args := []string{
12+
"auth",
13+
"get-or-create",
14+
fmt.Sprintf("client.ceph-exporter.%s", hostname),
15+
"mon", "profile ceph-exporter",
16+
"-o", filepath.Join(path, "keyring"),
17+
}
18+
19+
_, err := cephRun(args...)
20+
if err != nil {
21+
logger.Errorf("failed to bootstrap ceph-exporter daemon: %s", err.Error())
22+
return err
23+
}
24+
25+
return nil
26+
}

microceph/ceph/services_placement.go

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,12 @@ type PlacementIntf interface {
2626

2727
func GetServicePlacementTable() map[string](PlacementIntf) {
2828
return map[string](PlacementIntf){
29-
"mon": &MonServicePlacement{"mon"},
30-
"mgr": &GenericServicePlacement{"mgr"},
31-
"mds": &GenericServicePlacement{"mds"},
32-
"rgw": &RgwServicePlacement{},
33-
"rbd-mirror": &ClientServicePlacement{"rbd-mirror"},
29+
"mon": &MonServicePlacement{"mon"},
30+
"mgr": &GenericServicePlacement{"mgr"},
31+
"mds": &GenericServicePlacement{"mds"},
32+
"rgw": &RgwServicePlacement{},
33+
"rbd-mirror": &ClientServicePlacement{"rbd-mirror"},
34+
"ceph-exporter": &ClientServicePlacement{"ceph-exporter"},
3435
}
3536
}
3637

microceph/ceph/services_placement_generic.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,11 @@ import (
1818
// Maps the addService function to respective services.
1919
func GetServiceKeyringTable() map[string](func(string, string) error) {
2020
return map[string](func(string, string) error){
21-
"mon": joinMon,
22-
"mgr": bootstrapMgr,
23-
"mds": bootstrapMds,
24-
"rbd-mirror": bootstrapRbdMirror,
21+
"mon": joinMon,
22+
"mgr": bootstrapMgr,
23+
"mds": bootstrapMds,
24+
"rbd-mirror": bootstrapRbdMirror,
25+
"ceph-exporter": bootstrapCephExporter,
2526
// Add more services here, for using the generic Interface implementation.
2627
}
2728
}

snap/snapcraft.yaml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,16 @@ apps:
137137
- network
138138
- network-bind
139139
- process-control
140+
"ceph-exporter":
141+
command: commands/ceph-exporter.start
142+
daemon: simple
143+
install-mode: disable
144+
after:
145+
- daemon
146+
plugs:
147+
- network
148+
- network-bind
149+
- process-control
140150
# Commands
141151
ceph:
142152
command: commands/ceph
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#!/bin/bash
2+
3+
. "${SNAP}/commands/common"
4+
5+
limits
6+
7+
exec ceph-exporter -f --cluster ceph --id "ceph-exporter.$(hostname)"

0 commit comments

Comments
 (0)