Skip to content
This repository has been archived by the owner on Dec 4, 2024. It is now read-only.

Commit

Permalink
pkg/lvm: add flock-based lock around any lvm invocations
Browse files Browse the repository at this point in the history
  • Loading branch information
Gustav Paul committed Aug 8, 2019
1 parent f91368e commit ba76dce
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions pkg/lvm/lock.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package lvm

import (
"github.com/gofrs/flock"
)

var lvmlock *flock.Flock

// SetLockFilePath sets the path to the LOCK file to use for preventing
// concurrent invocations of LVM command-line utilities.
//
// See
// - https://jira.mesosphere.com/browse/DCOS_OSS-5434
// - https://github.com/lvmteam/lvm2/issues/23
func SetLockFilePath(filepath string) {
lvmlock = flock.New(filepath)

This comment has been minimized.

Copy link
@bbannier

bbannier Aug 8, 2019

Does it makes sense to perform some sanity checks here? We could check that we can actually pull this lock (at least now) to exclude cases like filepath=/foo/bar.lock and /foo not existing. I also wonder whether we should require an absolute path to prevent users from creating potentially useless locks in the working directory of just this csilvm instance.

}

0 comments on commit ba76dce

Please sign in to comment.