{"action":"created","comment":{"url":"https://api.github.com/repos/rancherio/cattle/pulls/comments/32653115","id":32653115,"diff_hunk":"@@ -33,16 +34,26 @@ public boolean matches(AllocationAttempt attempt,\n         Set<Long> hostIds = candidate.getHosts();\n         if (op == AffinityOps.SOFT_EQ || op == AffinityOps.EQ) {\n             for (Long hostId : hostIds) {\n-                Map<String, String> labelsForHost = allocatorDao.getLabelsForHost(hostId);\n-                if (!labelValue.equals(labelsForHost.get(labelKey))) {\n+                Map<String, String[]> labelsForHost = allocatorDao.getLabelsForHost(hostId);\n+                if (labelsForHost.get(labelKey) == null) { // key doesn't exist\n+                    return false;\n+                }\n+                String value = labelsForHost.get(labelKey)[0];\n+                String hostLabelMapState = labelsForHost.get(labelKey)[1];\n+                if (!labelValue.equals(value)) { // value doesn't match\n+                    return false;\n+                }\n+                if (CommonStatesConstants.REMOVING.equals(hostLabelMapState)) { // value matches but it's currently getting removed\n                     return false;\n                 }\n             }\n             return true;\n         } else {\n             for (Long hostId : hostIds) {\n-                Map<String, String> labelsForHost = allocatorDao.getLabelsForHost(hostId);\n-                if (labelValue.equals(labelsForHost.get(labelKey))) {\n+                Map<String, String[]> labelsForHost = allocatorDao.getLabelsForHost(hostId);\n+                if (labelsForHost.get(labelKey) != null ","path":"code/iaas/allocator/src/main/java/io/cattle/platform/allocator/constraint/HostAffinityConstraint.java","position":33,"original_position":33,"commit_id":"e56c7dcd3b5e4f87d089ef00b66116eb7b50c8db","original_commit_id":"e56c7dcd3b5e4f87d089ef00b66116eb7b50c8db","user":{"login":"sonchang","id":8651231,"avatar_url":"https://avatars.githubusercontent.com/u/8651231?v=3","gravatar_id":"","url":"https://api.github.com/users/sonchang","html_url":"https://github.com/sonchang","followers_url":"https://api.github.com/users/sonchang/followers","following_url":"https://api.github.com/users/sonchang/following{/other_user}","gists_url":"https://api.github.com/users/sonchang/gists{/gist_id}","starred_url":"https://api.github.com/users/sonchang/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sonchang/subscriptions","organizations_url":"https://api.github.com/users/sonchang/orgs","repos_url":"https://api.github.com/users/sonchang/repos","events_url":"https://api.github.com/users/sonchang/events{/privacy}","received_events_url":"https://api.github.com/users/sonchang/received_events","type":"User","site_admin":false},"body":"I just checked and I think we should be ok.  I did notice that labelKey could potentially be null, but it looks like that should be ok.","created_at":"2015-06-17T17:38:29Z","updated_at":"2015-06-17T17:38:29Z","html_url":"https://github.com/rancherio/cattle/pull/632#discussion_r32653115","pull_request_url":"https://api.github.com/repos/rancherio/cattle/pulls/632","_links":{"self":{"href":"https://api.github.com/repos/rancherio/cattle/pulls/comments/32653115"},"html":{"href":"https://github.com/rancherio/cattle/pull/632#discussion_r32653115"},"pull_request":{"href":"https://api.github.com/repos/rancherio/cattle/pulls/632"}}},"pull_request":{"url":"https://api.github.com/repos/rancherio/cattle/pulls/632","id":37744393,"html_url":"https://github.com/rancherio/cattle/pull/632","diff_url":"https://github.com/rancherio/cattle/pull/632.diff","patch_url":"https://github.com/rancherio/cattle/pull/632.patch","issue_url":"https://api.github.com/repos/rancherio/cattle/issues/632","number":632,"state":"open","locked":false,"title":"trigger global service on hostlabelmap.remove as well; do not remove …","user":{"login":"sonchang","id":8651231,"avatar_url":"https://avatars.githubusercontent.com/u/8651231?v=3","gravatar_id":"","url":"https://api.github.com/users/sonchang","html_url":"https://github.com/sonchang","followers_url":"https://api.github.com/users/sonchang/followers","following_url":"https://api.github.com/users/sonchang/following{/other_user}","gists_url":"https://api.github.com/users/sonchang/gists{/gist_id}","starred_url":"https://api.github.com/users/sonchang/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sonchang/subscriptions","organizations_url":"https://api.github.com/users/sonchang/orgs","repos_url":"https://api.github.com/users/sonchang/repos","events_url":"https://api.github.com/users/sonchang/events{/privacy}","received_events_url":"https://api.github.com/users/sonchang/received_events","type":"User","site_admin":false},"body":"…containers","created_at":"2015-06-15T22:57:34Z","updated_at":"2015-06-17T17:38:29Z","closed_at":null,"merged_at":null,"merge_commit_sha":"02afa9a1e8ca61976a6a3f41b27f2896a5402209","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/rancherio/cattle/pulls/632/commits","review_comments_url":"https://api.github.com/repos/rancherio/cattle/pulls/632/comments","review_comment_url":"https://api.github.com/repos/rancherio/cattle/pulls/comments{/number}","comments_url":"https://api.github.com/repos/rancherio/cattle/issues/632/comments","statuses_url":"https://api.github.com/repos/rancherio/cattle/statuses/e56c7dcd3b5e4f87d089ef00b66116eb7b50c8db","head":{"label":"sonchang:fix_gobalsrv_host_label_delete","ref":"fix_gobalsrv_host_label_delete","sha":"e56c7dcd3b5e4f87d089ef00b66116eb7b50c8db","user":{"login":"sonchang","id":8651231,"avatar_url":"https://avatars.githubusercontent.com/u/8651231?v=3","gravatar_id":"","url":"https://api.github.com/users/sonchang","html_url":"https://github.com/sonchang","followers_url":"https://api.github.com/users/sonchang/followers","following_url":"https://api.github.com/users/sonchang/following{/other_user}","gists_url":"https://api.github.com/users/sonchang/gists{/gist_id}","starred_url":"https://api.github.com/users/sonchang/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sonchang/subscriptions","organizations_url":"https://api.github.com/users/sonchang/orgs","repos_url":"https://api.github.com/users/sonchang/repos","events_url":"https://api.github.com/users/sonchang/events{/privacy}","received_events_url":"https://api.github.com/users/sonchang/received_events","type":"User","site_admin":false},"repo":{"id":29026857,"name":"cattle","full_name":"sonchang/cattle","owner":{"login":"sonchang","id":8651231,"avatar_url":"https://avatars.githubusercontent.com/u/8651231?v=3","gravatar_id":"","url":"https://api.github.com/users/sonchang","html_url":"https://github.com/sonchang","followers_url":"https://api.github.com/users/sonchang/followers","following_url":"https://api.github.com/users/sonchang/following{/other_user}","gists_url":"https://api.github.com/users/sonchang/gists{/gist_id}","starred_url":"https://api.github.com/users/sonchang/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sonchang/subscriptions","organizations_url":"https://api.github.com/users/sonchang/orgs","repos_url":"https://api.github.com/users/sonchang/repos","events_url":"https://api.github.com/users/sonchang/events{/privacy}","received_events_url":"https://api.github.com/users/sonchang/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/sonchang/cattle","description":"Infrastructure orchestration platform","fork":true,"url":"https://api.github.com/repos/sonchang/cattle","forks_url":"https://api.github.com/repos/sonchang/cattle/forks","keys_url":"https://api.github.com/repos/sonchang/cattle/keys{/key_id}","collaborators_url":"https://api.github.com/repos/sonchang/cattle/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/sonchang/cattle/teams","hooks_url":"https://api.github.com/repos/sonchang/cattle/hooks","issue_events_url":"https://api.github.com/repos/sonchang/cattle/issues/events{/number}","events_url":"https://api.github.com/repos/sonchang/cattle/events","assignees_url":"https://api.github.com/repos/sonchang/cattle/assignees{/user}","branches_url":"https://api.github.com/repos/sonchang/cattle/branches{/branch}","tags_url":"https://api.github.com/repos/sonchang/cattle/tags","blobs_url":"https://api.github.com/repos/sonchang/cattle/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/sonchang/cattle/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/sonchang/cattle/git/refs{/sha}","trees_url":"https://api.github.com/repos/sonchang/cattle/git/trees{/sha}","statuses_url":"https://api.github.com/repos/sonchang/cattle/statuses/{sha}","languages_url":"https://api.github.com/repos/sonchang/cattle/languages","stargazers_url":"https://api.github.com/repos/sonchang/cattle/stargazers","contributors_url":"https://api.github.com/repos/sonchang/cattle/contributors","subscribers_url":"https://api.github.com/repos/sonchang/cattle/subscribers","subscription_url":"https://api.github.com/repos/sonchang/cattle/subscription","commits_url":"https://api.github.com/repos/sonchang/cattle/commits{/sha}","git_commits_url":"https://api.github.com/repos/sonchang/cattle/git/commits{/sha}","comments_url":"https://api.github.com/repos/sonchang/cattle/comments{/number}","issue_comment_url":"https://api.github.com/repos/sonchang/cattle/issues/comments{/number}","contents_url":"https://api.github.com/repos/sonchang/cattle/contents/{+path}","compare_url":"https://api.github.com/repos/sonchang/cattle/compare/{base}...{head}","merges_url":"https://api.github.com/repos/sonchang/cattle/merges","archive_url":"https://api.github.com/repos/sonchang/cattle/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/sonchang/cattle/downloads","issues_url":"https://api.github.com/repos/sonchang/cattle/issues{/number}","pulls_url":"https://api.github.com/repos/sonchang/cattle/pulls{/number}","milestones_url":"https://api.github.com/repos/sonchang/cattle/milestones{/number}","notifications_url":"https://api.github.com/repos/sonchang/cattle/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/sonchang/cattle/labels{/name}","releases_url":"https://api.github.com/repos/sonchang/cattle/releases{/id}","created_at":"2015-01-09T17:18:38Z","updated_at":"2015-05-07T15:56:06Z","pushed_at":"2015-06-15T22:49:05Z","git_url":"git://github.com/sonchang/cattle.git","ssh_url":"git@github.com:sonchang/cattle.git","clone_url":"https://github.com/sonchang/cattle.git","svn_url":"https://github.com/sonchang/cattle","homepage":"","size":19933,"stargazers_count":0,"watchers_count":0,"language":"Java","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":"rancherio:master","ref":"master","sha":"426f6095dc76d7cd16cb9631a565e220753f9024","user":{"login":"rancherio","id":9343010,"avatar_url":"https://avatars.githubusercontent.com/u/9343010?v=3","gravatar_id":"","url":"https://api.github.com/users/rancherio","html_url":"https://github.com/rancherio","followers_url":"https://api.github.com/users/rancherio/followers","following_url":"https://api.github.com/users/rancherio/following{/other_user}","gists_url":"https://api.github.com/users/rancherio/gists{/gist_id}","starred_url":"https://api.github.com/users/rancherio/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rancherio/subscriptions","organizations_url":"https://api.github.com/users/rancherio/orgs","repos_url":"https://api.github.com/users/rancherio/repos","events_url":"https://api.github.com/users/rancherio/events{/privacy}","received_events_url":"https://api.github.com/users/rancherio/received_events","type":"Organization","site_admin":false},"repo":{"id":18023059,"name":"cattle","full_name":"rancherio/cattle","owner":{"login":"rancherio","id":9343010,"avatar_url":"https://avatars.githubusercontent.com/u/9343010?v=3","gravatar_id":"","url":"https://api.github.com/users/rancherio","html_url":"https://github.com/rancherio","followers_url":"https://api.github.com/users/rancherio/followers","following_url":"https://api.github.com/users/rancherio/following{/other_user}","gists_url":"https://api.github.com/users/rancherio/gists{/gist_id}","starred_url":"https://api.github.com/users/rancherio/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rancherio/subscriptions","organizations_url":"https://api.github.com/users/rancherio/orgs","repos_url":"https://api.github.com/users/rancherio/repos","events_url":"https://api.github.com/users/rancherio/events{/privacy}","received_events_url":"https://api.github.com/users/rancherio/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/rancherio/cattle","description":"Infrastructure orchestration platform","fork":false,"url":"https://api.github.com/repos/rancherio/cattle","forks_url":"https://api.github.com/repos/rancherio/cattle/forks","keys_url":"https://api.github.com/repos/rancherio/cattle/keys{/key_id}","collaborators_url":"https://api.github.com/repos/rancherio/cattle/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/rancherio/cattle/teams","hooks_url":"https://api.github.com/repos/rancherio/cattle/hooks","issue_events_url":"https://api.github.com/repos/rancherio/cattle/issues/events{/number}","events_url":"https://api.github.com/repos/rancherio/cattle/events","assignees_url":"https://api.github.com/repos/rancherio/cattle/assignees{/user}","branches_url":"https://api.github.com/repos/rancherio/cattle/branches{/branch}","tags_url":"https://api.github.com/repos/rancherio/cattle/tags","blobs_url":"https://api.github.com/repos/rancherio/cattle/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/rancherio/cattle/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/rancherio/cattle/git/refs{/sha}","trees_url":"https://api.github.com/repos/rancherio/cattle/git/trees{/sha}","statuses_url":"https://api.github.com/repos/rancherio/cattle/statuses/{sha}","languages_url":"https://api.github.com/repos/rancherio/cattle/languages","stargazers_url":"https://api.github.com/repos/rancherio/cattle/stargazers","contributors_url":"https://api.github.com/repos/rancherio/cattle/contributors","subscribers_url":"https://api.github.com/repos/rancherio/cattle/subscribers","subscription_url":"https://api.github.com/repos/rancherio/cattle/subscription","commits_url":"https://api.github.com/repos/rancherio/cattle/commits{/sha}","git_commits_url":"https://api.github.com/repos/rancherio/cattle/git/commits{/sha}","comments_url":"https://api.github.com/repos/rancherio/cattle/comments{/number}","issue_comment_url":"https://api.github.com/repos/rancherio/cattle/issues/comments{/number}","contents_url":"https://api.github.com/repos/rancherio/cattle/contents/{+path}","compare_url":"https://api.github.com/repos/rancherio/cattle/compare/{base}...{head}","merges_url":"https://api.github.com/repos/rancherio/cattle/merges","archive_url":"https://api.github.com/repos/rancherio/cattle/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/rancherio/cattle/downloads","issues_url":"https://api.github.com/repos/rancherio/cattle/issues{/number}","pulls_url":"https://api.github.com/repos/rancherio/cattle/pulls{/number}","milestones_url":"https://api.github.com/repos/rancherio/cattle/milestones{/number}","notifications_url":"https://api.github.com/repos/rancherio/cattle/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/rancherio/cattle/labels{/name}","releases_url":"https://api.github.com/repos/rancherio/cattle/releases{/id}","created_at":"2014-03-23T00:19:52Z","updated_at":"2015-06-16T21:34:54Z","pushed_at":"2015-06-17T17:04:19Z","git_url":"git://github.com/rancherio/cattle.git","ssh_url":"git@github.com:rancherio/cattle.git","clone_url":"https://github.com/rancherio/cattle.git","svn_url":"https://github.com/rancherio/cattle","homepage":"","size":27308,"stargazers_count":141,"watchers_count":141,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":33,"mirror_url":null,"open_issues_count":81,"forks":33,"open_issues":81,"watchers":141,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/rancherio/cattle/pulls/632"},"html":{"href":"https://github.com/rancherio/cattle/pull/632"},"issue":{"href":"https://api.github.com/repos/rancherio/cattle/issues/632"},"comments":{"href":"https://api.github.com/repos/rancherio/cattle/issues/632/comments"},"review_comments":{"href":"https://api.github.com/repos/rancherio/cattle/pulls/632/comments"},"review_comment":{"href":"https://api.github.com/repos/rancherio/cattle/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/rancherio/cattle/pulls/632/commits"},"statuses":{"href":"https://api.github.com/repos/rancherio/cattle/statuses/e56c7dcd3b5e4f87d089ef00b66116eb7b50c8db"}}}}