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

Commit

Permalink
Merge pull request #101 from RSE-Cambridge/persistent-mount
Browse files Browse the repository at this point in the history
Ensure filesystem mount gets correct persistent mount path
  • Loading branch information
JohnGarbutt authored Sep 10, 2019
2 parents 710960f + 40a618a commit 346bf8b
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 8 deletions.
2 changes: 1 addition & 1 deletion internal/pkg/dacctl/workflow_impl/session.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ func (s sessionFacade) CreateSession(session datamodel.Session) error {
if err != nil {
return session, err
}
if session.ActualSizeBytes == 0 {
if session.ActualSizeBytes == 0 && len(session.MultiJobAttachments) == 0 {
// Skip creating an empty filesystem
return datamodel.Session{}, nil
}
Expand Down
5 changes: 3 additions & 2 deletions internal/pkg/filesystem_impl/mount.go
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ func mountRemoteFilesystem(fsType FSType, hostname string, lnetSuffix string, mg
func mountLustre(hostname string, lnetSuffix string, mgtHost string, fsname string, directory string) error {
// We assume modprobe -v lustre is already done
// First check if we are mounted already
if err := runner.Execute(hostname, fmt.Sprintf("grep %s /etc/mtab", directory)); err != nil {
if err := runner.Execute(hostname, fmt.Sprintf("grep %s /etc/mtab", directory)); err != nil || conf.SkipAnsible {
if err := runner.Execute(hostname, fmt.Sprintf(
"mount -t lustre -o flock,nodev,nosuid %s%s:/%s %s",
mgtHost, lnetSuffix, fsname, directory)); err != nil {
Expand Down Expand Up @@ -282,7 +282,8 @@ func (*run) Execute(hostname string, cmdStr string) error {
log.Println(string(output))
return nil
} else {
log.Println("Error in remove ssh run:", string(output))
log.Printf("Error in remote ssh run: '%s' error: %s\n", cmdStr, err.Error())
log.Println(string(output))
return err
}
}
Expand Down
15 changes: 10 additions & 5 deletions internal/pkg/filesystem_impl/mount_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ func (f *fakeRunner) Execute(hostname string, cmdStr string) error {
if cmdStr == "grep /mnt/dac/job1_job /etc/mtab" {
return errors.New("trigger mount")
}
if cmdStr == "grep /mnt/dac/job1_persistent_asdf /etc/mtab" {
return errors.New("trigger mount")
}
return f.err
}

Expand Down Expand Up @@ -183,7 +186,7 @@ func Test_Umount_multi(t *testing.T) {
fake := &fakeRunner{}
runner = fake

sessionName := datamodel.SessionName("asdf")
sessionName := datamodel.SessionName("asdf2")
internalName := "uuidasdf"
primaryBrickHost := datamodel.BrickHostName("host1")
attachment := datamodel.AttachmentSession{
Expand All @@ -200,9 +203,9 @@ func Test_Umount_multi(t *testing.T) {
assert.Equal(t, 3, fake.calls)

assert.Equal(t, "client1", fake.hostnames[0])
assert.Equal(t, "grep /mnt/dac/job1_persistent_asdf /etc/mtab", fake.cmdStrs[0])
assert.Equal(t, "umount /mnt/dac/job1_persistent_asdf", fake.cmdStrs[1])
assert.Equal(t, "rm -df /mnt/dac/job1_persistent_asdf", fake.cmdStrs[2])
assert.Equal(t, "grep /mnt/dac/job1_persistent_asdf2 /etc/mtab", fake.cmdStrs[0])
assert.Equal(t, "umount /mnt/dac/job1_persistent_asdf2", fake.cmdStrs[1])
assert.Equal(t, "rm -df /mnt/dac/job1_persistent_asdf2", fake.cmdStrs[2])
}

func Test_Mount_multi(t *testing.T) {
Expand All @@ -227,10 +230,12 @@ func Test_Mount_multi(t *testing.T) {
owner, group, false)

assert.Nil(t, err)
assert.Equal(t, 2, fake.calls)
assert.Equal(t, 3, fake.calls)

assert.Equal(t, "client1", fake.hostnames[0])
assert.Equal(t, "mkdir -p /mnt/dac/job1_persistent_asdf", fake.cmdStrs[0])
assert.Equal(t, "client1", fake.hostnames[1])
assert.Equal(t, "grep /mnt/dac/job1_persistent_asdf /etc/mtab", fake.cmdStrs[1])
assert.Equal(t, "client1", fake.hostnames[2])
assert.Equal(t, "mount -t lustre -o flock,nodev,nosuid host1:/uuidasdf /mnt/dac/job1_persistent_asdf", fake.cmdStrs[2])
}

0 comments on commit 346bf8b

Please sign in to comment.