{"action":"created","comment":{"url":"https://api.github.com/repos/crowbar/crowbar-core/pulls/comments/112402030","pull_request_review_id":33712495,"id":112402030,"diff_hunk":"@@ -68,6 +68,13 @@ def increment_crowbar_revision!\n     else\n       item[\"deployment\"][self.barclamp][\"crowbar-revision\"] += 1\n     end\n+    # The domain attribute of the dns barclamp is needed when looking up a Node.\n+    # We don't want to go to the database every time we need it since that will\n+    # be many times per second, but nor can we statically record it since it may\n+    # change. Instead we use Rails' caching mechanism to store the new revision,\n+    # and when we look it up elsewhere we first check the revision to see if the\n+    # barclamp has been updated and we require a trip to the database.\n+    cache_crowbar_revision if barclamp == 'dns'","path":"crowbar_framework/app/models/proposal.rb","position":10,"original_position":10,"commit_id":"29b15698090f4f839cc7cb2b9b08d567921b8635","original_commit_id":"29b15698090f4f839cc7cb2b9b08d567921b8635","user":{"login":"jsuchome","id":910000,"avatar_url":"https://avatars1.githubusercontent.com/u/910000?v=3","gravatar_id":"","url":"https://api.github.com/users/jsuchome","html_url":"https://github.com/jsuchome","followers_url":"https://api.github.com/users/jsuchome/followers","following_url":"https://api.github.com/users/jsuchome/following{/other_user}","gists_url":"https://api.github.com/users/jsuchome/gists{/gist_id}","starred_url":"https://api.github.com/users/jsuchome/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jsuchome/subscriptions","organizations_url":"https://api.github.com/users/jsuchome/orgs","repos_url":"https://api.github.com/users/jsuchome/repos","events_url":"https://api.github.com/users/jsuchome/events{/privacy}","received_events_url":"https://api.github.com/users/jsuchome/received_events","type":"User","site_admin":false},"body":"Wouldn't it be possible to cache the revision from `dns_service.rb` to avoid this barclamp specific action?","created_at":"2017-04-20T09:05:49Z","updated_at":"2017-04-20T09:05:49Z","html_url":"https://github.com/crowbar/crowbar-core/pull/1218#discussion_r112402030","pull_request_url":"https://api.github.com/repos/crowbar/crowbar-core/pulls/1218","_links":{"self":{"href":"https://api.github.com/repos/crowbar/crowbar-core/pulls/comments/112402030"},"html":{"href":"https://github.com/crowbar/crowbar-core/pull/1218#discussion_r112402030"},"pull_request":{"href":"https://api.github.com/repos/crowbar/crowbar-core/pulls/1218"}}},"pull_request":{"url":"https://api.github.com/repos/crowbar/crowbar-core/pulls/1218","id":116719378,"html_url":"https://github.com/crowbar/crowbar-core/pull/1218","diff_url":"https://github.com/crowbar/crowbar-core/pull/1218.diff","patch_url":"https://github.com/crowbar/crowbar-core/pull/1218.patch","issue_url":"https://api.github.com/repos/crowbar/crowbar-core/issues/1218","number":1218,"state":"open","locked":false,"title":"bsc#1033537: Fix domain caching","user":{"login":"cmurphy","id":1220710,"avatar_url":"https://avatars0.githubusercontent.com/u/1220710?v=3","gravatar_id":"","url":"https://api.github.com/users/cmurphy","html_url":"https://github.com/cmurphy","followers_url":"https://api.github.com/users/cmurphy/followers","following_url":"https://api.github.com/users/cmurphy/following{/other_user}","gists_url":"https://api.github.com/users/cmurphy/gists{/gist_id}","starred_url":"https://api.github.com/users/cmurphy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cmurphy/subscriptions","organizations_url":"https://api.github.com/users/cmurphy/orgs","repos_url":"https://api.github.com/users/cmurphy/repos","events_url":"https://api.github.com/users/cmurphy/events{/privacy}","received_events_url":"https://api.github.com/users/cmurphy/received_events","type":"User","site_admin":false},"body":"The Node model goes through Crowbar::Settings to get the domain name of\r\na node. Without this patch, Crowbar::Settings will use the domain\r\nattribute of the dns barclamp and, to avoid repeated database queries,\r\nstore it permanently as a class variable. This is a problem because if\r\nthe domain attribute is changed in the dns barclamp, the change will not\r\nbe reflected in the Node model, which means that if a node is removed\r\nand re-added, its new domain name will be properly reflected in Chef but\r\ncrowbar will respond with an HTTP 404 Not Found when a node is queried.\r\n\r\nThis \"caching\" strategy has been part of the code apparently since the\r\nbeginning of time[1] and it's unclear what the performance gain was\r\nthought to be at the time, so one might think that a reasonable option\r\nto fix this would be to undo the \"caching\" strategy and simply query the\r\nProposal relation when the domain needs to be fetched. However, this is\r\nnot reasonable because the crowbar dashboard UI queries the node list\r\nevery few seconds and this causes a lookup of the domain for each node,\r\nso with a reasonably large number of nodes this would easily overload\r\nthe database server. Rails' own SQL caching mechanism is not sufficient\r\nhere because query caches are destroyed at the end of an action[2].\r\n\r\nThis patch solves the problem by writing the proposal revision number\r\nto Rails' cache when the dns barclamp is updated, and storing both the\r\nrevision number and the domain attribute as a class variable in the\r\nCrowbar::Settings class. The Crowbar::Settings class then queries the\r\nRails cache to see if the dns proposal has been updated, and if so\r\nupdates its copy of the domain attribute. This way we avoid repeated\r\ntrips to the database but changes to the proposal will be propogated.\r\n\r\n[1] https://github.com/crowbar/crowbar/commit/f95325fc7ec27a2c8ed4a184eca95af8f428ac3d\r\n[2] http://guides.rubyonrails.org/caching_with_rails.html#sql-caching","created_at":"2017-04-20T08:45:48Z","updated_at":"2017-04-20T09:05:49Z","closed_at":null,"merged_at":null,"merge_commit_sha":"7f331915983a39648750fbcfcf5a5abe4d58b021","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/crowbar/crowbar-core/pulls/1218/commits","review_comments_url":"https://api.github.com/repos/crowbar/crowbar-core/pulls/1218/comments","review_comment_url":"https://api.github.com/repos/crowbar/crowbar-core/pulls/comments{/number}","comments_url":"https://api.github.com/repos/crowbar/crowbar-core/issues/1218/comments","statuses_url":"https://api.github.com/repos/crowbar/crowbar-core/statuses/29b15698090f4f839cc7cb2b9b08d567921b8635","head":{"label":"cmurphy:domain_caching_alt","ref":"domain_caching_alt","sha":"29b15698090f4f839cc7cb2b9b08d567921b8635","user":{"login":"cmurphy","id":1220710,"avatar_url":"https://avatars0.githubusercontent.com/u/1220710?v=3","gravatar_id":"","url":"https://api.github.com/users/cmurphy","html_url":"https://github.com/cmurphy","followers_url":"https://api.github.com/users/cmurphy/followers","following_url":"https://api.github.com/users/cmurphy/following{/other_user}","gists_url":"https://api.github.com/users/cmurphy/gists{/gist_id}","starred_url":"https://api.github.com/users/cmurphy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cmurphy/subscriptions","organizations_url":"https://api.github.com/users/cmurphy/orgs","repos_url":"https://api.github.com/users/cmurphy/repos","events_url":"https://api.github.com/users/cmurphy/events{/privacy}","received_events_url":"https://api.github.com/users/cmurphy/received_events","type":"User","site_admin":false},"repo":{"id":81552693,"name":"crowbar-core","full_name":"cmurphy/crowbar-core","owner":{"login":"cmurphy","id":1220710,"avatar_url":"https://avatars0.githubusercontent.com/u/1220710?v=3","gravatar_id":"","url":"https://api.github.com/users/cmurphy","html_url":"https://github.com/cmurphy","followers_url":"https://api.github.com/users/cmurphy/followers","following_url":"https://api.github.com/users/cmurphy/following{/other_user}","gists_url":"https://api.github.com/users/cmurphy/gists{/gist_id}","starred_url":"https://api.github.com/users/cmurphy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cmurphy/subscriptions","organizations_url":"https://api.github.com/users/cmurphy/orgs","repos_url":"https://api.github.com/users/cmurphy/repos","events_url":"https://api.github.com/users/cmurphy/events{/privacy}","received_events_url":"https://api.github.com/users/cmurphy/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/cmurphy/crowbar-core","description":"Core deployment for Crowbar","fork":true,"url":"https://api.github.com/repos/cmurphy/crowbar-core","forks_url":"https://api.github.com/repos/cmurphy/crowbar-core/forks","keys_url":"https://api.github.com/repos/cmurphy/crowbar-core/keys{/key_id}","collaborators_url":"https://api.github.com/repos/cmurphy/crowbar-core/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/cmurphy/crowbar-core/teams","hooks_url":"https://api.github.com/repos/cmurphy/crowbar-core/hooks","issue_events_url":"https://api.github.com/repos/cmurphy/crowbar-core/issues/events{/number}","events_url":"https://api.github.com/repos/cmurphy/crowbar-core/events","assignees_url":"https://api.github.com/repos/cmurphy/crowbar-core/assignees{/user}","branches_url":"https://api.github.com/repos/cmurphy/crowbar-core/branches{/branch}","tags_url":"https://api.github.com/repos/cmurphy/crowbar-core/tags","blobs_url":"https://api.github.com/repos/cmurphy/crowbar-core/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/cmurphy/crowbar-core/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/cmurphy/crowbar-core/git/refs{/sha}","trees_url":"https://api.github.com/repos/cmurphy/crowbar-core/git/trees{/sha}","statuses_url":"https://api.github.com/repos/cmurphy/crowbar-core/statuses/{sha}","languages_url":"https://api.github.com/repos/cmurphy/crowbar-core/languages","stargazers_url":"https://api.github.com/repos/cmurphy/crowbar-core/stargazers","contributors_url":"https://api.github.com/repos/cmurphy/crowbar-core/contributors","subscribers_url":"https://api.github.com/repos/cmurphy/crowbar-core/subscribers","subscription_url":"https://api.github.com/repos/cmurphy/crowbar-core/subscription","commits_url":"https://api.github.com/repos/cmurphy/crowbar-core/commits{/sha}","git_commits_url":"https://api.github.com/repos/cmurphy/crowbar-core/git/commits{/sha}","comments_url":"https://api.github.com/repos/cmurphy/crowbar-core/comments{/number}","issue_comment_url":"https://api.github.com/repos/cmurphy/crowbar-core/issues/comments{/number}","contents_url":"https://api.github.com/repos/cmurphy/crowbar-core/contents/{+path}","compare_url":"https://api.github.com/repos/cmurphy/crowbar-core/compare/{base}...{head}","merges_url":"https://api.github.com/repos/cmurphy/crowbar-core/merges","archive_url":"https://api.github.com/repos/cmurphy/crowbar-core/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/cmurphy/crowbar-core/downloads","issues_url":"https://api.github.com/repos/cmurphy/crowbar-core/issues{/number}","pulls_url":"https://api.github.com/repos/cmurphy/crowbar-core/pulls{/number}","milestones_url":"https://api.github.com/repos/cmurphy/crowbar-core/milestones{/number}","notifications_url":"https://api.github.com/repos/cmurphy/crowbar-core/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/cmurphy/crowbar-core/labels{/name}","releases_url":"https://api.github.com/repos/cmurphy/crowbar-core/releases{/id}","deployments_url":"https://api.github.com/repos/cmurphy/crowbar-core/deployments","created_at":"2017-02-10T10:05:39Z","updated_at":"2017-02-10T10:05:43Z","pushed_at":"2017-04-20T09:05:21Z","git_url":"git://github.com/cmurphy/crowbar-core.git","ssh_url":"git@github.com:cmurphy/crowbar-core.git","clone_url":"https://github.com/cmurphy/crowbar-core.git","svn_url":"https://github.com/cmurphy/crowbar-core","homepage":null,"size":108022,"stargazers_count":0,"watchers_count":0,"language":"Ruby","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"crowbar:master","ref":"master","sha":"0baf5b37df31d7e509e6d641253319a2ff607279","user":{"login":"crowbar","id":2910205,"avatar_url":"https://avatars1.githubusercontent.com/u/2910205?v=3","gravatar_id":"","url":"https://api.github.com/users/crowbar","html_url":"https://github.com/crowbar","followers_url":"https://api.github.com/users/crowbar/followers","following_url":"https://api.github.com/users/crowbar/following{/other_user}","gists_url":"https://api.github.com/users/crowbar/gists{/gist_id}","starred_url":"https://api.github.com/users/crowbar/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/crowbar/subscriptions","organizations_url":"https://api.github.com/users/crowbar/orgs","repos_url":"https://api.github.com/users/crowbar/repos","events_url":"https://api.github.com/users/crowbar/events{/privacy}","received_events_url":"https://api.github.com/users/crowbar/received_events","type":"Organization","site_admin":false},"repo":{"id":39003227,"name":"crowbar-core","full_name":"crowbar/crowbar-core","owner":{"login":"crowbar","id":2910205,"avatar_url":"https://avatars1.githubusercontent.com/u/2910205?v=3","gravatar_id":"","url":"https://api.github.com/users/crowbar","html_url":"https://github.com/crowbar","followers_url":"https://api.github.com/users/crowbar/followers","following_url":"https://api.github.com/users/crowbar/following{/other_user}","gists_url":"https://api.github.com/users/crowbar/gists{/gist_id}","starred_url":"https://api.github.com/users/crowbar/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/crowbar/subscriptions","organizations_url":"https://api.github.com/users/crowbar/orgs","repos_url":"https://api.github.com/users/crowbar/repos","events_url":"https://api.github.com/users/crowbar/events{/privacy}","received_events_url":"https://api.github.com/users/crowbar/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/crowbar/crowbar-core","description":"Core deployment for Crowbar","fork":false,"url":"https://api.github.com/repos/crowbar/crowbar-core","forks_url":"https://api.github.com/repos/crowbar/crowbar-core/forks","keys_url":"https://api.github.com/repos/crowbar/crowbar-core/keys{/key_id}","collaborators_url":"https://api.github.com/repos/crowbar/crowbar-core/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/crowbar/crowbar-core/teams","hooks_url":"https://api.github.com/repos/crowbar/crowbar-core/hooks","issue_events_url":"https://api.github.com/repos/crowbar/crowbar-core/issues/events{/number}","events_url":"https://api.github.com/repos/crowbar/crowbar-core/events","assignees_url":"https://api.github.com/repos/crowbar/crowbar-core/assignees{/user}","branches_url":"https://api.github.com/repos/crowbar/crowbar-core/branches{/branch}","tags_url":"https://api.github.com/repos/crowbar/crowbar-core/tags","blobs_url":"https://api.github.com/repos/crowbar/crowbar-core/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/crowbar/crowbar-core/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/crowbar/crowbar-core/git/refs{/sha}","trees_url":"https://api.github.com/repos/crowbar/crowbar-core/git/trees{/sha}","statuses_url":"https://api.github.com/repos/crowbar/crowbar-core/statuses/{sha}","languages_url":"https://api.github.com/repos/crowbar/crowbar-core/languages","stargazers_url":"https://api.github.com/repos/crowbar/crowbar-core/stargazers","contributors_url":"https://api.github.com/repos/crowbar/crowbar-core/contributors","subscribers_url":"https://api.github.com/repos/crowbar/crowbar-core/subscribers","subscription_url":"https://api.github.com/repos/crowbar/crowbar-core/subscription","commits_url":"https://api.github.com/repos/crowbar/crowbar-core/commits{/sha}","git_commits_url":"https://api.github.com/repos/crowbar/crowbar-core/git/commits{/sha}","comments_url":"https://api.github.com/repos/crowbar/crowbar-core/comments{/number}","issue_comment_url":"https://api.github.com/repos/crowbar/crowbar-core/issues/comments{/number}","contents_url":"https://api.github.com/repos/crowbar/crowbar-core/contents/{+path}","compare_url":"https://api.github.com/repos/crowbar/crowbar-core/compare/{base}...{head}","merges_url":"https://api.github.com/repos/crowbar/crowbar-core/merges","archive_url":"https://api.github.com/repos/crowbar/crowbar-core/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/crowbar/crowbar-core/downloads","issues_url":"https://api.github.com/repos/crowbar/crowbar-core/issues{/number}","pulls_url":"https://api.github.com/repos/crowbar/crowbar-core/pulls{/number}","milestones_url":"https://api.github.com/repos/crowbar/crowbar-core/milestones{/number}","notifications_url":"https://api.github.com/repos/crowbar/crowbar-core/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/crowbar/crowbar-core/labels{/name}","releases_url":"https://api.github.com/repos/crowbar/crowbar-core/releases{/id}","deployments_url":"https://api.github.com/repos/crowbar/crowbar-core/deployments","created_at":"2015-07-13T09:31:28Z","updated_at":"2017-04-12T10:15:20Z","pushed_at":"2017-04-20T09:05:22Z","git_url":"git://github.com/crowbar/crowbar-core.git","ssh_url":"git@github.com:crowbar/crowbar-core.git","clone_url":"https://github.com/crowbar/crowbar-core.git","svn_url":"https://github.com/crowbar/crowbar-core","homepage":null,"size":108181,"stargazers_count":10,"watchers_count":10,"language":"Ruby","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":42,"mirror_url":null,"open_issues_count":42,"forks":42,"open_issues":42,"watchers":10,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/crowbar/crowbar-core/pulls/1218"},"html":{"href":"https://github.com/crowbar/crowbar-core/pull/1218"},"issue":{"href":"https://api.github.com/repos/crowbar/crowbar-core/issues/1218"},"comments":{"href":"https://api.github.com/repos/crowbar/crowbar-core/issues/1218/comments"},"review_comments":{"href":"https://api.github.com/repos/crowbar/crowbar-core/pulls/1218/comments"},"review_comment":{"href":"https://api.github.com/repos/crowbar/crowbar-core/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/crowbar/crowbar-core/pulls/1218/commits"},"statuses":{"href":"https://api.github.com/repos/crowbar/crowbar-core/statuses/29b15698090f4f839cc7cb2b9b08d567921b8635"}}}}
{"actor":{"display_login":"jsuchome"}}