{"action":"created","issue":{"url":"https://api.github.com/repos/scality/scality-manila-utils/issues/3","labels_url":"https://api.github.com/repos/scality/scality-manila-utils/issues/3/labels{/name}","comments_url":"https://api.github.com/repos/scality/scality-manila-utils/issues/3/comments","events_url":"https://api.github.com/repos/scality/scality-manila-utils/issues/3/events","html_url":"https://github.com/scality/scality-manila-utils/issues/3","id":93751144,"number":3,"title":"Add `exports` locking","user":{"login":"NicolasT","id":102605,"avatar_url":"https://avatars.githubusercontent.com/u/102605?v=3","gravatar_id":"","url":"https://api.github.com/users/NicolasT","html_url":"https://github.com/NicolasT","followers_url":"https://api.github.com/users/NicolasT/followers","following_url":"https://api.github.com/users/NicolasT/following{/other_user}","gists_url":"https://api.github.com/users/NicolasT/gists{/gist_id}","starred_url":"https://api.github.com/users/NicolasT/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/NicolasT/subscriptions","organizations_url":"https://api.github.com/users/NicolasT/orgs","repos_url":"https://api.github.com/users/NicolasT/repos","events_url":"https://api.github.com/users/NicolasT/events{/privacy}","received_events_url":"https://api.github.com/users/NicolasT/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2015-07-08T09:55:23Z","updated_at":"2015-08-03T16:10:56Z","closed_at":null,"body":"When multiple `manila-share` services try to perform actions on `/etc/exports` concurrently, they could overwrite/drop other changes. To work around this, the CLI tool should lock the resource.\r\n\r\nProposed scheme:\r\n\r\n1. Open `/etc/exports` for reading as `fdr`\r\n2. Get an advisory read lock on `fdr`\r\n3. Once lock has been granted, `stat` `/etc/exports` and `fstat` `fdr`, ensure they're the same file. If not, close resources and restart\r\n4. Read/parse file\r\n5. Unlock `fdr` (but keep open)\r\n6. When ready to write, open `/etc/exports` for writing as `fdw`\r\n7. Get an advisory write lock on `fdw`\r\n8. Once the write lock has been granted, `fstat` `fdr` and `fdw` and `stat` `/etc/exports`. If they're not all the same file, restart the whole operation.\r\n9. Write to temporary file, do `rename` and `fsync` dance\r\n10. Close `fdr` and `fdw` which now point to an unlinked file (this also releases locks implicitly)"},"comment":{"url":"https://api.github.com/repos/scality/scality-manila-utils/issues/comments/127292395","html_url":"https://github.com/scality/scality-manila-utils/issues/3#issuecomment-127292395","issue_url":"https://api.github.com/repos/scality/scality-manila-utils/issues/3","id":127292395,"user":{"login":"JordanP","id":221981,"avatar_url":"https://avatars.githubusercontent.com/u/221981?v=3","gravatar_id":"","url":"https://api.github.com/users/JordanP","html_url":"https://github.com/JordanP","followers_url":"https://api.github.com/users/JordanP/followers","following_url":"https://api.github.com/users/JordanP/following{/other_user}","gists_url":"https://api.github.com/users/JordanP/gists{/gist_id}","starred_url":"https://api.github.com/users/JordanP/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/JordanP/subscriptions","organizations_url":"https://api.github.com/users/JordanP/orgs","repos_url":"https://api.github.com/users/JordanP/repos","events_url":"https://api.github.com/users/JordanP/events{/privacy}","received_events_url":"https://api.github.com/users/JordanP/received_events","type":"User","site_admin":false},"created_at":"2015-08-03T16:10:56Z","updated_at":"2015-08-03T16:10:56Z","body":"/me goes grab some popcorn...."}}