Skip to content

Commit

Permalink
Merge pull request #129 from gman0/backport-127
Browse files Browse the repository at this point in the history
(Backport #127) sharedmount: create metadata dir only when running sharedmount-runner
  • Loading branch information
gman0 authored Oct 6, 2023
2 parents 411bf54 + e353d16 commit 37417ae
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 9 deletions.
8 changes: 6 additions & 2 deletions cmd/singlemount-runner/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,17 +47,21 @@ func main() {
os.Exit(0)
}

// Initialize and run automount-runner.
// Initialize and run singlemount-runner.

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

if err := singlemount.CreateSingleMountsDir(); err != nil {
log.Fatalf("Failed to create metadata directory in %s: %v", singlemount.SinglemountsDir, err)
}

opts := singlemount.Opts{
Endpoint: *endpoint,
}

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

os.Exit(0)
Expand Down
15 changes: 8 additions & 7 deletions internal/cvmfs/singlemount/sharedmount.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ const (
// bind.json
// config
// mount.json
singlemountsDir = "/var/lib/cvmfs.csi.cern.ch/single"
SinglemountsDir = "/var/lib/cvmfs.csi.cern.ch/single"

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

func fmtMountSingleBasePath(mountID string) string {
return path.Join(singlemountsDir, mountID)
return path.Join(SinglemountsDir, mountID)
}

func fmtMountpointPath(mountID string) string {
Expand All @@ -100,13 +100,14 @@ func fmtConfigPath(mountID string) string {
}

func fmtMountpointsMetadataPath() string {
return path.Join(singlemountsDir, mountpointsFilename)
return path.Join(SinglemountsDir, mountpointsFilename)
}

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

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

0 comments on commit 37417ae

Please sign in to comment.