Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: open with RDWR for exclusive file lock #3780

Merged
merged 1 commit into from
May 29, 2020

Conversation

dnwe
Copy link
Contributor

@dnwe dnwe commented May 28, 2020

In order to place an exclusive lock on NFS storage, the file must be
opened for writing.

Fixes #3779

Signed-off-by: Dominic Evans [email protected]

@webvictim
Copy link
Contributor

ok to test

@gravitational-jenkins
Copy link

Can one of the admins verify this patch?

@benarent
Copy link
Contributor

ok to test

@webvictim
Copy link
Contributor

# github.com/gravitational/teleport/lib/events
lib/events/uploader.go:222:26: too many arguments in call to os.Open
	have (string, int, number)
	want (string)
# github.com/gravitational/teleport/lib/events [github.com/gravitational/teleport/lib/events.test]
lib/events/uploader.go:222: too many arguments in call to os.Open
	have (string, int, number)
	want (string)
FAIL	github.com/gravitational/teleport/e/lib/auth [build failed]

@dnwe dnwe force-pushed the use-rdwr-for-exclusive-lock branch from f042602 to 8b90e13 Compare May 28, 2020 18:36
Copy link
Contributor

@fspmarshall fspmarshall left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me, thanks for the PR!

@@ -219,7 +219,7 @@ func (u *Uploader) emitEvent(e UploadEvent) {
}

func (u *Uploader) uploadFile(lockFilePath string, sessionID session.ID) error {
lockFile, err := os.Open(lockFilePath)
lockFile, err := os.OpenFile(lockFilePath, os.O_RDWR, 0640)
Copy link
Contributor

@fspmarshall fspmarshall May 28, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: Cleaner to just pass 0 for permission bits since we aren't using O_CREATE (teleport is full of unused permission bits being passed to OpenFile, so fixing this really isn't necessary).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@fspmarshall good point, fixed 👍

In order to place an exclusive lock on NFS storage, the file must be
opened for writing.

Fixes gravitational#3779

Signed-off-by: Dominic Evans <[email protected]>
@dnwe dnwe force-pushed the use-rdwr-for-exclusive-lock branch from 8b90e13 to af4d437 Compare May 28, 2020 19:43
@russjones russjones merged commit c4ed842 into gravitational:master May 29, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Upload fails if NFS storage is used for /var/lib/teleport
6 participants