mirror of
				https://github.com/optim-enterprises-bv/kubernetes.git
				synced 2025-11-04 04:08:16 +00:00 
			
		
		
		
	Cleanup scheduler/algorithm/predicates package
This commit is contained in:
		@@ -4,9 +4,7 @@ go_library(
 | 
			
		||||
    name = "go_default_library",
 | 
			
		||||
    srcs = [
 | 
			
		||||
        "error.go",
 | 
			
		||||
        "metadata.go",
 | 
			
		||||
        "predicates.go",
 | 
			
		||||
        "utils.go",
 | 
			
		||||
    ],
 | 
			
		||||
    importpath = "k8s.io/kubernetes/pkg/scheduler/algorithm/predicates",
 | 
			
		||||
    visibility = ["//visibility:public"],
 | 
			
		||||
@@ -25,10 +23,7 @@ go_library(
 | 
			
		||||
 | 
			
		||||
go_test(
 | 
			
		||||
    name = "go_default_test",
 | 
			
		||||
    srcs = [
 | 
			
		||||
        "predicates_test.go",
 | 
			
		||||
        "utils_test.go",
 | 
			
		||||
    ],
 | 
			
		||||
    srcs = ["predicates_test.go"],
 | 
			
		||||
    embed = [":go_default_library"],
 | 
			
		||||
    deps = [
 | 
			
		||||
        "//pkg/apis/core:go_default_library",
 | 
			
		||||
 
 | 
			
		||||
@@ -1,21 +0,0 @@
 | 
			
		||||
/*
 | 
			
		||||
Copyright 2016 The Kubernetes Authors.
 | 
			
		||||
 | 
			
		||||
Licensed under the Apache License, Version 2.0 (the "License");
 | 
			
		||||
you may not use this file except in compliance with the License.
 | 
			
		||||
You may obtain a copy of the License at
 | 
			
		||||
 | 
			
		||||
    http://www.apache.org/licenses/LICENSE-2.0
 | 
			
		||||
 | 
			
		||||
Unless required by applicable law or agreed to in writing, software
 | 
			
		||||
distributed under the License is distributed on an "AS IS" BASIS,
 | 
			
		||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 | 
			
		||||
See the License for the specific language governing permissions and
 | 
			
		||||
limitations under the License.
 | 
			
		||||
*/
 | 
			
		||||
 | 
			
		||||
package predicates
 | 
			
		||||
 | 
			
		||||
// Metadata interface represents anything that can access a predicate metadata.
 | 
			
		||||
// DEPRECATED.
 | 
			
		||||
type Metadata interface{}
 | 
			
		||||
@@ -108,6 +108,10 @@ func Ordering() []string {
 | 
			
		||||
	return predicatesOrdering
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Metadata interface represents anything that can access a predicate metadata.
 | 
			
		||||
// DEPRECATED.
 | 
			
		||||
type Metadata interface{}
 | 
			
		||||
 | 
			
		||||
// FitPredicate is a function that indicates if a pod fits into an existing node.
 | 
			
		||||
// The failure information is given by the error.
 | 
			
		||||
type FitPredicate func(pod *v1.Pod, meta Metadata, nodeInfo *schedulernodeinfo.NodeInfo) (bool, []PredicateFailureReason, error)
 | 
			
		||||
@@ -278,9 +282,11 @@ func PodFitsHostPortsPredicate(pod *v1.Pod, meta []*v1.ContainerPort, nodeInfo *
 | 
			
		||||
	existingPorts := nodeInfo.UsedPorts()
 | 
			
		||||
 | 
			
		||||
	// try to see whether existingPorts and  wantPorts will conflict or not
 | 
			
		||||
	if portsConflict(existingPorts, wantPorts) {
 | 
			
		||||
	for _, cp := range wantPorts {
 | 
			
		||||
		if existingPorts.CheckConflict(cp.HostIP, string(cp.Protocol), cp.HostPort) {
 | 
			
		||||
			return false, []PredicateFailureReason{ErrPodNotFitsHostPorts}, nil
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return true, nil, nil
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -1,34 +0,0 @@
 | 
			
		||||
/*
 | 
			
		||||
Copyright 2016 The Kubernetes Authors.
 | 
			
		||||
 | 
			
		||||
Licensed under the Apache License, Version 2.0 (the "License");
 | 
			
		||||
you may not use this file except in compliance with the License.
 | 
			
		||||
You may obtain a copy of the License at
 | 
			
		||||
 | 
			
		||||
    http://www.apache.org/licenses/LICENSE-2.0
 | 
			
		||||
 | 
			
		||||
Unless required by applicable law or agreed to in writing, software
 | 
			
		||||
distributed under the License is distributed on an "AS IS" BASIS,
 | 
			
		||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 | 
			
		||||
See the License for the specific language governing permissions and
 | 
			
		||||
limitations under the License.
 | 
			
		||||
*/
 | 
			
		||||
 | 
			
		||||
package predicates
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	v1 "k8s.io/api/core/v1"
 | 
			
		||||
	schedulernodeinfo "k8s.io/kubernetes/pkg/scheduler/nodeinfo"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
// portsConflict check whether existingPorts and wantPorts conflict with each other
 | 
			
		||||
// return true if we have a conflict
 | 
			
		||||
func portsConflict(existingPorts schedulernodeinfo.HostPortInfo, wantPorts []*v1.ContainerPort) bool {
 | 
			
		||||
	for _, cp := range wantPorts {
 | 
			
		||||
		if existingPorts.CheckConflict(cp.HostIP, string(cp.Protocol), cp.HostPort) {
 | 
			
		||||
			return true
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return false
 | 
			
		||||
}
 | 
			
		||||
@@ -1,17 +0,0 @@
 | 
			
		||||
/*
 | 
			
		||||
Copyright 2016 The Kubernetes Authors.
 | 
			
		||||
 | 
			
		||||
Licensed under the Apache License, Version 2.0 (the "License");
 | 
			
		||||
you may not use this file except in compliance with the License.
 | 
			
		||||
You may obtain a copy of the License at
 | 
			
		||||
 | 
			
		||||
    http://www.apache.org/licenses/LICENSE-2.0
 | 
			
		||||
 | 
			
		||||
Unless required by applicable law or agreed to in writing, software
 | 
			
		||||
distributed under the License is distributed on an "AS IS" BASIS,
 | 
			
		||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 | 
			
		||||
See the License for the specific language governing permissions and
 | 
			
		||||
limitations under the License.
 | 
			
		||||
*/
 | 
			
		||||
 | 
			
		||||
package predicates
 | 
			
		||||
		Reference in New Issue
	
	Block a user