{"action":"created","issue":{"url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/issues/5548","labels_url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/issues/5548/labels{/name}","comments_url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/issues/5548/comments","events_url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/issues/5548/events","html_url":"https://github.com/GoogleCloudPlatform/kubernetes/issues/5548","id":62422698,"number":5548,"title":"cache selector result in etcd","user":{"login":"xudifsd","id":665253,"avatar_url":"https://avatars.githubusercontent.com/u/665253?v=3","gravatar_id":"","url":"https://api.github.com/users/xudifsd","html_url":"https://github.com/xudifsd","followers_url":"https://api.github.com/users/xudifsd/followers","following_url":"https://api.github.com/users/xudifsd/following{/other_user}","gists_url":"https://api.github.com/users/xudifsd/gists{/gist_id}","starred_url":"https://api.github.com/users/xudifsd/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/xudifsd/subscriptions","organizations_url":"https://api.github.com/users/xudifsd/orgs","repos_url":"https://api.github.com/users/xudifsd/repos","events_url":"https://api.github.com/users/xudifsd/events{/privacy}","received_events_url":"https://api.github.com/users/xudifsd/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/labels/priority/design","name":"priority/design","color":"c7def8"},{"url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/labels/team/master","name":"team/master","color":"d2b48c"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":25,"created_at":"2015-03-17T15:10:16Z","updated_at":"2015-03-20T11:41:12Z","closed_at":null,"body":"This is a proposal to implement caching selector result. https://github.com/GoogleCloudPlatform/kubernetes/issues/4817#issuecomment-76495394\r\n\r\nAFAIK, currently only [two components](https://github.com/GoogleCloudPlatform/kubernetes/blob/master/docs/labels.md#api) use selector to group their members: `service` and `replicationController`, and they get list of their members by matching seletor against all pods' label every time.\r\n\r\nHere I propose a way to cache seletor result in etcd.\r\n\r\nDefine a new registry in etcd: selector.\r\n\r\nWhenever a `service` or `replicationController` is created, generate [uid](https://github.com/GoogleCloudPlatform/kubernetes/blob/master/docs/identifiers.md#uids) for its selector, and register selector with that uid in etcd. While creating `service` or `replicationController`, it watches that selector in etcd to wait updates on result of selector. We should add pre-existed matched pods to its result of course.\r\n\r\nAnd whenever a `pod` is created, matches its label with all selector under its namespace (assuming we forbidden selector select object in another ns, which I not quite sure), and add that pod to selector result if match. Update or delete a `pod` should also update all selectors' result under its ns.\r\n\r\nWhen a `selector` and `pod` is created at same time, we should use some kind of mutex to avoid race condition.\r\n\r\nAny comment?"},"comment":{"url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/issues/comments/83991428","html_url":"https://github.com/GoogleCloudPlatform/kubernetes/issues/5548#issuecomment-83991428","issue_url":"https://api.github.com/repos/GoogleCloudPlatform/kubernetes/issues/5548","id":83991428,"user":{"login":"derekwaynecarr","id":6233452,"avatar_url":"https://avatars.githubusercontent.com/u/6233452?v=3","gravatar_id":"","url":"https://api.github.com/users/derekwaynecarr","html_url":"https://github.com/derekwaynecarr","followers_url":"https://api.github.com/users/derekwaynecarr/followers","following_url":"https://api.github.com/users/derekwaynecarr/following{/other_user}","gists_url":"https://api.github.com/users/derekwaynecarr/gists{/gist_id}","starred_url":"https://api.github.com/users/derekwaynecarr/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/derekwaynecarr/subscriptions","organizations_url":"https://api.github.com/users/derekwaynecarr/orgs","repos_url":"https://api.github.com/users/derekwaynecarr/repos","events_url":"https://api.github.com/users/derekwaynecarr/events{/privacy}","received_events_url":"https://api.github.com/users/derekwaynecarr/received_events","type":"User","site_admin":false},"created_at":"2015-03-20T11:41:12Z","updated_at":"2015-03-20T11:41:12Z","body":"I am for the latter, and we have a solution today to index the data in the latter form using cache.Store and cache.Indexer \r\n\r\nThere is no call in etcd that lets you get N objects in a single request by passing N keys. \r\n\r\nSent from my iPhone\r\n\r\n> On Mar 20, 2015, at 4:29 AM, gmarek <notifications@github.com> wrote:\r\n> \r\n> I'm slightly worried by mixing terms 'index' and 'cache'. For me former means keeping indexed labels in memory and reading full data from etcd (I believe labels will be changing far less often than other 'content'), while the latter means keeping in-memory copy of whole etcd and serving results from it.\r\n> \r\n> —\r\n> Reply to this email directly or view it on GitHub.\r\n> \r\n"}}