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

Commit 90b482f

Browse files
authored
Merge pull request #41 from RSE-Cambridge/rsync-fixes
Rsync fixes
2 parents 663f065 + 8e1f08c commit 90b482f

7 files changed

Lines changed: 58 additions & 32 deletions

File tree

dac-ansible/roles/data-acc/tasks/main.yml

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,5 @@
11
---
2-
- name: check for installation of data-acc
3-
become: yes
4-
stat:
5-
path: '{{data_acc_install_dir}}/{{data_acc_name}}/bin'
6-
changed_when: false
7-
register: data_acc_binary_dir
8-
9-
- when: not data_acc_binary_dir.stat.exists
10-
block:
2+
- block:
113
- name: download data_acc
124
become: yes
135
become_user: root
@@ -33,7 +25,6 @@
3325
remote_src: yes
3426
src: /tmp/{{data_acc_tgz}}
3527
dest: '{{data_acc_install_dir}}/{{data_acc_name}}'
36-
creates: '{{data_acc_install_dir}}/{{data_acc_name}}/bin'
3728
always:
3829
- name: delete archive
3930
become: yes

docker-slurm/burst_buffer.conf

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
AllowUsers=root,slurm
21
Flags=EnablePersistent,PrivateData
32

43
StageInTimeout=3600

internal/pkg/dacctl/persistent.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,8 +117,6 @@ func CreateVolumesAndJobs(volReg registry.VolumeRegistry, poolRegistry registry.
117117
JobVolume: volume.Name, // Even though its a persistent buffer, we add it here to ensure we delete buffer
118118
Paths: make(map[string]string),
119119
}
120-
job.Paths[fmt.Sprintf("DW_PERSISTENT_STRIPED_%s", volume.Name)] = fmt.Sprintf(
121-
"/mnt/dac/job/%s/multijob/%s", job.Name, volume.Name)
122120

123121
err = volReg.AddJob(job)
124122
if err != nil {

internal/pkg/pfsprovider/ansible/copy.go

Lines changed: 34 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,36 @@ import (
44
"fmt"
55
"github.com/RSE-Cambridge/data-acc/internal/pkg/registry"
66
"log"
7+
"path"
8+
"strings"
79
)
810

911
func processDataCopy(volume registry.Volume, request registry.DataCopyRequest) error {
1012
cmd, err := generateDataCopyCmd(volume, request)
1113
if err != nil {
1214
return err
1315
}
16+
if cmd == "" {
17+
log.Println("No files to copy for:", volume.Name)
18+
return nil
19+
}
20+
21+
log.Printf("Doing copy: %s", cmd)
1422

15-
log.Printf("FAKE copy: %s", cmd)
16-
return nil
23+
// Make sure global dir is setup correctly
24+
// TODO: share code with mount better
25+
// TODO: Probably should all get setup in fs-ansible really!!
26+
mountDir := fmt.Sprintf("/mnt/lustre/%s", volume.UUID)
27+
sharedDir := path.Join(mountDir, "/global")
28+
if err := mkdir("localhost", sharedDir); err != nil {
29+
return err
30+
}
31+
if err := fixUpOwnership("localhost", volume.Owner, volume.Group, sharedDir); err != nil {
32+
return err
33+
}
34+
35+
// Do the copy
36+
return runner.Execute("localhost", cmd)
1737
}
1838

1939
func generateDataCopyCmd(volume registry.Volume, request registry.DataCopyRequest) (string, error) {
@@ -22,24 +42,31 @@ func generateDataCopyCmd(volume registry.Volume, request registry.DataCopyReques
2242
return "", err
2343
}
2444

25-
cmd := fmt.Sprintf("sudo su `getent passwd %d | cut -d: -f1` %s", volume.Owner, rsync)
45+
cmd := fmt.Sprintf("sudo -g '#%d' -u '#%d' %s", volume.Group, volume.Owner, rsync)
46+
dacHostBufferPath := fmt.Sprintf("/mnt/lustre/%s/global", volume.UUID)
47+
cmd = fmt.Sprintf("bash -c \"export DW_JOB_STRIPED='%s' && %s\"", dacHostBufferPath, cmd)
2648
return cmd, nil
2749
}
2850

2951
func generateRsyncCmd(volume registry.Volume, request registry.DataCopyRequest) (string, error) {
3052
if request.Source == "" && request.Destination == "" {
31-
log.Println("No files to copy for:", volume.Name)
3253
return "", nil
3354
}
3455

3556
var flags string
3657
if request.SourceType == registry.Directory {
37-
flags = "-r "
58+
flags = "-r -ospgu --stats"
3859
} else if request.SourceType == registry.File {
39-
flags = ""
60+
flags = "-ospgu --stats"
4061
} else {
4162
return "", fmt.Errorf("unsupported source type %s for volume: %s", request.SourceType, volume.Name)
4263
}
4364

44-
return fmt.Sprintf("rsync %s%s %s", flags, request.Source, request.Destination), nil
65+
return fmt.Sprintf("rsync %s %s %s", flags,
66+
escapePath(request.Source),
67+
escapePath(request.Destination)), nil
68+
}
69+
70+
func escapePath(path string) string {
71+
return strings.Replace(path, "$DW_JOB_STRIPED", "\\$DW_JOB_STRIPED", 1)
4572
}

internal/pkg/pfsprovider/ansible/copy_test.go

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ func Test_GenerateDataCopy(t *testing.T) {
1010
testVolume := registry.Volume{
1111
Name: registry.VolumeName("asdf"),
1212
Owner: 1001,
13+
Group: 1002,
14+
UUID: "fsuuid",
1315
}
1416
request := registry.DataCopyRequest{}
1517

@@ -18,11 +20,11 @@ func Test_GenerateDataCopy(t *testing.T) {
1820
assert.Empty(t, cmd)
1921

2022
request.SourceType = registry.File
21-
request.Source = "source"
23+
request.Source = "$DW_JOB_STRIPED/source"
2224
request.Destination = "dest"
2325
cmd, err = generateDataCopyCmd(testVolume, request)
2426
assert.Nil(t, err)
25-
assert.Equal(t, "sudo su `getent passwd 1001 | cut -d: -f1` rsync source dest", cmd)
27+
assert.Equal(t, "bash -c \"export DW_JOB_STRIPED='/mnt/lustre/fsuuid/global' && sudo -g '#1002' -u '#1001' rsync -ospgu --stats \\$DW_JOB_STRIPED/source dest\"", cmd)
2628

2729
request.SourceType = registry.List
2830
request.Source = "list_filename"
@@ -47,14 +49,14 @@ func Test_GenerateRsyncCmd(t *testing.T) {
4749
request.Destination = "dest"
4850
cmd, err = generateRsyncCmd(testVolume, request)
4951
assert.Nil(t, err)
50-
assert.Equal(t, "rsync source dest", cmd)
52+
assert.Equal(t, "rsync -ospgu --stats source dest", cmd)
5153

5254
request.SourceType = registry.Directory
5355
request.Source = "source"
5456
request.Destination = "dest"
5557
cmd, err = generateRsyncCmd(testVolume, request)
5658
assert.Nil(t, err)
57-
assert.Equal(t, "rsync -r source dest", cmd)
59+
assert.Equal(t, "rsync -r -ospgu --stats source dest", cmd)
5860

5961
request.SourceType = registry.List
6062
request.Source = "list_filename"

tools/dac-reset.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ set +a
77
/usr/local/bin/etcdctl --key /etc/data-acc/pki/`hostname`.dac.hpc.cam.ac.uk-key.pem --cert /etc/data-acc/pki/`hostname`.dac.hpc.cam.ac.uk.pem --cacert /etc/data-acc/pki/ca.pem del --prefix ''
88

99
# Kill all lustre filesystems
10-
ssh slurm-cpu1 sudo umount -atl lustre
11-
ssh slurm-cpu2 sudo umount -atl lustre
10+
#ssh slurm-cpu1 sudo umount -atl lustre
11+
#ssh slurm-cpu2 sudo umount -atl lustre
1212
ssh dac1 sudo umount -at lustre
1313
ssh dac2 sudo umount -at lustre
1414
ssh dac3 sudo umount -at lustre

tools/slurm-test.sh

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,17 @@ echo "#!/bin/bash
1212
#DW jobdw capacity=2TB access_mode=striped,private type=scratch
1313
#DW persistentdw name=mytestbuffer
1414
#DW swap 5MB
15-
#DW stage_in source=/global/cscratch1/filename1 destination=\$DW_JOB_STRIPED/filename1 type=file
16-
#DW stage_out source=\$DW_JOB_STRIPED/outdir destination=/global/scratch1/outdir type=directory
15+
#DW stage_in source=/usr/local/bin/dacd destination=\$DW_JOB_STRIPED/filename1 type=file
16+
#DW stage_out source=\$DW_JOB_STRIPED/outdir destination=/tmp type=directory
17+
1718
env
1819
df -h
1920
swapon
21+
22+
mkdir \$DW_JOB_STRIPED/outdir
23+
df -h > \$DW_JOB_STRIPED/outdir/dfoutput
24+
ls -al \$DW_JOB_STRIPED > \$DW_JOB_STRIPED/outdir/lsoutput
25+
2026
echo \$HOSTNAME
2127
" > use-persistent.sh
2228

@@ -45,11 +51,14 @@ scontrol show burstbuffer
4551
squeue
4652

4753
echo "***Use persistent buffer***"
54+
adduser centos
4855
cat use-persistent.sh
49-
su slurm -c 'sbatch use-persistent.sh'
50-
su slurm -c 'sbatch use-persistent.sh'
51-
su slurm -c 'sbatch use-persistent.sh'
52-
su slurm -c 'sbatch use-persistent.sh'
56+
su centos -c 'sbatch use-persistent.sh'
57+
su centos -c 'sbatch use-persistent.sh'
58+
su centos -c 'sbatch use-persistent.sh'
59+
su centos -c 'sbatch use-persistent.sh'
60+
su centos -c 'sbatch --array=1-10 test-persistent.sh'
61+
5362
squeue
5463

5564
sleep $SLEEP_INTERVAL

0 commit comments

Comments
 (0)