Skip to content

Commit

Permalink
Support OSD file backing
Browse files Browse the repository at this point in the history
Add support for auto-creating loopback backing for OSDs

Signed-off-by: Peter Sabaini <[email protected]>
  • Loading branch information
sabaini committed Nov 20, 2023
1 parent 765426d commit 45240b6
Show file tree
Hide file tree
Showing 6 changed files with 301 additions and 50 deletions.
42 changes: 42 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,48 @@ jobs:
- name: Test client configurations
run: ~/actionutils.sh check_client_configs

loop-file-tests:
name: Test with loopback file OSDs
runs-on: ubuntu-22.04
needs: build-microceph
steps:
- name: Download snap
uses: actions/download-artifact@v3
with:
name: snaps
path: /home/runner

- name: Checkout code
uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Copy utils
run: cp tests/scripts/actionutils.sh $HOME

- name: Clear FORWARD firewall rules
run: ~/actionutils.sh cleaript

- name: Free disk
run: ~/actionutils.sh free_runner_disk

- name: Install and setup
run: ~/actionutils.sh install_microceph

- name: Add loopback file OSDs
run: |
set -uex
sudo microceph disk add loop,1G,3
~/actionutils.sh wait_for_osds 3
sudo microceph.ceph -s
- name: Enable RGW
run: ~/actionutils.sh enable_rgw

- name: Exercise RGW
run: ~/actionutils.sh testrgw


upgrade-quincy-tests:
name: Test quincy upgrades
runs-on: ubuntu-22.04
Expand Down
19 changes: 16 additions & 3 deletions microceph/api/disks.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"net/http"
"net/url"
"strconv"
"strings"
"sync"

"github.com/canonical/lxd/lxd/response"
Expand Down Expand Up @@ -60,14 +61,26 @@ func cmdDisksPost(s *state.State, r *http.Request) response.Response {
mu.Lock()
defer mu.Unlock()

data = types.DiskParameter{req.Path, req.Encrypt, req.Wipe}
// check if we want OSDs backed by files
if strings.HasPrefix(req.Path, "loop,") {
logger.Debugf("cmdDisksPost: adding loopback OSDs")
err = ceph.AddLoopBackOSDs(s, req.Path)
if err != nil {
return response.SmartError(err)
}
return response.EmptySyncResponse
}

// handle physical devices
data = types.DiskParameter{req.Path, req.Encrypt, req.Wipe, 0}
if req.WALDev != nil {
wal = &types.DiskParameter{*req.WALDev, req.WALEncrypt, req.WALWipe}
wal = &types.DiskParameter{*req.WALDev, req.WALEncrypt, req.WALWipe, 0}
}
if req.DBDev != nil {
db = &types.DiskParameter{*req.DBDev, req.DBEncrypt, req.DBWipe}
db = &types.DiskParameter{*req.DBDev, req.DBEncrypt, req.DBWipe, 0}
}

// add a regular block device
err = ceph.AddOSD(s, data, wal, db)
if err != nil {
return response.SmartError(err)
Expand Down
7 changes: 4 additions & 3 deletions microceph/api/types/disks.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ type Disk struct {
}

type DiskParameter struct {
Path string
Encrypt bool
Wipe bool
Path string
Encrypt bool
Wipe bool
LoopSize uint64
}
Loading

0 comments on commit 45240b6

Please sign in to comment.