{"action":"created","comment":{"url":"https://api.github.com/repos/Peripli/service-manager/pulls/comments/224761195","pull_request_review_id":164211327,"id":224761195,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDIyNDc2MTE5NQ==","diff_hunk":"@@ -89,6 +91,9 @@ func New(ctx context.Context, env env.Environment) *ServiceManagerBuilder {\n \t// setup logging\n \tctx = log.Configure(ctx, cfg.Log)\n \n+\t// goroutines that log must be started after the log has been configured\n+\tutil.HandleInterrupts(ctx, cancel)","path":"pkg/sm/sm.go","position":23,"original_position":23,"commit_id":"4cc9cf3d54e7dcc0e992812bd8206bba26890ea5","original_commit_id":"4cc9cf3d54e7dcc0e992812bd8206bba26890ea5","user":{"login":"KirilKabakchiev","id":8989462,"node_id":"MDQ6VXNlcjg5ODk0NjI=","avatar_url":"https://avatars1.githubusercontent.com/u/8989462?v=4","gravatar_id":"","url":"https://api.github.com/users/KirilKabakchiev","html_url":"https://github.com/KirilKabakchiev","followers_url":"https://api.github.com/users/KirilKabakchiev/followers","following_url":"https://api.github.com/users/KirilKabakchiev/following{/other_user}","gists_url":"https://api.github.com/users/KirilKabakchiev/gists{/gist_id}","starred_url":"https://api.github.com/users/KirilKabakchiev/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/KirilKabakchiev/subscriptions","organizations_url":"https://api.github.com/users/KirilKabakchiev/orgs","repos_url":"https://api.github.com/users/KirilKabakchiev/repos","events_url":"https://api.github.com/users/KirilKabakchiev/events{/privacy}","received_events_url":"https://api.github.com/users/KirilKabakchiev/received_events","type":"User","site_admin":false},"body":"can we put it in the server for now ? otherwise we gotta do the same in proxy.go","created_at":"2018-10-12T12:02:39Z","updated_at":"2018-10-12T12:02:40Z","html_url":"https://github.com/Peripli/service-manager/pull/159#discussion_r224761195","pull_request_url":"https://api.github.com/repos/Peripli/service-manager/pulls/159","author_association":"MEMBER","_links":{"self":{"href":"https://api.github.com/repos/Peripli/service-manager/pulls/comments/224761195"},"html":{"href":"https://github.com/Peripli/service-manager/pull/159#discussion_r224761195"},"pull_request":{"href":"https://api.github.com/repos/Peripli/service-manager/pulls/159"}}},"pull_request":{"url":"https://api.github.com/repos/Peripli/service-manager/pulls/159","id":222441114,"node_id":"MDExOlB1bGxSZXF1ZXN0MjIyNDQxMTE0","html_url":"https://github.com/Peripli/service-manager/pull/159","diff_url":"https://github.com/Peripli/service-manager/pull/159.diff","patch_url":"https://github.com/Peripli/service-manager/pull/159.patch","issue_url":"https://api.github.com/repos/Peripli/service-manager/issues/159","number":159,"state":"open","locked":false,"title":"Fix race condition","user":{"login":"dpanayotov","id":4910295,"node_id":"MDQ6VXNlcjQ5MTAyOTU=","avatar_url":"https://avatars1.githubusercontent.com/u/4910295?v=4","gravatar_id":"","url":"https://api.github.com/users/dpanayotov","html_url":"https://github.com/dpanayotov","followers_url":"https://api.github.com/users/dpanayotov/followers","following_url":"https://api.github.com/users/dpanayotov/following{/other_user}","gists_url":"https://api.github.com/users/dpanayotov/gists{/gist_id}","starred_url":"https://api.github.com/users/dpanayotov/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dpanayotov/subscriptions","organizations_url":"https://api.github.com/users/dpanayotov/orgs","repos_url":"https://api.github.com/users/dpanayotov/repos","events_url":"https://api.github.com/users/dpanayotov/events{/privacy}","received_events_url":"https://api.github.com/users/dpanayotov/received_events","type":"User","site_admin":false},"body":"Fixes #157 \r\nThere are a couple issues:\r\n1. `sm.New` wants to configure the default entry (write) but `util.HandleInterrupts` starts a goroutine that wants to read the default entry in order to copy it (read). Any goroutines that use logging must be started after the `log.Configure` call. Not the best solution. Same applies to `pkg/storage/registry.go - awaitTermination`\r\n2. Because we share the same entry for all log events in a context, there is a race condition in the `onrik/logrus/filename` hook that adds the filename and location of the log - \r\n https://github.com/onrik/logrus/blob/master/filename/filename.go#L24 Here, the same logrus.Entry is shared between the `until.HandleInterrupts` goroutine and the main service-manager goroutine (out of any http request).  `util.HandleInterrupts` invokes the hook which wants to write in the entry's data map, but at the same time the main goroutine also wants to log, writing to the same entry map. Solution is to copy the entry for every log. Again, not the best solution...\r\n\r\nOverall, this is a workaround, that comes from abusing the logrus library. The logrus.Logger has sync.Pool that doesn't share entries and uses proper synchronization, but doesn't fit our needs because it doesn't expose the `Data` field in which we want to store context (request-scoped) information. \r\n\r\nExplore and see if other logging libraries fit our needs:\r\n- https://github.com/uber-go/zap\r\n- https://github.com/rs/zerolog\r\n- https://github.com/cloudfoundry/lager","created_at":"2018-10-12T11:51:18Z","updated_at":"2018-10-12T12:02:40Z","closed_at":null,"merged_at":null,"merge_commit_sha":"e071c3dc9f2902c8b7099942c1b245d34abfcd21","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/Peripli/service-manager/pulls/159/commits","review_comments_url":"https://api.github.com/repos/Peripli/service-manager/pulls/159/comments","review_comment_url":"https://api.github.com/repos/Peripli/service-manager/pulls/comments{/number}","comments_url":"https://api.github.com/repos/Peripli/service-manager/issues/159/comments","statuses_url":"https://api.github.com/repos/Peripli/service-manager/statuses/4cc9cf3d54e7dcc0e992812bd8206bba26890ea5","head":{"label":"Peripli:race","ref":"race","sha":"4cc9cf3d54e7dcc0e992812bd8206bba26890ea5","user":{"login":"Peripli","id":36069234,"node_id":"MDEyOk9yZ2FuaXphdGlvbjM2MDY5MjM0","avatar_url":"https://avatars1.githubusercontent.com/u/36069234?v=4","gravatar_id":"","url":"https://api.github.com/users/Peripli","html_url":"https://github.com/Peripli","followers_url":"https://api.github.com/users/Peripli/followers","following_url":"https://api.github.com/users/Peripli/following{/other_user}","gists_url":"https://api.github.com/users/Peripli/gists{/gist_id}","starred_url":"https://api.github.com/users/Peripli/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Peripli/subscriptions","organizations_url":"https://api.github.com/users/Peripli/orgs","repos_url":"https://api.github.com/users/Peripli/repos","events_url":"https://api.github.com/users/Peripli/events{/privacy}","received_events_url":"https://api.github.com/users/Peripli/received_events","type":"Organization","site_admin":false},"repo":{"id":123334573,"node_id":"MDEwOlJlcG9zaXRvcnkxMjMzMzQ1NzM=","name":"service-manager","full_name":"Peripli/service-manager","private":false,"owner":{"login":"Peripli","id":36069234,"node_id":"MDEyOk9yZ2FuaXphdGlvbjM2MDY5MjM0","avatar_url":"https://avatars1.githubusercontent.com/u/36069234?v=4","gravatar_id":"","url":"https://api.github.com/users/Peripli","html_url":"https://github.com/Peripli","followers_url":"https://api.github.com/users/Peripli/followers","following_url":"https://api.github.com/users/Peripli/following{/other_user}","gists_url":"https://api.github.com/users/Peripli/gists{/gist_id}","starred_url":"https://api.github.com/users/Peripli/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Peripli/subscriptions","organizations_url":"https://api.github.com/users/Peripli/orgs","repos_url":"https://api.github.com/users/Peripli/repos","events_url":"https://api.github.com/users/Peripli/events{/privacy}","received_events_url":"https://api.github.com/users/Peripli/received_events","type":"Organization","site_admin":false},"html_url":"https://github.com/Peripli/service-manager","description":"Service Manager Core","fork":false,"url":"https://api.github.com/repos/Peripli/service-manager","forks_url":"https://api.github.com/repos/Peripli/service-manager/forks","keys_url":"https://api.github.com/repos/Peripli/service-manager/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Peripli/service-manager/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Peripli/service-manager/teams","hooks_url":"https://api.github.com/repos/Peripli/service-manager/hooks","issue_events_url":"https://api.github.com/repos/Peripli/service-manager/issues/events{/number}","events_url":"https://api.github.com/repos/Peripli/service-manager/events","assignees_url":"https://api.github.com/repos/Peripli/service-manager/assignees{/user}","branches_url":"https://api.github.com/repos/Peripli/service-manager/branches{/branch}","tags_url":"https://api.github.com/repos/Peripli/service-manager/tags","blobs_url":"https://api.github.com/repos/Peripli/service-manager/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Peripli/service-manager/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Peripli/service-manager/git/refs{/sha}","trees_url":"https://api.github.com/repos/Peripli/service-manager/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Peripli/service-manager/statuses/{sha}","languages_url":"https://api.github.com/repos/Peripli/service-manager/languages","stargazers_url":"https://api.github.com/repos/Peripli/service-manager/stargazers","contributors_url":"https://api.github.com/repos/Peripli/service-manager/contributors","subscribers_url":"https://api.github.com/repos/Peripli/service-manager/subscribers","subscription_url":"https://api.github.com/repos/Peripli/service-manager/subscription","commits_url":"https://api.github.com/repos/Peripli/service-manager/commits{/sha}","git_commits_url":"https://api.github.com/repos/Peripli/service-manager/git/commits{/sha}","comments_url":"https://api.github.com/repos/Peripli/service-manager/comments{/number}","issue_comment_url":"https://api.github.com/repos/Peripli/service-manager/issues/comments{/number}","contents_url":"https://api.github.com/repos/Peripli/service-manager/contents/{+path}","compare_url":"https://api.github.com/repos/Peripli/service-manager/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Peripli/service-manager/merges","archive_url":"https://api.github.com/repos/Peripli/service-manager/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Peripli/service-manager/downloads","issues_url":"https://api.github.com/repos/Peripli/service-manager/issues{/number}","pulls_url":"https://api.github.com/repos/Peripli/service-manager/pulls{/number}","milestones_url":"https://api.github.com/repos/Peripli/service-manager/milestones{/number}","notifications_url":"https://api.github.com/repos/Peripli/service-manager/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Peripli/service-manager/labels{/name}","releases_url":"https://api.github.com/repos/Peripli/service-manager/releases{/id}","deployments_url":"https://api.github.com/repos/Peripli/service-manager/deployments","created_at":"2018-02-28T19:51:32Z","updated_at":"2018-10-11T15:56:36Z","pushed_at":"2018-10-12T11:55:16Z","git_url":"git://github.com/Peripli/service-manager.git","ssh_url":"git@github.com:Peripli/service-manager.git","clone_url":"https://github.com/Peripli/service-manager.git","svn_url":"https://github.com/Peripli/service-manager","homepage":"","size":823,"stargazers_count":17,"watchers_count":17,"language":"Go","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":5,"mirror_url":null,"archived":false,"open_issues_count":34,"license":{"key":"apache-2.0","name":"Apache License 2.0","spdx_id":"Apache-2.0","url":"https://api.github.com/licenses/apache-2.0","node_id":"MDc6TGljZW5zZTI="},"forks":5,"open_issues":34,"watchers":17,"default_branch":"master"}},"base":{"label":"Peripli:master","ref":"master","sha":"5f24721248f5b01ee71a37d676552bbc22f57804","user":{"login":"Peripli","id":36069234,"node_id":"MDEyOk9yZ2FuaXphdGlvbjM2MDY5MjM0","avatar_url":"https://avatars1.githubusercontent.com/u/36069234?v=4","gravatar_id":"","url":"https://api.github.com/users/Peripli","html_url":"https://github.com/Peripli","followers_url":"https://api.github.com/users/Peripli/followers","following_url":"https://api.github.com/users/Peripli/following{/other_user}","gists_url":"https://api.github.com/users/Peripli/gists{/gist_id}","starred_url":"https://api.github.com/users/Peripli/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Peripli/subscriptions","organizations_url":"https://api.github.com/users/Peripli/orgs","repos_url":"https://api.github.com/users/Peripli/repos","events_url":"https://api.github.com/users/Peripli/events{/privacy}","received_events_url":"https://api.github.com/users/Peripli/received_events","type":"Organization","site_admin":false},"repo":{"id":123334573,"node_id":"MDEwOlJlcG9zaXRvcnkxMjMzMzQ1NzM=","name":"service-manager","full_name":"Peripli/service-manager","private":false,"owner":{"login":"Peripli","id":36069234,"node_id":"MDEyOk9yZ2FuaXphdGlvbjM2MDY5MjM0","avatar_url":"https://avatars1.githubusercontent.com/u/36069234?v=4","gravatar_id":"","url":"https://api.github.com/users/Peripli","html_url":"https://github.com/Peripli","followers_url":"https://api.github.com/users/Peripli/followers","following_url":"https://api.github.com/users/Peripli/following{/other_user}","gists_url":"https://api.github.com/users/Peripli/gists{/gist_id}","starred_url":"https://api.github.com/users/Peripli/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Peripli/subscriptions","organizations_url":"https://api.github.com/users/Peripli/orgs","repos_url":"https://api.github.com/users/Peripli/repos","events_url":"https://api.github.com/users/Peripli/events{/privacy}","received_events_url":"https://api.github.com/users/Peripli/received_events","type":"Organization","site_admin":false},"html_url":"https://github.com/Peripli/service-manager","description":"Service Manager Core","fork":false,"url":"https://api.github.com/repos/Peripli/service-manager","forks_url":"https://api.github.com/repos/Peripli/service-manager/forks","keys_url":"https://api.github.com/repos/Peripli/service-manager/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Peripli/service-manager/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Peripli/service-manager/teams","hooks_url":"https://api.github.com/repos/Peripli/service-manager/hooks","issue_events_url":"https://api.github.com/repos/Peripli/service-manager/issues/events{/number}","events_url":"https://api.github.com/repos/Peripli/service-manager/events","assignees_url":"https://api.github.com/repos/Peripli/service-manager/assignees{/user}","branches_url":"https://api.github.com/repos/Peripli/service-manager/branches{/branch}","tags_url":"https://api.github.com/repos/Peripli/service-manager/tags","blobs_url":"https://api.github.com/repos/Peripli/service-manager/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Peripli/service-manager/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Peripli/service-manager/git/refs{/sha}","trees_url":"https://api.github.com/repos/Peripli/service-manager/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Peripli/service-manager/statuses/{sha}","languages_url":"https://api.github.com/repos/Peripli/service-manager/languages","stargazers_url":"https://api.github.com/repos/Peripli/service-manager/stargazers","contributors_url":"https://api.github.com/repos/Peripli/service-manager/contributors","subscribers_url":"https://api.github.com/repos/Peripli/service-manager/subscribers","subscription_url":"https://api.github.com/repos/Peripli/service-manager/subscription","commits_url":"https://api.github.com/repos/Peripli/service-manager/commits{/sha}","git_commits_url":"https://api.github.com/repos/Peripli/service-manager/git/commits{/sha}","comments_url":"https://api.github.com/repos/Peripli/service-manager/comments{/number}","issue_comment_url":"https://api.github.com/repos/Peripli/service-manager/issues/comments{/number}","contents_url":"https://api.github.com/repos/Peripli/service-manager/contents/{+path}","compare_url":"https://api.github.com/repos/Peripli/service-manager/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Peripli/service-manager/merges","archive_url":"https://api.github.com/repos/Peripli/service-manager/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Peripli/service-manager/downloads","issues_url":"https://api.github.com/repos/Peripli/service-manager/issues{/number}","pulls_url":"https://api.github.com/repos/Peripli/service-manager/pulls{/number}","milestones_url":"https://api.github.com/repos/Peripli/service-manager/milestones{/number}","notifications_url":"https://api.github.com/repos/Peripli/service-manager/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Peripli/service-manager/labels{/name}","releases_url":"https://api.github.com/repos/Peripli/service-manager/releases{/id}","deployments_url":"https://api.github.com/repos/Peripli/service-manager/deployments","created_at":"2018-02-28T19:51:32Z","updated_at":"2018-10-11T15:56:36Z","pushed_at":"2018-10-12T11:55:16Z","git_url":"git://github.com/Peripli/service-manager.git","ssh_url":"git@github.com:Peripli/service-manager.git","clone_url":"https://github.com/Peripli/service-manager.git","svn_url":"https://github.com/Peripli/service-manager","homepage":"","size":823,"stargazers_count":17,"watchers_count":17,"language":"Go","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":5,"mirror_url":null,"archived":false,"open_issues_count":34,"license":{"key":"apache-2.0","name":"Apache License 2.0","spdx_id":"Apache-2.0","url":"https://api.github.com/licenses/apache-2.0","node_id":"MDc6TGljZW5zZTI="},"forks":5,"open_issues":34,"watchers":17,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/Peripli/service-manager/pulls/159"},"html":{"href":"https://github.com/Peripli/service-manager/pull/159"},"issue":{"href":"https://api.github.com/repos/Peripli/service-manager/issues/159"},"comments":{"href":"https://api.github.com/repos/Peripli/service-manager/issues/159/comments"},"review_comments":{"href":"https://api.github.com/repos/Peripli/service-manager/pulls/159/comments"},"review_comment":{"href":"https://api.github.com/repos/Peripli/service-manager/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/Peripli/service-manager/pulls/159/commits"},"statuses":{"href":"https://api.github.com/repos/Peripli/service-manager/statuses/4cc9cf3d54e7dcc0e992812bd8206bba26890ea5"}},"author_association":"MEMBER"}}
{"actor":{"display_login":"KirilKabakchiev"}}