{"action":"created","comment":{"url":"https://api.github.com/repos/kubernetes/kubernetes/pulls/comments/54177341","id":54177341,"diff_hunk":"@@ -1894,31 +1901,44 @@ func (s *AWSCloud) listPublicSubnetIDsinVPC(vpcId string) ([]string, error) {\n \treturn subnetIds, nil\n }\n \n-func isSubnetPublic(rt []*ec2.RouteTable, subnetID string) bool {\n+func isSubnetPublic(rt []*ec2.RouteTable, subnetID string) (bool, error) {\n+\tvar mainVpcTable *ec2.RouteTable\n \tfor _, table := range rt {\n-\t\tvar found bool\n \t\tfor _, assoc := range table.Associations {\n-\t\t\tif aws.StringValue(assoc.SubnetId) == subnetID {\n-\t\t\t\tfound = true\n+\t\t\tif aws.BoolValue(assoc.Main) == true {\n+\t\t\t\tmainVpcTable = table\n \t\t\t\tbreak\n \t\t\t}\n \t\t}\n-\t\tif !found {\n-\t\t\tcontinue\n-\t\t}\n-\t\tfor _, route := range table.Routes {\n-\t\t\t// There is no direct way in the AWS API to determine if a subnet is public or private.\n-\t\t\t// A public subnet is one which has an internet gateway route\n-\t\t\t// we look for the gatewayId and make sure it has the prefix of igw to differentiate\n-\t\t\t// from the default in-subnet route which is called \"local\"\n-\t\t\t// or other virtual gateway (starting with vgv)\n-\t\t\t// or vpc peering connections (starting with pcx).\n-\t\t\tif strings.HasPrefix(aws.StringValue(route.GatewayId), \"igw\") {\n-\t\t\t\treturn true\n+\t}\n+\n+\tif mainVpcTable == nil {\n+\t\treturn false, fmt.Errorf(\"Could not locate main routing table\")\n+\t}\n+\n+\tsubnetTable := mainVpcTable","path":"pkg/cloudprovider/providers/aws/aws.go","position":90,"original_position":90,"commit_id":"a64cd9f741dc3614c7f308242c8b79645cc76978","original_commit_id":"a64cd9f741dc3614c7f308242c8b79645cc76978","user":{"login":"justinsb","id":100893,"avatar_url":"https://avatars.githubusercontent.com/u/100893?v=3","gravatar_id":"","url":"https://api.github.com/users/justinsb","html_url":"https://github.com/justinsb","followers_url":"https://api.github.com/users/justinsb/followers","following_url":"https://api.github.com/users/justinsb/following{/other_user}","gists_url":"https://api.github.com/users/justinsb/gists{/gist_id}","starred_url":"https://api.github.com/users/justinsb/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/justinsb/subscriptions","organizations_url":"https://api.github.com/users/justinsb/orgs","repos_url":"https://api.github.com/users/justinsb/repos","events_url":"https://api.github.com/users/justinsb/events{/privacy}","received_events_url":"https://api.github.com/users/justinsb/received_events","type":"User","site_admin":false},"body":"My personal preference would be to not return error if we can't find the main table, unless we need it.\r\n\r\nAlso I would set subnetTable to nil, then look for a match, then if we don't find it explicitly default to the main table, while also having a comment about the fact that this is how AWS associations work, maybe even glog.V(4).Infof as well or similar.\r\n\r\nBut this doesn't really matter - just my personal taste...","created_at":"2016-02-25T22:36:50Z","updated_at":"2016-02-25T22:36:50Z","html_url":"https://github.com/kubernetes/kubernetes/pull/22019#discussion_r54177341","pull_request_url":"https://api.github.com/repos/kubernetes/kubernetes/pulls/22019","_links":{"self":{"href":"https://api.github.com/repos/kubernetes/kubernetes/pulls/comments/54177341"},"html":{"href":"https://github.com/kubernetes/kubernetes/pull/22019#discussion_r54177341"},"pull_request":{"href":"https://api.github.com/repos/kubernetes/kubernetes/pulls/22019"}}},"pull_request":{"url":"https://api.github.com/repos/kubernetes/kubernetes/pulls/22019","id":60759022,"html_url":"https://github.com/kubernetes/kubernetes/pull/22019","diff_url":"https://github.com/kubernetes/kubernetes/pull/22019.diff","patch_url":"https://github.com/kubernetes/kubernetes/pull/22019.patch","issue_url":"https://api.github.com/repos/kubernetes/kubernetes/issues/22019","number":22019,"state":"open","locked":false,"title":"Handle aws implicit and shared routing tables","user":{"login":"jsravn","id":522123,"avatar_url":"https://avatars.githubusercontent.com/u/522123?v=3","gravatar_id":"","url":"https://api.github.com/users/jsravn","html_url":"https://github.com/jsravn","followers_url":"https://api.github.com/users/jsravn/followers","following_url":"https://api.github.com/users/jsravn/following{/other_user}","gists_url":"https://api.github.com/users/jsravn/gists{/gist_id}","starred_url":"https://api.github.com/users/jsravn/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jsravn/subscriptions","organizations_url":"https://api.github.com/users/jsravn/orgs","repos_url":"https://api.github.com/users/jsravn/repos","events_url":"https://api.github.com/users/jsravn/events{/privacy}","received_events_url":"https://api.github.com/users/jsravn/received_events","type":"User","site_admin":false},"body":"Fix the AWS subnet lookup that checks if a subnet is public, which was\r\nmissing a few cases:\r\n\r\n- Subnets without explicit routing tables, which use the main VPC\r\n  routing table.\r\n- Routing tables not tagged with KubernetesCluster. The filter for this\r\n  is now removed.","created_at":"2016-02-25T22:30:03Z","updated_at":"2016-02-25T22:36:50Z","closed_at":null,"merged_at":null,"merge_commit_sha":"ff4488c1d12acff01a4ea62973e4b629e47d067a","assignee":{"login":"mikedanese","id":1787169,"avatar_url":"https://avatars.githubusercontent.com/u/1787169?v=3","gravatar_id":"","url":"https://api.github.com/users/mikedanese","html_url":"https://github.com/mikedanese","followers_url":"https://api.github.com/users/mikedanese/followers","following_url":"https://api.github.com/users/mikedanese/following{/other_user}","gists_url":"https://api.github.com/users/mikedanese/gists{/gist_id}","starred_url":"https://api.github.com/users/mikedanese/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mikedanese/subscriptions","organizations_url":"https://api.github.com/users/mikedanese/orgs","repos_url":"https://api.github.com/users/mikedanese/repos","events_url":"https://api.github.com/users/mikedanese/events{/privacy}","received_events_url":"https://api.github.com/users/mikedanese/received_events","type":"User","site_admin":false},"milestone":null,"commits_url":"https://api.github.com/repos/kubernetes/kubernetes/pulls/22019/commits","review_comments_url":"https://api.github.com/repos/kubernetes/kubernetes/pulls/22019/comments","review_comment_url":"https://api.github.com/repos/kubernetes/kubernetes/pulls/comments{/number}","comments_url":"https://api.github.com/repos/kubernetes/kubernetes/issues/22019/comments","statuses_url":"https://api.github.com/repos/kubernetes/kubernetes/statuses/a64cd9f741dc3614c7f308242c8b79645cc76978","head":{"label":"sky-uk:aws-handle-implicit-routing-tables","ref":"aws-handle-implicit-routing-tables","sha":"a64cd9f741dc3614c7f308242c8b79645cc76978","user":{"login":"sky-uk","id":1391938,"avatar_url":"https://avatars.githubusercontent.com/u/1391938?v=3","gravatar_id":"","url":"https://api.github.com/users/sky-uk","html_url":"https://github.com/sky-uk","followers_url":"https://api.github.com/users/sky-uk/followers","following_url":"https://api.github.com/users/sky-uk/following{/other_user}","gists_url":"https://api.github.com/users/sky-uk/gists{/gist_id}","starred_url":"https://api.github.com/users/sky-uk/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sky-uk/subscriptions","organizations_url":"https://api.github.com/users/sky-uk/orgs","repos_url":"https://api.github.com/users/sky-uk/repos","events_url":"https://api.github.com/users/sky-uk/events{/privacy}","received_events_url":"https://api.github.com/users/sky-uk/received_events","type":"Organization","site_admin":false},"repo":{"id":50423512,"name":"kubernetes","full_name":"sky-uk/kubernetes","owner":{"login":"sky-uk","id":1391938,"avatar_url":"https://avatars.githubusercontent.com/u/1391938?v=3","gravatar_id":"","url":"https://api.github.com/users/sky-uk","html_url":"https://github.com/sky-uk","followers_url":"https://api.github.com/users/sky-uk/followers","following_url":"https://api.github.com/users/sky-uk/following{/other_user}","gists_url":"https://api.github.com/users/sky-uk/gists{/gist_id}","starred_url":"https://api.github.com/users/sky-uk/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sky-uk/subscriptions","organizations_url":"https://api.github.com/users/sky-uk/orgs","repos_url":"https://api.github.com/users/sky-uk/repos","events_url":"https://api.github.com/users/sky-uk/events{/privacy}","received_events_url":"https://api.github.com/users/sky-uk/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/sky-uk/kubernetes","description":"Container Cluster Manager from Google","fork":true,"url":"https://api.github.com/repos/sky-uk/kubernetes","forks_url":"https://api.github.com/repos/sky-uk/kubernetes/forks","keys_url":"https://api.github.com/repos/sky-uk/kubernetes/keys{/key_id}","collaborators_url":"https://api.github.com/repos/sky-uk/kubernetes/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/sky-uk/kubernetes/teams","hooks_url":"https://api.github.com/repos/sky-uk/kubernetes/hooks","issue_events_url":"https://api.github.com/repos/sky-uk/kubernetes/issues/events{/number}","events_url":"https://api.github.com/repos/sky-uk/kubernetes/events","assignees_url":"https://api.github.com/repos/sky-uk/kubernetes/assignees{/user}","branches_url":"https://api.github.com/repos/sky-uk/kubernetes/branches{/branch}","tags_url":"https://api.github.com/repos/sky-uk/kubernetes/tags","blobs_url":"https://api.github.com/repos/sky-uk/kubernetes/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/sky-uk/kubernetes/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/sky-uk/kubernetes/git/refs{/sha}","trees_url":"https://api.github.com/repos/sky-uk/kubernetes/git/trees{/sha}","statuses_url":"https://api.github.com/repos/sky-uk/kubernetes/statuses/{sha}","languages_url":"https://api.github.com/repos/sky-uk/kubernetes/languages","stargazers_url":"https://api.github.com/repos/sky-uk/kubernetes/stargazers","contributors_url":"https://api.github.com/repos/sky-uk/kubernetes/contributors","subscribers_url":"https://api.github.com/repos/sky-uk/kubernetes/subscribers","subscription_url":"https://api.github.com/repos/sky-uk/kubernetes/subscription","commits_url":"https://api.github.com/repos/sky-uk/kubernetes/commits{/sha}","git_commits_url":"https://api.github.com/repos/sky-uk/kubernetes/git/commits{/sha}","comments_url":"https://api.github.com/repos/sky-uk/kubernetes/comments{/number}","issue_comment_url":"https://api.github.com/repos/sky-uk/kubernetes/issues/comments{/number}","contents_url":"https://api.github.com/repos/sky-uk/kubernetes/contents/{+path}","compare_url":"https://api.github.com/repos/sky-uk/kubernetes/compare/{base}...{head}","merges_url":"https://api.github.com/repos/sky-uk/kubernetes/merges","archive_url":"https://api.github.com/repos/sky-uk/kubernetes/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/sky-uk/kubernetes/downloads","issues_url":"https://api.github.com/repos/sky-uk/kubernetes/issues{/number}","pulls_url":"https://api.github.com/repos/sky-uk/kubernetes/pulls{/number}","milestones_url":"https://api.github.com/repos/sky-uk/kubernetes/milestones{/number}","notifications_url":"https://api.github.com/repos/sky-uk/kubernetes/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/sky-uk/kubernetes/labels{/name}","releases_url":"https://api.github.com/repos/sky-uk/kubernetes/releases{/id}","deployments_url":"https://api.github.com/repos/sky-uk/kubernetes/deployments","created_at":"2016-01-26T11:09:54Z","updated_at":"2016-01-26T11:10:06Z","pushed_at":"2016-02-25T22:29:45Z","git_url":"git://github.com/sky-uk/kubernetes.git","ssh_url":"git@github.com:sky-uk/kubernetes.git","clone_url":"https://github.com/sky-uk/kubernetes.git","svn_url":"https://github.com/sky-uk/kubernetes","homepage":"http://kubernetes.io","size":174527,"stargazers_count":0,"watchers_count":0,"language":"Go","has_issues":false,"has_downloads":true,"has_wiki":true,"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":"kubernetes:master","ref":"master","sha":"df234d83cdae2b0fc4bd7cd775fda8446dee6488","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":"Container Cluster Manager from Google","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-02-25T20:04:25Z","pushed_at":"2016-02-25T22:33:26Z","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":331734,"stargazers_count":12879,"watchers_count":12879,"language":"Go","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":3679,"mirror_url":null,"open_issues_count":2991,"forks":3679,"open_issues":2991,"watchers":12879,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/kubernetes/kubernetes/pulls/22019"},"html":{"href":"https://github.com/kubernetes/kubernetes/pull/22019"},"issue":{"href":"https://api.github.com/repos/kubernetes/kubernetes/issues/22019"},"comments":{"href":"https://api.github.com/repos/kubernetes/kubernetes/issues/22019/comments"},"review_comments":{"href":"https://api.github.com/repos/kubernetes/kubernetes/pulls/22019/comments"},"review_comment":{"href":"https://api.github.com/repos/kubernetes/kubernetes/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/kubernetes/kubernetes/pulls/22019/commits"},"statuses":{"href":"https://api.github.com/repos/kubernetes/kubernetes/statuses/a64cd9f741dc3614c7f308242c8b79645cc76978"}}}}