{"action":"created","comment":{"url":"https://api.github.com/repos/kubernetes/kubernetes/pulls/comments/77917323","id":77917323,"diff_hunk":"@@ -0,0 +1,42 @@\n+/*\n+Copyright 2014 The Kubernetes Authors.\n+\n+Licensed under the Apache License, Version 2.0 (the \"License\");\n+you may not use this file except in compliance with the License.\n+You may obtain a copy of the License at\n+\n+    http://www.apache.org/licenses/LICENSE-2.0\n+\n+Unless required by applicable law or agreed to in writing, software\n+distributed under the License is distributed on an \"AS IS\" BASIS,\n+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n+See the License for the specific language governing permissions and\n+limitations under the License.\n+*/\n+\n+package framework\n+\n+import (\n+\t\"fmt\"\n+\t\"math/rand\"\n+\n+\t\"k8s.io/kubernetes/pkg/storage\"\n+\n+\tconsulapi \"github.com/hashicorp/consul/api\"\n+)\n+\n+var consulClient *consulapi.Client","path":"test/integration/framework/consul_utils.go","position":28,"original_position":28,"commit_id":"7dea1b5cb3e5851df23e1eb433a4d846d1380421","original_commit_id":"fe0897e138623ce4175dba80cf2fb8675ab4433a","user":{"login":"lavalamp","id":647318,"avatar_url":"https://avatars.githubusercontent.com/u/647318?v=3","gravatar_id":"","url":"https://api.github.com/users/lavalamp","html_url":"https://github.com/lavalamp","followers_url":"https://api.github.com/users/lavalamp/followers","following_url":"https://api.github.com/users/lavalamp/following{/other_user}","gists_url":"https://api.github.com/users/lavalamp/gists{/gist_id}","starred_url":"https://api.github.com/users/lavalamp/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lavalamp/subscriptions","organizations_url":"https://api.github.com/users/lavalamp/orgs","repos_url":"https://api.github.com/users/lavalamp/repos","events_url":"https://api.github.com/users/lavalamp/events{/privacy}","received_events_url":"https://api.github.com/users/lavalamp/received_events","type":"User","site_admin":false},"body":"We should not be doing this as a global.","created_at":"2016-09-07T22:37:31Z","updated_at":"2016-09-07T22:37:31Z","html_url":"https://github.com/kubernetes/kubernetes/pull/31622#discussion_r77917323","pull_request_url":"https://api.github.com/repos/kubernetes/kubernetes/pulls/31622","_links":{"self":{"href":"https://api.github.com/repos/kubernetes/kubernetes/pulls/comments/77917323"},"html":{"href":"https://github.com/kubernetes/kubernetes/pull/31622#discussion_r77917323"},"pull_request":{"href":"https://api.github.com/repos/kubernetes/kubernetes/pulls/31622"}}},"pull_request":{"url":"https://api.github.com/repos/kubernetes/kubernetes/pulls/31622","id":83129502,"html_url":"https://github.com/kubernetes/kubernetes/pull/31622","diff_url":"https://github.com/kubernetes/kubernetes/pull/31622.diff","patch_url":"https://github.com/kubernetes/kubernetes/pull/31622.patch","issue_url":"https://api.github.com/repos/kubernetes/kubernetes/issues/31622","number":31622,"state":"open","locked":false,"title":"Add Consul support","user":{"login":"soupdiver","id":800562,"avatar_url":"https://avatars.githubusercontent.com/u/800562?v=3","gravatar_id":"","url":"https://api.github.com/users/soupdiver","html_url":"https://github.com/soupdiver","followers_url":"https://api.github.com/users/soupdiver/followers","following_url":"https://api.github.com/users/soupdiver/following{/other_user}","gists_url":"https://api.github.com/users/soupdiver/gists{/gist_id}","starred_url":"https://api.github.com/users/soupdiver/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/soupdiver/subscriptions","organizations_url":"https://api.github.com/users/soupdiver/orgs","repos_url":"https://api.github.com/users/soupdiver/repos","events_url":"https://api.github.com/users/soupdiver/events{/privacy}","received_events_url":"https://api.github.com/users/soupdiver/received_events","type":"User","site_admin":false},"body":"An earlier discussion about Consul integration can be found here: #28508 \r\n\r\n# Consul support integration\r\nWe worked on getting Consul support into Kubernetes. Our implementation is based on Consul `0.6.4` and should provide the same featureset as the `etcd` implementation does.\r\nTo ensure correct working of the implementation we wrote integration tests which are very similar to the ones for `etcd`.  These can be found at `test/integration/master/consul_tools_test.go\r\nHowever the implementation is not finished yet. Herein after I will address the remaining issue.\r\n\r\n## unit tests\r\nCurrently unit tests, which need to talk to a storage backend, are using the `etcd` implementation directly ([example](https://github.com/kubernetes/kubernetes/tree/master/pkg/registry/deployment/etcd)).\r\n This means the tests can't directly be reused with Consul. We tried to solve this problem by refactoring all the `etcd` specific tests to more generic `storage` tests and also using a factory to create all the available storage backends and run the unit tests against each backend. In the end we had to drop this change because we could not keep up with the frequency of changes in these locations. So for now unit tests don't run against Consul.\r\nWe think this is probably a good discussion point on how to handle multiple storage backends.\r\nThis could be handled in a separate PR to keep the scope smaller for each one.\r\n\r\n### Our test implementation\r\nIn the following are snippets showing how our approach to run the tests for multiple backends looks like.\r\n#### Running tests and creating storage\r\n```\r\nvar factory storagefactory.TestServerFactory\r\n\r\nfunc TestMain(m *testing.M) {\r\n\tstoragefactory.RunTestsForStorageFactories(func(fac storagefactory.TestServerFactory) int {\r\n\t\tfactory = fac\r\n\t\treturn m.Run()\r\n\t})\r\n}\r\n\r\nfunc newStorage(t *testing.T) (*DeploymentStorage, storagefactory.TestClientServer) {\r\n\tinternalStorage, server := registrytest.NewStorage(t, factory, extensions.GroupName)\r\n\trestOptions := generic.RESTOptions{Storage: internalStorage, Decorator: generic.UndecoratedStorage, DeleteCollectionWorkers: 1}\r\n\tdeploymentStorage := NewStorage(restOptions)\r\n\treturn &deploymentStorage, server\r\n}\r\n```\r\n\r\n#### factory\r\n```\r\nfunc RunTestsForStorageFactories(iterFn func(TestServerFactory) int) {\r\n\tFactoryTypesList := os.Getenv(\"KUBE_STORAGE\")\r\n\tif FactoryTypesList == \"\" {\r\n\t\tFactoryTypesList = \"etcd2,consul\"\r\n\t}\r\n\ttypes := strings.Split(FactoryTypesList, \",\")\r\n\tretCodes := make([]int, len(types))\r\n\tfor index, FactoryType := range types {\r\n\t\tfactory, err := GetFactory(FactoryType)\r\n\t\tif err != nil {\r\n\t\t\tfmt.Printf(\"Skipping tests for %s because %v\", FactoryType, err)\r\n\t\t\tretCodes[index] = 1\r\n\t\t\tcontinue \r\n\t\t}\r\n\t\tfmt.Printf(\"Running tests in %s mode\\n\", factory.GetName())\r\n\t\tretCodes[index] = iterFn(factory)\r\n\t}\r\n\tfor _, code := range retCodes {\r\n\t\tif code > 0 {\r\n\t\t\tos.Exit(code)\r\n\t\t}\r\n\t}\r\n\tos.Exit(0)\r\n}\r\n\r\n// Create creates a storage backend based on given config.\r\nfunc GetFactory(Type string) (TestServerFactory, error) {\r\n\tswitch Type {\r\n\tcase storagebackend.StorageTypeUnset, storagebackend.StorageTypeETCD2:\r\n\t\treturn NewETCD2TestServerFactory()\r\n\t//case storagebackend.StorageTypeETCD3:\r\n\t\t// TODO: We have the following features to implement:\r\n\t\t// - Support secure connection by using key, cert, and CA files.\r\n\t\t// - Honor \"https\" scheme to support secure connection in gRPC.\r\n\t\t// - Support non-quorum read.\r\n\t\t//return newETCD3Storage(c, codec)\r\n\tcase storagebackend.StorageTypeConsul:\r\n\t\treturn NewConsulSharedTestServerFactory()\r\n\tdefault:\r\n\t\treturn nil, fmt.Errorf(\"unknown storage type: %s\", Type)\r\n\t}\r\n}\r\n```\n\n<!-- Reviewable:start -->\n---\nThis change is [<img src=\"https://reviewable.kubernetes.io/review_button.svg\" height=\"34\" align=\"absmiddle\" alt=\"Reviewable\"/>](https://reviewable.kubernetes.io/reviews/kubernetes/kubernetes/31622)\n<!-- Reviewable:end -->\n","created_at":"2016-08-29T16:46:17Z","updated_at":"2016-09-07T22:37:31Z","closed_at":null,"merged_at":null,"merge_commit_sha":"05398382c84c817827d52555b33c851b1c574dbd","assignee":{"login":"lavalamp","id":647318,"avatar_url":"https://avatars.githubusercontent.com/u/647318?v=3","gravatar_id":"","url":"https://api.github.com/users/lavalamp","html_url":"https://github.com/lavalamp","followers_url":"https://api.github.com/users/lavalamp/followers","following_url":"https://api.github.com/users/lavalamp/following{/other_user}","gists_url":"https://api.github.com/users/lavalamp/gists{/gist_id}","starred_url":"https://api.github.com/users/lavalamp/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lavalamp/subscriptions","organizations_url":"https://api.github.com/users/lavalamp/orgs","repos_url":"https://api.github.com/users/lavalamp/repos","events_url":"https://api.github.com/users/lavalamp/events{/privacy}","received_events_url":"https://api.github.com/users/lavalamp/received_events","type":"User","site_admin":false},"assignees":[{"login":"lavalamp","id":647318,"avatar_url":"https://avatars.githubusercontent.com/u/647318?v=3","gravatar_id":"","url":"https://api.github.com/users/lavalamp","html_url":"https://github.com/lavalamp","followers_url":"https://api.github.com/users/lavalamp/followers","following_url":"https://api.github.com/users/lavalamp/following{/other_user}","gists_url":"https://api.github.com/users/lavalamp/gists{/gist_id}","starred_url":"https://api.github.com/users/lavalamp/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lavalamp/subscriptions","organizations_url":"https://api.github.com/users/lavalamp/orgs","repos_url":"https://api.github.com/users/lavalamp/repos","events_url":"https://api.github.com/users/lavalamp/events{/privacy}","received_events_url":"https://api.github.com/users/lavalamp/received_events","type":"User","site_admin":false}],"milestone":null,"commits_url":"https://api.github.com/repos/kubernetes/kubernetes/pulls/31622/commits","review_comments_url":"https://api.github.com/repos/kubernetes/kubernetes/pulls/31622/comments","review_comment_url":"https://api.github.com/repos/kubernetes/kubernetes/pulls/comments{/number}","comments_url":"https://api.github.com/repos/kubernetes/kubernetes/issues/31622/comments","statuses_url":"https://api.github.com/repos/kubernetes/kubernetes/statuses/7dea1b5cb3e5851df23e1eb433a4d846d1380421","head":{"label":"MustWin:consul-storage-integration","ref":"consul-storage-integration","sha":"7dea1b5cb3e5851df23e1eb433a4d846d1380421","user":{"login":"MustWin","id":3650631,"avatar_url":"https://avatars.githubusercontent.com/u/3650631?v=3","gravatar_id":"","url":"https://api.github.com/users/MustWin","html_url":"https://github.com/MustWin","followers_url":"https://api.github.com/users/MustWin/followers","following_url":"https://api.github.com/users/MustWin/following{/other_user}","gists_url":"https://api.github.com/users/MustWin/gists{/gist_id}","starred_url":"https://api.github.com/users/MustWin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/MustWin/subscriptions","organizations_url":"https://api.github.com/users/MustWin/orgs","repos_url":"https://api.github.com/users/MustWin/repos","events_url":"https://api.github.com/users/MustWin/events{/privacy}","received_events_url":"https://api.github.com/users/MustWin/received_events","type":"Organization","site_admin":false},"repo":{"id":55523973,"name":"kubernetes","full_name":"MustWin/kubernetes","owner":{"login":"MustWin","id":3650631,"avatar_url":"https://avatars.githubusercontent.com/u/3650631?v=3","gravatar_id":"","url":"https://api.github.com/users/MustWin","html_url":"https://github.com/MustWin","followers_url":"https://api.github.com/users/MustWin/followers","following_url":"https://api.github.com/users/MustWin/following{/other_user}","gists_url":"https://api.github.com/users/MustWin/gists{/gist_id}","starred_url":"https://api.github.com/users/MustWin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/MustWin/subscriptions","organizations_url":"https://api.github.com/users/MustWin/orgs","repos_url":"https://api.github.com/users/MustWin/repos","events_url":"https://api.github.com/users/MustWin/events{/privacy}","received_events_url":"https://api.github.com/users/MustWin/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/MustWin/kubernetes","description":"Container Cluster Manager from Google","fork":true,"url":"https://api.github.com/repos/MustWin/kubernetes","forks_url":"https://api.github.com/repos/MustWin/kubernetes/forks","keys_url":"https://api.github.com/repos/MustWin/kubernetes/keys{/key_id}","collaborators_url":"https://api.github.com/repos/MustWin/kubernetes/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/MustWin/kubernetes/teams","hooks_url":"https://api.github.com/repos/MustWin/kubernetes/hooks","issue_events_url":"https://api.github.com/repos/MustWin/kubernetes/issues/events{/number}","events_url":"https://api.github.com/repos/MustWin/kubernetes/events","assignees_url":"https://api.github.com/repos/MustWin/kubernetes/assignees{/user}","branches_url":"https://api.github.com/repos/MustWin/kubernetes/branches{/branch}","tags_url":"https://api.github.com/repos/MustWin/kubernetes/tags","blobs_url":"https://api.github.com/repos/MustWin/kubernetes/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/MustWin/kubernetes/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/MustWin/kubernetes/git/refs{/sha}","trees_url":"https://api.github.com/repos/MustWin/kubernetes/git/trees{/sha}","statuses_url":"https://api.github.com/repos/MustWin/kubernetes/statuses/{sha}","languages_url":"https://api.github.com/repos/MustWin/kubernetes/languages","stargazers_url":"https://api.github.com/repos/MustWin/kubernetes/stargazers","contributors_url":"https://api.github.com/repos/MustWin/kubernetes/contributors","subscribers_url":"https://api.github.com/repos/MustWin/kubernetes/subscribers","subscription_url":"https://api.github.com/repos/MustWin/kubernetes/subscription","commits_url":"https://api.github.com/repos/MustWin/kubernetes/commits{/sha}","git_commits_url":"https://api.github.com/repos/MustWin/kubernetes/git/commits{/sha}","comments_url":"https://api.github.com/repos/MustWin/kubernetes/comments{/number}","issue_comment_url":"https://api.github.com/repos/MustWin/kubernetes/issues/comments{/number}","contents_url":"https://api.github.com/repos/MustWin/kubernetes/contents/{+path}","compare_url":"https://api.github.com/repos/MustWin/kubernetes/compare/{base}...{head}","merges_url":"https://api.github.com/repos/MustWin/kubernetes/merges","archive_url":"https://api.github.com/repos/MustWin/kubernetes/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/MustWin/kubernetes/downloads","issues_url":"https://api.github.com/repos/MustWin/kubernetes/issues{/number}","pulls_url":"https://api.github.com/repos/MustWin/kubernetes/pulls{/number}","milestones_url":"https://api.github.com/repos/MustWin/kubernetes/milestones{/number}","notifications_url":"https://api.github.com/repos/MustWin/kubernetes/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/MustWin/kubernetes/labels{/name}","releases_url":"https://api.github.com/repos/MustWin/kubernetes/releases{/id}","deployments_url":"https://api.github.com/repos/MustWin/kubernetes/deployments","created_at":"2016-04-05T16:28:32Z","updated_at":"2016-06-09T19:15:03Z","pushed_at":"2016-08-31T14:59:24Z","git_url":"git://github.com/MustWin/kubernetes.git","ssh_url":"git@github.com:MustWin/kubernetes.git","clone_url":"https://github.com/MustWin/kubernetes.git","svn_url":"https://github.com/MustWin/kubernetes","homepage":"http://kubernetes.io","size":319635,"stargazers_count":1,"watchers_count":1,"language":"Go","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":8,"forks":1,"open_issues":8,"watchers":1,"default_branch":"master"}},"base":{"label":"kubernetes:master","ref":"master","sha":"a93b979881ffb113e94ce6d21989d261a696c551","user":{"login":"kubernetes","id":13629408,"avatar_url":"https://avatars.githubusercontent.com/u/13629408?v=3","gravatar_id":"","url":"https://api.github.com/users/kubernetes","html_url":"https://github.com/kubernetes","followers_url":"https://api.github.com/users/kubernetes/followers","following_url":"https://api.github.com/users/kubernetes/following{/other_user}","gists_url":"https://api.github.com/users/kubernetes/gists{/gist_id}","starred_url":"https://api.github.com/users/kubernetes/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kubernetes/subscriptions","organizations_url":"https://api.github.com/users/kubernetes/orgs","repos_url":"https://api.github.com/users/kubernetes/repos","events_url":"https://api.github.com/users/kubernetes/events{/privacy}","received_events_url":"https://api.github.com/users/kubernetes/received_events","type":"Organization","site_admin":false},"repo":{"id":20580498,"name":"kubernetes","full_name":"kubernetes/kubernetes","owner":{"login":"kubernetes","id":13629408,"avatar_url":"https://avatars.githubusercontent.com/u/13629408?v=3","gravatar_id":"","url":"https://api.github.com/users/kubernetes","html_url":"https://github.com/kubernetes","followers_url":"https://api.github.com/users/kubernetes/followers","following_url":"https://api.github.com/users/kubernetes/following{/other_user}","gists_url":"https://api.github.com/users/kubernetes/gists{/gist_id}","starred_url":"https://api.github.com/users/kubernetes/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kubernetes/subscriptions","organizations_url":"https://api.github.com/users/kubernetes/orgs","repos_url":"https://api.github.com/users/kubernetes/repos","events_url":"https://api.github.com/users/kubernetes/events{/privacy}","received_events_url":"https://api.github.com/users/kubernetes/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/kubernetes/kubernetes","description":"Production-Grade Container Scheduling and Management","fork":false,"url":"https://api.github.com/repos/kubernetes/kubernetes","forks_url":"https://api.github.com/repos/kubernetes/kubernetes/forks","keys_url":"https://api.github.com/repos/kubernetes/kubernetes/keys{/key_id}","collaborators_url":"https://api.github.com/repos/kubernetes/kubernetes/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/kubernetes/kubernetes/teams","hooks_url":"https://api.github.com/repos/kubernetes/kubernetes/hooks","issue_events_url":"https://api.github.com/repos/kubernetes/kubernetes/issues/events{/number}","events_url":"https://api.github.com/repos/kubernetes/kubernetes/events","assignees_url":"https://api.github.com/repos/kubernetes/kubernetes/assignees{/user}","branches_url":"https://api.github.com/repos/kubernetes/kubernetes/branches{/branch}","tags_url":"https://api.github.com/repos/kubernetes/kubernetes/tags","blobs_url":"https://api.github.com/repos/kubernetes/kubernetes/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/kubernetes/kubernetes/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/kubernetes/kubernetes/git/refs{/sha}","trees_url":"https://api.github.com/repos/kubernetes/kubernetes/git/trees{/sha}","statuses_url":"https://api.github.com/repos/kubernetes/kubernetes/statuses/{sha}","languages_url":"https://api.github.com/repos/kubernetes/kubernetes/languages","stargazers_url":"https://api.github.com/repos/kubernetes/kubernetes/stargazers","contributors_url":"https://api.github.com/repos/kubernetes/kubernetes/contributors","subscribers_url":"https://api.github.com/repos/kubernetes/kubernetes/subscribers","subscription_url":"https://api.github.com/repos/kubernetes/kubernetes/subscription","commits_url":"https://api.github.com/repos/kubernetes/kubernetes/commits{/sha}","git_commits_url":"https://api.github.com/repos/kubernetes/kubernetes/git/commits{/sha}","comments_url":"https://api.github.com/repos/kubernetes/kubernetes/comments{/number}","issue_comment_url":"https://api.github.com/repos/kubernetes/kubernetes/issues/comments{/number}","contents_url":"https://api.github.com/repos/kubernetes/kubernetes/contents/{+path}","compare_url":"https://api.github.com/repos/kubernetes/kubernetes/compare/{base}...{head}","merges_url":"https://api.github.com/repos/kubernetes/kubernetes/merges","archive_url":"https://api.github.com/repos/kubernetes/kubernetes/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/kubernetes/kubernetes/downloads","issues_url":"https://api.github.com/repos/kubernetes/kubernetes/issues{/number}","pulls_url":"https://api.github.com/repos/kubernetes/kubernetes/pulls{/number}","milestones_url":"https://api.github.com/repos/kubernetes/kubernetes/milestones{/number}","notifications_url":"https://api.github.com/repos/kubernetes/kubernetes/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/kubernetes/kubernetes/labels{/name}","releases_url":"https://api.github.com/repos/kubernetes/kubernetes/releases{/id}","deployments_url":"https://api.github.com/repos/kubernetes/kubernetes/deployments","created_at":"2014-06-06T22:56:04Z","updated_at":"2016-09-07T21:03:13Z","pushed_at":"2016-09-07T22:27:41Z","git_url":"git://github.com/kubernetes/kubernetes.git","ssh_url":"git@github.com:kubernetes/kubernetes.git","clone_url":"https://github.com/kubernetes/kubernetes.git","svn_url":"https://github.com/kubernetes/kubernetes","homepage":"http://kubernetes.io","size":558399,"stargazers_count":16582,"watchers_count":16582,"language":"Go","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":5349,"mirror_url":null,"open_issues_count":4421,"forks":5349,"open_issues":4421,"watchers":16582,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/kubernetes/kubernetes/pulls/31622"},"html":{"href":"https://github.com/kubernetes/kubernetes/pull/31622"},"issue":{"href":"https://api.github.com/repos/kubernetes/kubernetes/issues/31622"},"comments":{"href":"https://api.github.com/repos/kubernetes/kubernetes/issues/31622/comments"},"review_comments":{"href":"https://api.github.com/repos/kubernetes/kubernetes/pulls/31622/comments"},"review_comment":{"href":"https://api.github.com/repos/kubernetes/kubernetes/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/kubernetes/kubernetes/pulls/31622/commits"},"statuses":{"href":"https://api.github.com/repos/kubernetes/kubernetes/statuses/7dea1b5cb3e5851df23e1eb433a4d846d1380421"}}}}
{"actor":{"display_login":"lavalamp"}}