Skip to content

Commit

Permalink
Sequence startup and rewrite config
Browse files Browse the repository at this point in the history
Make ceph services wait for microcephd and force a config rewrite on
startup. This should help avoid config inconsistencies and races.

Signed-off-by: Peter Sabaini <[email protected]>
  • Loading branch information
sabaini committed Jan 28, 2025
1 parent 2e22e93 commit b08fc01
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 2 deletions.
7 changes: 5 additions & 2 deletions microceph/ceph/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,8 @@ func PostRefresh() error {

// Start is run on daemon startup.
func Start(ctx context.Context, s interfaces.StateInterface) error {
// flag: are we on the first run?
first := true
// Start background loop to refresh the config every minute if needed.
go func() {
oldMonitors := []string{}
Expand Down Expand Up @@ -182,8 +184,8 @@ func Start(ctx context.Context, s interfaces.StateInterface) error {
continue
}

// Compare to the previous list.
if reflect.DeepEqual(oldMonitors, monitors) {
// Check if we need to update
if !first || reflect.DeepEqual(oldMonitors, monitors) {
logger.Debugf("start: monitors unchanged, sleeping: %v", monitors)
time.Sleep(time.Minute)
continue
Expand All @@ -196,6 +198,7 @@ func Start(ctx context.Context, s interfaces.StateInterface) error {
continue
}
logger.Debug("start: updated config, sleeping")
first = false // for subsequent runs
oldMonitors = monitors
time.Sleep(time.Minute)
}
Expand Down
12 changes: 12 additions & 0 deletions snap/snapcraft.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -61,13 +61,17 @@ apps:
command: commands/mds.start
daemon: simple
install-mode: disable
after:
- daemon
plugs:
- network
- network-bind
mon:
command: commands/mon.start
daemon: simple
install-mode: disable
after:
- daemon
plugs:
- hardware-observe
- network
Expand All @@ -76,6 +80,8 @@ apps:
command: commands/mgr.start
daemon: simple
install-mode: disable
after:
- daemon
plugs:
- network
- network-bind
Expand All @@ -86,6 +92,8 @@ apps:
install-mode: disable
stop-mode: sigterm-all
stop-timeout: 5m
after:
- daemon
plugs:
- block-devices
- dm-crypt
Expand All @@ -98,6 +106,8 @@ apps:
command: commands/rgw.start
daemon: simple
install-mode: disable
after:
- daemon
plugs:
- hardware-observe
- network
Expand All @@ -107,6 +117,8 @@ apps:
command: commands/rbd-mirror.start
daemon: simple
install-mode: disable
after:
- daemon
plugs:
- network
- network-bind
Expand Down
1 change: 1 addition & 0 deletions snapcraft/commands/common
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ wait_for_config() {
local max_attempts=300
local attempt=0

sleep 1 # give microcephd startup a headstart
while [ $attempt -lt $max_attempts ]; do
if [ -f "${confpath}" ]; then
if grep -q "${search_str}" "${confpath}"; then
Expand Down

0 comments on commit b08fc01

Please sign in to comment.