{"action":"created","comment":{"url":"https://api.github.com/repos/minio/minio/pulls/comments/192963624","pull_request_review_id":125838647,"id":192963624,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDE5Mjk2MzYyNA==","diff_hunk":"@@ -70,42 +89,61 @@ func (sys *PolicySys) IsAllowed(args policy.Args) bool {\n \treturn args.IsOwner\n }\n \n-// Init - initializes policy system from policy.json of all buckets.\n-func (sys *PolicySys) Init(objAPI ObjectLayer) error {\n-\tif objAPI == nil {\n-\t\treturn errInvalidArgument\n-\t}\n-\n+// Refresh in-memory bucket policy cache.\n+func (sys *PolicySys) refreshInmemoryBucketpolicy(objAPI ObjectLayer) {\n \tbuckets, err := objAPI.ListBuckets(context.Background())\n \tif err != nil {\n-\t\treturn err\n+\t\treturn\n \t}\n-\n+\tsys.RemoveDeletedBuckets(buckets)","path":"cmd/policy.go","position":58,"original_position":51,"commit_id":"b8e90023a86466704d947cd16edce887c6ca31eb","original_commit_id":"1070b1f01b5b4d7f25bc3b2e00338862b5ddf1f1","user":{"login":"balamurugana","id":629407,"node_id":"MDQ6VXNlcjYyOTQwNw==","avatar_url":"https://avatars2.githubusercontent.com/u/629407?v=4","gravatar_id":"","url":"https://api.github.com/users/balamurugana","html_url":"https://github.com/balamurugana","followers_url":"https://api.github.com/users/balamurugana/followers","following_url":"https://api.github.com/users/balamurugana/following{/other_user}","gists_url":"https://api.github.com/users/balamurugana/gists{/gist_id}","starred_url":"https://api.github.com/users/balamurugana/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/balamurugana/subscriptions","organizations_url":"https://api.github.com/users/balamurugana/orgs","repos_url":"https://api.github.com/users/balamurugana/repos","events_url":"https://api.github.com/users/balamurugana/events{/privacy}","received_events_url":"https://api.github.com/users/balamurugana/received_events","type":"User","site_admin":false},"body":"Yep, but not the way you are referring.  Below is the method\r\n\r\n```go\r\nfunc (sys *PolicySys) reinit() {\r\n\tobjAPI := newObjectLayerFn()\r\n\tif objAPI == nil {\r\n\t\treturn\r\n\t}\r\n\r\n\tbuckets, err := objAPI.ListBuckets(context.Background())\r\n\tif err != nil {\r\n\t\treturn\r\n\t}\r\n\r\n\tbucketPolicyMap := make(map[string]policy.Policy)\r\n\tfor _, bucket := range buckets {\r\n\t\tif config, err := GetPolicyConfig(objAPI, bucket.Name); err == nil {\r\n\t\t\tbucketPolicyMap[bucket.Name] = *config\r\n\t\t}\r\n\t}\r\n\r\n\tsys.Lock()\r\n\tsys.bucketPolicyMap = bucketPolicyMap\r\n\tsys.Unlock()\r\n}\r\n```\r\n\r\nand `PolicySys.Init()` will start it as goroutine, before `return nil`\r\n```\r\ngo func() {\r\n\tticker := time.NewTicker(5 * time.Minute)\r\n\tdefer ticker.Stop()\r\n\r\n\tfor {\r\n\t\tselect {\r\n\t\tcase <-globalServiceDoneCh:\r\n\t\t\tbreak\r\n\t\tcase <-ticker.C:\r\n\t\t\tsys.reinit()\r\n\t\t}\r\n\t}\r\n}()\r\n```\r\n","created_at":"2018-06-05T06:50:09Z","updated_at":"2018-06-05T06:50:09Z","html_url":"https://github.com/minio/minio/pull/6007#discussion_r192963624","pull_request_url":"https://api.github.com/repos/minio/minio/pulls/6007","author_association":"MEMBER","_links":{"self":{"href":"https://api.github.com/repos/minio/minio/pulls/comments/192963624"},"html":{"href":"https://github.com/minio/minio/pull/6007#discussion_r192963624"},"pull_request":{"href":"https://api.github.com/repos/minio/minio/pulls/6007"}},"in_reply_to_id":192935324},"pull_request":{"url":"https://api.github.com/repos/minio/minio/pulls/6007","id":192176188,"node_id":"MDExOlB1bGxSZXF1ZXN0MTkyMTc2MTg4","html_url":"https://github.com/minio/minio/pull/6007","diff_url":"https://github.com/minio/minio/pull/6007.diff","patch_url":"https://github.com/minio/minio/pull/6007.patch","issue_url":"https://api.github.com/repos/minio/minio/issues/6007","number":6007,"state":"open","locked":false,"title":"Refresh in-memory bucket policy cache every 5 minutes","user":{"login":"krishnasrinivas","id":634494,"node_id":"MDQ6VXNlcjYzNDQ5NA==","avatar_url":"https://avatars0.githubusercontent.com/u/634494?v=4","gravatar_id":"","url":"https://api.github.com/users/krishnasrinivas","html_url":"https://github.com/krishnasrinivas","followers_url":"https://api.github.com/users/krishnasrinivas/followers","following_url":"https://api.github.com/users/krishnasrinivas/following{/other_user}","gists_url":"https://api.github.com/users/krishnasrinivas/gists{/gist_id}","starred_url":"https://api.github.com/users/krishnasrinivas/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/krishnasrinivas/subscriptions","organizations_url":"https://api.github.com/users/krishnasrinivas/orgs","repos_url":"https://api.github.com/users/krishnasrinivas/repos","events_url":"https://api.github.com/users/krishnasrinivas/events{/privacy}","received_events_url":"https://api.github.com/users/krishnasrinivas/received_events","type":"User","site_admin":false},"body":"<!--- Provide a general summary of your changes in the Title above -->\r\n\r\n## Description\r\n<!--- Describe your changes in detail -->\r\nRefresh in-memory bucket policy cache every 5 minutes so that if a node does not receive bucket-policy-change-notification the node can update the in-mem cache.\r\n\r\n\r\n## How Has This Been Tested?\r\n<!--- Please describe in detail how you tested your changes. -->\r\n<!--- Include details of your testing environment, and the tests you ran to -->\r\n<!--- see how your change affects other areas of the code, etc. -->\r\nmanual\r\n\r\n## Types of changes\r\n<!--- What types of changes does your code introduce? Put an `x` in all the boxes that apply: -->\r\n- [ ] Bug fix (non-breaking change which fixes an issue)\r\n- [ ] New feature (non-breaking change which adds functionality)\r\n- [ ] Breaking change (fix or feature that would cause existing functionality to change)\r\n\r\n## Checklist:\r\n<!--- Go over all the following points, and put an `x` in all the boxes that apply. -->\r\n<!--- If you're unsure about any of these, don't hesitate to ask. We're here to help! -->\r\n- [ ] My code follows the code style of this project.\r\n- [ ] My change requires a change to the documentation.\r\n- [ ] I have updated the documentation accordingly.\r\n- [ ] I have added unit tests to cover my changes.\r\n- [ ] I have added/updated functional tests in [mint](https://github.com/minio/mint). (If yes, add `mint` PR # here: )\r\n- [ ] All new and existing tests passed.","created_at":"2018-06-02T03:08:09Z","updated_at":"2018-06-05T06:50:09Z","closed_at":null,"merged_at":null,"merge_commit_sha":"e8c65dba29a3930f630c7a714cb248867295fee4","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[{"id":574010436,"node_id":"MDU6TGFiZWw1NzQwMTA0MzY=","url":"https://api.github.com/repos/minio/minio/labels/priority:%20high","name":"priority: high","color":"FF530D","default":false}],"milestone":null,"commits_url":"https://api.github.com/repos/minio/minio/pulls/6007/commits","review_comments_url":"https://api.github.com/repos/minio/minio/pulls/6007/comments","review_comment_url":"https://api.github.com/repos/minio/minio/pulls/comments{/number}","comments_url":"https://api.github.com/repos/minio/minio/issues/6007/comments","statuses_url":"https://api.github.com/repos/minio/minio/statuses/b8e90023a86466704d947cd16edce887c6ca31eb","head":{"label":"krishnasrinivas:refresh-policy-cache","ref":"refresh-policy-cache","sha":"b8e90023a86466704d947cd16edce887c6ca31eb","user":{"login":"krishnasrinivas","id":634494,"node_id":"MDQ6VXNlcjYzNDQ5NA==","avatar_url":"https://avatars0.githubusercontent.com/u/634494?v=4","gravatar_id":"","url":"https://api.github.com/users/krishnasrinivas","html_url":"https://github.com/krishnasrinivas","followers_url":"https://api.github.com/users/krishnasrinivas/followers","following_url":"https://api.github.com/users/krishnasrinivas/following{/other_user}","gists_url":"https://api.github.com/users/krishnasrinivas/gists{/gist_id}","starred_url":"https://api.github.com/users/krishnasrinivas/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/krishnasrinivas/subscriptions","organizations_url":"https://api.github.com/users/krishnasrinivas/orgs","repos_url":"https://api.github.com/users/krishnasrinivas/repos","events_url":"https://api.github.com/users/krishnasrinivas/events{/privacy}","received_events_url":"https://api.github.com/users/krishnasrinivas/received_events","type":"User","site_admin":false},"repo":{"id":39705039,"node_id":"MDEwOlJlcG9zaXRvcnkzOTcwNTAzOQ==","name":"minio","full_name":"krishnasrinivas/minio","owner":{"login":"krishnasrinivas","id":634494,"node_id":"MDQ6VXNlcjYzNDQ5NA==","avatar_url":"https://avatars0.githubusercontent.com/u/634494?v=4","gravatar_id":"","url":"https://api.github.com/users/krishnasrinivas","html_url":"https://github.com/krishnasrinivas","followers_url":"https://api.github.com/users/krishnasrinivas/followers","following_url":"https://api.github.com/users/krishnasrinivas/following{/other_user}","gists_url":"https://api.github.com/users/krishnasrinivas/gists{/gist_id}","starred_url":"https://api.github.com/users/krishnasrinivas/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/krishnasrinivas/subscriptions","organizations_url":"https://api.github.com/users/krishnasrinivas/orgs","repos_url":"https://api.github.com/users/krishnasrinivas/repos","events_url":"https://api.github.com/users/krishnasrinivas/events{/privacy}","received_events_url":"https://api.github.com/users/krishnasrinivas/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/krishnasrinivas/minio","description":"Minio Cloud Storage Server","fork":true,"url":"https://api.github.com/repos/krishnasrinivas/minio","forks_url":"https://api.github.com/repos/krishnasrinivas/minio/forks","keys_url":"https://api.github.com/repos/krishnasrinivas/minio/keys{/key_id}","collaborators_url":"https://api.github.com/repos/krishnasrinivas/minio/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/krishnasrinivas/minio/teams","hooks_url":"https://api.github.com/repos/krishnasrinivas/minio/hooks","issue_events_url":"https://api.github.com/repos/krishnasrinivas/minio/issues/events{/number}","events_url":"https://api.github.com/repos/krishnasrinivas/minio/events","assignees_url":"https://api.github.com/repos/krishnasrinivas/minio/assignees{/user}","branches_url":"https://api.github.com/repos/krishnasrinivas/minio/branches{/branch}","tags_url":"https://api.github.com/repos/krishnasrinivas/minio/tags","blobs_url":"https://api.github.com/repos/krishnasrinivas/minio/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/krishnasrinivas/minio/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/krishnasrinivas/minio/git/refs{/sha}","trees_url":"https://api.github.com/repos/krishnasrinivas/minio/git/trees{/sha}","statuses_url":"https://api.github.com/repos/krishnasrinivas/minio/statuses/{sha}","languages_url":"https://api.github.com/repos/krishnasrinivas/minio/languages","stargazers_url":"https://api.github.com/repos/krishnasrinivas/minio/stargazers","contributors_url":"https://api.github.com/repos/krishnasrinivas/minio/contributors","subscribers_url":"https://api.github.com/repos/krishnasrinivas/minio/subscribers","subscription_url":"https://api.github.com/repos/krishnasrinivas/minio/subscription","commits_url":"https://api.github.com/repos/krishnasrinivas/minio/commits{/sha}","git_commits_url":"https://api.github.com/repos/krishnasrinivas/minio/git/commits{/sha}","comments_url":"https://api.github.com/repos/krishnasrinivas/minio/comments{/number}","issue_comment_url":"https://api.github.com/repos/krishnasrinivas/minio/issues/comments{/number}","contents_url":"https://api.github.com/repos/krishnasrinivas/minio/contents/{+path}","compare_url":"https://api.github.com/repos/krishnasrinivas/minio/compare/{base}...{head}","merges_url":"https://api.github.com/repos/krishnasrinivas/minio/merges","archive_url":"https://api.github.com/repos/krishnasrinivas/minio/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/krishnasrinivas/minio/downloads","issues_url":"https://api.github.com/repos/krishnasrinivas/minio/issues{/number}","pulls_url":"https://api.github.com/repos/krishnasrinivas/minio/pulls{/number}","milestones_url":"https://api.github.com/repos/krishnasrinivas/minio/milestones{/number}","notifications_url":"https://api.github.com/repos/krishnasrinivas/minio/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/krishnasrinivas/minio/labels{/name}","releases_url":"https://api.github.com/repos/krishnasrinivas/minio/releases{/id}","deployments_url":"https://api.github.com/repos/krishnasrinivas/minio/deployments","created_at":"2015-07-25T22:31:14Z","updated_at":"2018-06-05T02:32:07Z","pushed_at":"2018-06-05T04:12:58Z","git_url":"git://github.com/krishnasrinivas/minio.git","ssh_url":"git@github.com:krishnasrinivas/minio.git","clone_url":"https://github.com/krishnasrinivas/minio.git","svn_url":"https://github.com/krishnasrinivas/minio","homepage":"https://minio.io/#minio-server","size":38443,"stargazers_count":2,"watchers_count":2,"language":"Go","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"archived":false,"open_issues_count":0,"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":1,"open_issues":0,"watchers":2,"default_branch":"master"}},"base":{"label":"minio:master","ref":"master","sha":"6fb06045028b7a57c37c60a612c8e50735279ab4","user":{"login":"minio","id":695951,"node_id":"MDEyOk9yZ2FuaXphdGlvbjY5NTk1MQ==","avatar_url":"https://avatars3.githubusercontent.com/u/695951?v=4","gravatar_id":"","url":"https://api.github.com/users/minio","html_url":"https://github.com/minio","followers_url":"https://api.github.com/users/minio/followers","following_url":"https://api.github.com/users/minio/following{/other_user}","gists_url":"https://api.github.com/users/minio/gists{/gist_id}","starred_url":"https://api.github.com/users/minio/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/minio/subscriptions","organizations_url":"https://api.github.com/users/minio/orgs","repos_url":"https://api.github.com/users/minio/repos","events_url":"https://api.github.com/users/minio/events{/privacy}","received_events_url":"https://api.github.com/users/minio/received_events","type":"Organization","site_admin":false},"repo":{"id":29261473,"node_id":"MDEwOlJlcG9zaXRvcnkyOTI2MTQ3Mw==","name":"minio","full_name":"minio/minio","owner":{"login":"minio","id":695951,"node_id":"MDEyOk9yZ2FuaXphdGlvbjY5NTk1MQ==","avatar_url":"https://avatars3.githubusercontent.com/u/695951?v=4","gravatar_id":"","url":"https://api.github.com/users/minio","html_url":"https://github.com/minio","followers_url":"https://api.github.com/users/minio/followers","following_url":"https://api.github.com/users/minio/following{/other_user}","gists_url":"https://api.github.com/users/minio/gists{/gist_id}","starred_url":"https://api.github.com/users/minio/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/minio/subscriptions","organizations_url":"https://api.github.com/users/minio/orgs","repos_url":"https://api.github.com/users/minio/repos","events_url":"https://api.github.com/users/minio/events{/privacy}","received_events_url":"https://api.github.com/users/minio/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/minio/minio","description":"Minio is an open source object storage server compatible with Amazon S3 APIs","fork":false,"url":"https://api.github.com/repos/minio/minio","forks_url":"https://api.github.com/repos/minio/minio/forks","keys_url":"https://api.github.com/repos/minio/minio/keys{/key_id}","collaborators_url":"https://api.github.com/repos/minio/minio/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/minio/minio/teams","hooks_url":"https://api.github.com/repos/minio/minio/hooks","issue_events_url":"https://api.github.com/repos/minio/minio/issues/events{/number}","events_url":"https://api.github.com/repos/minio/minio/events","assignees_url":"https://api.github.com/repos/minio/minio/assignees{/user}","branches_url":"https://api.github.com/repos/minio/minio/branches{/branch}","tags_url":"https://api.github.com/repos/minio/minio/tags","blobs_url":"https://api.github.com/repos/minio/minio/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/minio/minio/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/minio/minio/git/refs{/sha}","trees_url":"https://api.github.com/repos/minio/minio/git/trees{/sha}","statuses_url":"https://api.github.com/repos/minio/minio/statuses/{sha}","languages_url":"https://api.github.com/repos/minio/minio/languages","stargazers_url":"https://api.github.com/repos/minio/minio/stargazers","contributors_url":"https://api.github.com/repos/minio/minio/contributors","subscribers_url":"https://api.github.com/repos/minio/minio/subscribers","subscription_url":"https://api.github.com/repos/minio/minio/subscription","commits_url":"https://api.github.com/repos/minio/minio/commits{/sha}","git_commits_url":"https://api.github.com/repos/minio/minio/git/commits{/sha}","comments_url":"https://api.github.com/repos/minio/minio/comments{/number}","issue_comment_url":"https://api.github.com/repos/minio/minio/issues/comments{/number}","contents_url":"https://api.github.com/repos/minio/minio/contents/{+path}","compare_url":"https://api.github.com/repos/minio/minio/compare/{base}...{head}","merges_url":"https://api.github.com/repos/minio/minio/merges","archive_url":"https://api.github.com/repos/minio/minio/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/minio/minio/downloads","issues_url":"https://api.github.com/repos/minio/minio/issues{/number}","pulls_url":"https://api.github.com/repos/minio/minio/pulls{/number}","milestones_url":"https://api.github.com/repos/minio/minio/milestones{/number}","notifications_url":"https://api.github.com/repos/minio/minio/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/minio/minio/labels{/name}","releases_url":"https://api.github.com/repos/minio/minio/releases{/id}","deployments_url":"https://api.github.com/repos/minio/minio/deployments","created_at":"2015-01-14T19:23:58Z","updated_at":"2018-06-05T06:19:05Z","pushed_at":"2018-06-05T04:13:01Z","git_url":"git://github.com/minio/minio.git","ssh_url":"git@github.com:minio/minio.git","clone_url":"https://github.com/minio/minio.git","svn_url":"https://github.com/minio/minio","homepage":"https://minio.io/downloads.html#download-server","size":36263,"stargazers_count":11614,"watchers_count":11614,"language":"Go","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":995,"mirror_url":null,"archived":false,"open_issues_count":137,"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":995,"open_issues":137,"watchers":11614,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/minio/minio/pulls/6007"},"html":{"href":"https://github.com/minio/minio/pull/6007"},"issue":{"href":"https://api.github.com/repos/minio/minio/issues/6007"},"comments":{"href":"https://api.github.com/repos/minio/minio/issues/6007/comments"},"review_comments":{"href":"https://api.github.com/repos/minio/minio/pulls/6007/comments"},"review_comment":{"href":"https://api.github.com/repos/minio/minio/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/minio/minio/pulls/6007/commits"},"statuses":{"href":"https://api.github.com/repos/minio/minio/statuses/b8e90023a86466704d947cd16edce887c6ca31eb"}},"author_association":"MEMBER"}}
{"actor":{"display_login":"balamurugana"}}