{"action":"created","issue":{"url":"https://api.github.com/repos/chef/chef/issues/3575","labels_url":"https://api.github.com/repos/chef/chef/issues/3575/labels{/name}","comments_url":"https://api.github.com/repos/chef/chef/issues/3575/comments","events_url":"https://api.github.com/repos/chef/chef/issues/3575/events","html_url":"https://github.com/chef/chef/issues/3575","id":90462454,"number":3575,"title":"Firing notifies from within an inline'd LWRP provider.","user":{"login":"docwhat","id":40799,"avatar_url":"https://avatars.githubusercontent.com/u/40799?v=3","gravatar_id":"","url":"https://api.github.com/users/docwhat","html_url":"https://github.com/docwhat","followers_url":"https://api.github.com/users/docwhat/followers","following_url":"https://api.github.com/users/docwhat/following{/other_user}","gists_url":"https://api.github.com/users/docwhat/gists{/gist_id}","starred_url":"https://api.github.com/users/docwhat/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/docwhat/subscriptions","organizations_url":"https://api.github.com/users/docwhat/orgs","repos_url":"https://api.github.com/users/docwhat/repos","events_url":"https://api.github.com/users/docwhat/events{/privacy}","received_events_url":"https://api.github.com/users/docwhat/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":16,"created_at":"2015-06-23T18:48:08Z","updated_at":"2015-07-13T20:09:08Z","closed_at":"2015-06-25T01:25:55Z","body":"Currently, it is impossible to do this:\r\n\r\n```\r\n# recipes/default.rb\r\n\r\nservice 'foo'\r\n```\r\n\r\n```\r\n# provider/myprovider.rb\r\nuse_inline_resources\r\n\r\naction :something do\r\n  file '/tmp/foo' do\r\n    notifies :restart, 'service[foo]'\r\n  end\r\nend\r\n```\r\n\r\nIt returns an error because it cannot find the resource `service[foo]` because the LWRP provider runs in a temporary `run_context`, not the `saved_run_context` or the \"parent\" run_context.\r\n\r\nI feel like this should be able to notify/subscribe \"up\" (e.g. to parent `run_context`s), but not down (e.g. into the resources *hidden* by an LWRP).\r\n\r\nIf I'm going about this wrong, please tell me.  Initially, this seemed like the \"correct\" thing to do; then I dug around the code and realized what was going on.\r\n\r\nSuggestion:\r\n\r\nPerhaps change [lwrp_base.rb`'s line 59](https://github.com/chef/chef/blob/master/lib/chef/provider/lwrp_base.rb#L59) like so:\r\n\r\n```\r\ndiff --git a/lib/chef/provider/lwrp_base.rb b/lib/chef/provider/lwrp_base.rb\r\nindex b5efbb2..d434a49 100644\r\n--- a/lib/chef/provider/lwrp_base.rb\r\n+++ b/lib/chef/provider/lwrp_base.rb\r\n@@ -56,7 +56,7 @@ def recipe_eval_with_update_check(&block)\r\n           saved_run_context = @run_context\r\n           temp_run_context = @run_context.dup\r\n           @run_context = temp_run_context\r\n-          @run_context.resource_collection = Chef::ResourceCollection.new\r\n+          @run_context.resource_collection = saved_run_context.resource_collection\r\n\r\n           return_value = instance_eval(&block)\r\n           Chef::Runner.new(@run_context).converge\r\n```\r\n\r\nThough thinking about, I think we want a *copy* of the `resource_collection`, not the actual `resource_collection` from the parent. Otherwise you'd get a loop or something. :-/"},"comment":{"url":"https://api.github.com/repos/chef/chef/issues/comments/121039935","html_url":"https://github.com/chef/chef/issues/3575#issuecomment-121039935","issue_url":"https://api.github.com/repos/chef/chef/issues/3575","id":121039935,"user":{"login":"lamont-granquist","id":454857,"avatar_url":"https://avatars.githubusercontent.com/u/454857?v=3","gravatar_id":"","url":"https://api.github.com/users/lamont-granquist","html_url":"https://github.com/lamont-granquist","followers_url":"https://api.github.com/users/lamont-granquist/followers","following_url":"https://api.github.com/users/lamont-granquist/following{/other_user}","gists_url":"https://api.github.com/users/lamont-granquist/gists{/gist_id}","starred_url":"https://api.github.com/users/lamont-granquist/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lamont-granquist/subscriptions","organizations_url":"https://api.github.com/users/lamont-granquist/orgs","repos_url":"https://api.github.com/users/lamont-granquist/repos","events_url":"https://api.github.com/users/lamont-granquist/events{/privacy}","received_events_url":"https://api.github.com/users/lamont-granquist/received_events","type":"User","site_admin":false},"created_at":"2015-07-13T20:09:08Z","updated_at":"2015-07-13T20:09:08Z","body":"what is wrong with hanging the delayed notification off of the RP call rather than internal to RP?  if you just don't like typing the notification line all the time, wrap it with a definition to avoid having to type it all the time.  that keeps the runit_service in the main run_context along with the RPs and all the notifications.  then internal to the RPs you don't worry about notifications.\r\n\r\nand if there's problems caused by using definitions to do compile-time \"macro preprocessing\" then we should fix that use case, or maybe create some way to inject a default notification into an RP that you write just like default resource property values."}}