Skip to content

Commit 37417ae

Browse files
authored
Merge pull request #129 from gman0/backport-127
(Backport #127) sharedmount: create metadata dir only when running sharedmount-runner
2 parents 411bf54 + e353d16 commit 37417ae

File tree

2 files changed

+14
-9
lines changed

2 files changed

+14
-9
lines changed

cmd/singlemount-runner/main.go

+6-2
Original file line numberDiff line numberDiff line change
@@ -47,17 +47,21 @@ func main() {
4747
os.Exit(0)
4848
}
4949

50-
// Initialize and run automount-runner.
50+
// Initialize and run singlemount-runner.
5151

5252
log.Infof("singlemount-runner for CVMFS CSI plugin version %s", cvmfsversion.FullVersion())
5353
log.Infof("Command line arguments %v", os.Args)
5454

55+
if err := singlemount.CreateSingleMountsDir(); err != nil {
56+
log.Fatalf("Failed to create metadata directory in %s: %v", singlemount.SinglemountsDir, err)
57+
}
58+
5559
opts := singlemount.Opts{
5660
Endpoint: *endpoint,
5761
}
5862

5963
if err := singlemount.RunBlocking(opts); err != nil {
60-
log.Fatalf("Failed to run automount-runner: %v", err)
64+
log.Fatalf("Failed to run singlemount-runner: %v", err)
6165
}
6266

6367
os.Exit(0)

internal/cvmfs/singlemount/sharedmount.go

+8-7
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ const (
4141
// bind.json
4242
// config
4343
// mount.json
44-
singlemountsDir = "/var/lib/cvmfs.csi.cern.ch/single"
44+
SinglemountsDir = "/var/lib/cvmfs.csi.cern.ch/single"
4545

4646
// Contains mapping between all mountpoint -> mount ID that are currently
4747
// in use. We need to keep track of these, because CSI's NodeUnstageVolume
@@ -80,7 +80,7 @@ type (
8080
)
8181

8282
func fmtMountSingleBasePath(mountID string) string {
83-
return path.Join(singlemountsDir, mountID)
83+
return path.Join(SinglemountsDir, mountID)
8484
}
8585

8686
func fmtMountpointPath(mountID string) string {
@@ -100,13 +100,14 @@ func fmtConfigPath(mountID string) string {
100100
}
101101

102102
func fmtMountpointsMetadataPath() string {
103-
return path.Join(singlemountsDir, mountpointsFilename)
103+
return path.Join(SinglemountsDir, mountpointsFilename)
104104
}
105105

106-
func init() {
107-
if err := os.MkdirAll(singlemountsDir, 0775); err != nil {
108-
panic(err)
109-
}
106+
// Creates the metadata directory for singlemount-runner.
107+
// Must be called before RunBlocking().
108+
// TOOD: make the path configurable and expose via the chart.
109+
func CreateSingleMountsDir() error {
110+
return os.MkdirAll(SinglemountsDir, 0775)
110111
}
111112

112113
// Makes sure that directory <mountsDir>/<MountSingleRequest.MountId> exists.

0 commit comments

Comments
 (0)