{"action":"created","issue":{"url":"https://api.github.com/repos/dcos/dcos/issues/2730","repository_url":"https://api.github.com/repos/dcos/dcos","labels_url":"https://api.github.com/repos/dcos/dcos/issues/2730/labels{/name}","comments_url":"https://api.github.com/repos/dcos/dcos/issues/2730/comments","events_url":"https://api.github.com/repos/dcos/dcos/issues/2730/events","html_url":"https://github.com/dcos/dcos/pull/2730","id":313328646,"number":2730,"title":"[DCOS-14199] Write strings to files atomically in pkgpanda.util","user":{"login":"adamtheturtle","id":797801,"avatar_url":"https://avatars3.githubusercontent.com/u/797801?v=4","gravatar_id":"","url":"https://api.github.com/users/adamtheturtle","html_url":"https://github.com/adamtheturtle","followers_url":"https://api.github.com/users/adamtheturtle/followers","following_url":"https://api.github.com/users/adamtheturtle/following{/other_user}","gists_url":"https://api.github.com/users/adamtheturtle/gists{/gist_id}","starred_url":"https://api.github.com/users/adamtheturtle/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/adamtheturtle/subscriptions","organizations_url":"https://api.github.com/users/adamtheturtle/orgs","repos_url":"https://api.github.com/users/adamtheturtle/repos","events_url":"https://api.github.com/users/adamtheturtle/events{/privacy}","received_events_url":"https://api.github.com/users/adamtheturtle/received_events","type":"User","site_admin":false},"labels":[{"id":364878184,"url":"https://api.github.com/repos/dcos/dcos/labels/Ready%20For%20Review","name":"Ready For Review","color":"0e8a16","default":false}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":18,"created_at":"2018-04-11T13:39:38Z","updated_at":"2018-04-19T15:54:26Z","closed_at":null,"author_association":"CONTRIBUTOR","pull_request":{"url":"https://api.github.com/repos/dcos/dcos/pulls/2730","html_url":"https://github.com/dcos/dcos/pull/2730","diff_url":"https://github.com/dcos/dcos/pull/2730.diff","patch_url":"https://github.com/dcos/dcos/pull/2730.patch"},"body":"## High-level description\r\n\r\nThis changes `pkgpanda.util.write_string` to avoid a race condition as described in [DCOS-14199](https://jira.mesosphere.com/browse/DCOS-14199).\r\nI have also applied this change to some related functions as a precaution.\r\nI have stopped returning data from the functions as it appears that those return values are never used.\r\n\r\nThis also adds a test for `write_string` to enshrine the permission requirements and basic functionality of `write_string` (thanks @mhrabovcin for help). That test passes on `master` *and* with the changes here.\r\n\r\n## Corresponding DC/OS tickets (obligatory)\r\n\r\nThese DC/OS JIRA ticket(s) must be updated (ideally closed) in the moment this PR lands:\r\n\r\n  - [DCOS-14199](https://jira.mesosphere.com/browse/DCOS-14199) exhibitor.py try_shortcut() failed due to an empty file\r\n\r\n## Checklist for all PRs\r\n\r\n  - [ ] Added a comprehensible changelog entry to `CHANGES.md` or explain why this is not a user-facing change: See https://github.com/dcos/dcos/pull/2730#issuecomment-380506106.\r\n  - [ ] Included a test which will fail if code is reverted but test is not. If there is no test please explain here: This code is already called by the test suite. We could test the race condition with something like the following with a timeout but I'd rather not. I'm happy to discuss this with a reviewer:\r\n\r\n```python\r\n# This will trigger the error from the issue if run by two processes in parallel.\r\n# Calling the new function in the loop will not.\r\nfilename = 'foo.txt'\r\nwhile True:\r\n    with open(filename, 'w+') as f:\r\n        f.write('hello')\r\n\r\n    with open(filename) as f:\r\n        stripped = f.read().strip()\r\n        assert stripped != ''\r\n```\r\n\r\n  - [X] Read the [DC/OS contributing guidelines](https://github.com/dcos/dcos/blob/master/contributing.md)\r\n  - [X] Followed relevant code rules [Rules for Packages and Systemd](https://github.com/dcos/dcos/tree/master/docs)"},"comment":{"url":"https://api.github.com/repos/dcos/dcos/issues/comments/382787818","html_url":"https://github.com/dcos/dcos/pull/2730#issuecomment-382787818","issue_url":"https://api.github.com/repos/dcos/dcos/issues/2730","id":382787818,"user":{"login":"adamtheturtle","id":797801,"avatar_url":"https://avatars3.githubusercontent.com/u/797801?v=4","gravatar_id":"","url":"https://api.github.com/users/adamtheturtle","html_url":"https://github.com/adamtheturtle","followers_url":"https://api.github.com/users/adamtheturtle/followers","following_url":"https://api.github.com/users/adamtheturtle/following{/other_user}","gists_url":"https://api.github.com/users/adamtheturtle/gists{/gist_id}","starred_url":"https://api.github.com/users/adamtheturtle/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/adamtheturtle/subscriptions","organizations_url":"https://api.github.com/users/adamtheturtle/orgs","repos_url":"https://api.github.com/users/adamtheturtle/repos","events_url":"https://api.github.com/users/adamtheturtle/events{/privacy}","received_events_url":"https://api.github.com/users/adamtheturtle/received_events","type":"User","site_admin":false},"created_at":"2018-04-19T15:54:26Z","updated_at":"2018-04-19T15:54:26Z","author_association":"CONTRIBUTOR","body":"`teamcity/dcos/test/azure/arm` [failed](https://teamcity.mesosphere.io/viewLog.html?buildId=1041202&buildTypeId=DcOs_Open_Test_IntegrationTest_AzureArm&tab=buildLog).\r\n\r\nI will re-run and if it is a flake I will report to JIRA."}}
{"actor":{"display_login":"adamtheturtle"}}