Skip to content
This repository was archived by the owner on Mar 30, 2023. It is now read-only.

Commit 50a6896

Browse files
authored
Merge pull request #59 from RSE-Cambridge/lvm
Lvm debug testing
2 parents 51b77d2 + dba614f commit 50a6896

3 files changed

Lines changed: 21 additions & 11 deletions

File tree

internal/pkg/pfsprovider/ansible/ansible.go

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import (
1111
"os/exec"
1212
"path"
1313
"path/filepath"
14+
"strconv"
1415
"strings"
1516
"time"
1617
)
@@ -35,14 +36,19 @@ type Wrapper struct {
3536
}
3637

3738
var DefaultHostGroup = "dac-prod"
38-
var MaxMDTs uint = 24
39+
var DefaultMaxMDTs uint = 24
3940

4041
func getInventory(fsType FSType, volume registry.Volume, brickAllocations []registry.BrickAllocation) string {
4142
// NOTE: only used by lustre
4243
mgsDevice := os.Getenv("DAC_MGS_DEV")
4344
if mgsDevice == "" {
4445
mgsDevice = "sdb"
4546
}
47+
maxMDTs := DefaultMaxMDTs
48+
maxMDTsConf, err := strconv.ParseUint(os.Getenv("DAC_MAX_MDT_COUNT"), 10, 32)
49+
if err == nil && maxMDTsConf > 0 {
50+
maxMDTs = uint(maxMDTsConf)
51+
}
4652

4753
allocationsByHost := make(map[string][]registry.BrickAllocation)
4854
for _, allocation := range brickAllocations {
@@ -55,7 +61,7 @@ func getInventory(fsType FSType, volume registry.Volume, brickAllocations []regi
5561
mdts := make(map[string]int)
5662
osts := make(map[string]int)
5763
for _, allocation := range allocations {
58-
if allocation.AllocatedIndex < MaxMDTs {
64+
if allocation.AllocatedIndex < maxMDTs {
5965
mdts[allocation.Device] = int(allocation.AllocatedIndex)
6066
}
6167
osts[allocation.Device] = int(allocation.AllocatedIndex)
@@ -84,7 +90,7 @@ func getInventory(fsType FSType, volume registry.Volume, brickAllocations []regi
8490
"mgsnode": mgsnode,
8591
"client_port": fmt.Sprintf("%d", volume.ClientPort),
8692
"lnet_suffix": getLnetSuffix(),
87-
"mdt_size": fmt.Sprintf("%dg", getMdtSize()),
93+
"mdt_size": fmt.Sprintf("%dm", getMdtSizeMB()),
8894
},
8995
Hosts: hosts,
9096
}

internal/pkg/pfsprovider/ansible/ansible_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ func TestPlugin_GetInventory(t *testing.T) {
3939
vars:
4040
abcdefgh_client_port: "10002"
4141
lnet_suffix: ""
42-
abcdefgh_mdt_size: 20g
42+
abcdefgh_mdt_size: 20480m
4343
abcdefgh_mgsnode: dac1
4444
`
4545
assert.Equal(t, expected, result)
@@ -66,7 +66,7 @@ func TestPlugin_GetInventory_withNoOstOnOneHost(t *testing.T) {
6666
vars:
6767
abcdefgh_client_port: "10002"
6868
lnet_suffix: ""
69-
abcdefgh_mdt_size: 20g
69+
abcdefgh_mdt_size: 20480m
7070
abcdefgh_mgsnode: dac1
7171
`
7272
assert.Equal(t, expected, result)
@@ -205,7 +205,7 @@ func TestPlugin_GetInventory_MaxMDT(t *testing.T) {
205205
vars:
206206
abcdefgh_client_port: "10002"
207207
lnet_suffix: ""
208-
abcdefgh_mdt_size: 20g
208+
abcdefgh_mdt_size: 20480m
209209
abcdefgh_mgsnode: dac1
210210
`
211211
assert.Equal(t, expected, result)

internal/pkg/pfsprovider/ansible/mount.go

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,16 @@ func getLnetSuffix() string {
2323
return os.Getenv("DAC_LNET_SUFFIX")
2424
}
2525

26-
func getMdtSize() uint {
27-
mdtSize, err := strconv.ParseUint(os.Getenv("DAC_MDT_SIZE_GB"), 10, 32)
28-
if err != nil || mdtSize == 0 {
29-
mdtSize = 20
26+
func getMdtSizeMB() uint {
27+
mdtSizeGB, err := strconv.ParseUint(os.Getenv("DAC_MDT_SIZE_GB"), 10, 32)
28+
if err == nil && mdtSizeGB > 0 {
29+
return uint(mdtSizeGB * 1024)
3030
}
31-
return uint(mdtSize)
31+
mdtSizeMB, err := strconv.ParseUint(os.Getenv("DAC_MDT_SIZE_MB"), 10, 32)
32+
if err == nil && mdtSizeMB > 0 {
33+
return uint(mdtSizeMB)
34+
}
35+
return uint(20 * 1024)
3236
}
3337

3438
func mount(fsType FSType, volume registry.Volume, brickAllocations []registry.BrickAllocation, attachments []registry.Attachment) error {

0 commit comments

Comments
 (0)