{"action":"created","issue":{"url":"https://api.github.com/repos/kubernetes/kubernetes/issues/24720","repository_url":"https://api.github.com/repos/kubernetes/kubernetes","labels_url":"https://api.github.com/repos/kubernetes/kubernetes/issues/24720/labels{/name}","comments_url":"https://api.github.com/repos/kubernetes/kubernetes/issues/24720/comments","events_url":"https://api.github.com/repos/kubernetes/kubernetes/issues/24720/events","html_url":"https://github.com/kubernetes/kubernetes/issues/24720","id":150697054,"number":24720,"title":"Total priority can overflow","user":{"login":"davidopp","id":8264113,"avatar_url":"https://avatars.githubusercontent.com/u/8264113?v=3","gravatar_id":"","url":"https://api.github.com/users/davidopp","html_url":"https://github.com/davidopp","followers_url":"https://api.github.com/users/davidopp/followers","following_url":"https://api.github.com/users/davidopp/following{/other_user}","gists_url":"https://api.github.com/users/davidopp/gists{/gist_id}","starred_url":"https://api.github.com/users/davidopp/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/davidopp/subscriptions","organizations_url":"https://api.github.com/users/davidopp/orgs","repos_url":"https://api.github.com/users/davidopp/repos","events_url":"https://api.github.com/users/davidopp/events{/privacy}","received_events_url":"https://api.github.com/users/davidopp/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/kubernetes/kubernetes/labels/component/scheduler","name":"component/scheduler","color":"0052cc"},{"url":"https://api.github.com/repos/kubernetes/kubernetes/labels/kind/bug","name":"kind/bug","color":"e11d21"},{"url":"https://api.github.com/repos/kubernetes/kubernetes/labels/priority/P1","name":"priority/P1","color":"eb6420"},{"url":"https://api.github.com/repos/kubernetes/kubernetes/labels/team/control-plane","name":"team/control-plane","color":"d2b48c"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":3,"created_at":"2016-04-24T20:33:38Z","updated_at":"2016-04-27T12:35:35Z","closed_at":null,"body":"Weight is an int (see [PriorityConfigFactory definition](https://github.com/kubernetes/kubernetes/blob/dae5ac482861382e18b1e7b2943b1b7f333c6a2a/plugin/pkg/scheduler/factory/plugins.go#L53)). Priority can take the range 1-10. Total priority for a node is sum of weight * priority for each priority function, and the sum is accumulated into an int (see [PrioritizeNodes](https://github.com/kubernetes/kubernetes/blob/dae5ac482861382e18b1e7b2943b1b7f333c6a2a/plugin/pkg/scheduler/generic_scheduler.go#L227)). So obviously the total priority can overflow if someone sets the weight(s) too high.\r\n\r\nThe weights of all priority functions are compiled in (or specified in config file), so we can check to make sure maximum total priority can't overflow an int (take sum over all priority functions of 10 * weight of that priority function, and make sure that's smaller than int(MaxUint >> 1) which according to StackOverflow is the way to find out what is max int (math package has max Int32, Int64, etc. but not max Int).\r\n\r\nNote that scheduler extender is OK because although the policy runs in a separate process, the weight is specified in scheduler config file (ExtenderConfig struct) and the priority is bounded 1-10 as usual.\r\n"},"comment":{"url":"https://api.github.com/repos/kubernetes/kubernetes/issues/comments/215068390","html_url":"https://github.com/kubernetes/kubernetes/issues/24720#issuecomment-215068390","issue_url":"https://api.github.com/repos/kubernetes/kubernetes/issues/24720","id":215068390,"user":{"login":"AdoHe","id":1555564,"avatar_url":"https://avatars.githubusercontent.com/u/1555564?v=3","gravatar_id":"","url":"https://api.github.com/users/AdoHe","html_url":"https://github.com/AdoHe","followers_url":"https://api.github.com/users/AdoHe/followers","following_url":"https://api.github.com/users/AdoHe/following{/other_user}","gists_url":"https://api.github.com/users/AdoHe/gists{/gist_id}","starred_url":"https://api.github.com/users/AdoHe/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/AdoHe/subscriptions","organizations_url":"https://api.github.com/users/AdoHe/orgs","repos_url":"https://api.github.com/users/AdoHe/repos","events_url":"https://api.github.com/users/AdoHe/events{/privacy}","received_events_url":"https://api.github.com/users/AdoHe/received_events","type":"User","site_admin":false},"created_at":"2016-04-27T12:35:35Z","updated_at":"2016-04-27T12:35:35Z","body":"@davidopp I think we can check weight overflow in [getPriorityFunctionConfigs](https://github.com/kubernetes/kubernetes/blob/master/plugin/pkg/scheduler/factory/plugins.go#L256) after we get all PriorityConfig. what do you think about this?"}}