mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-25 12:43:23 +00:00
Scheduler: remove direct import to /pkg/util/parsers
This commit is contained in:
parent
4bdb72ed11
commit
0b715ea690
@ -22,7 +22,6 @@ go_library(
|
|||||||
"//pkg/kubelet/container:go_default_library",
|
"//pkg/kubelet/container:go_default_library",
|
||||||
"//pkg/kubelet/events:go_default_library",
|
"//pkg/kubelet/events:go_default_library",
|
||||||
"//pkg/kubelet/util/sliceutils:go_default_library",
|
"//pkg/kubelet/util/sliceutils:go_default_library",
|
||||||
"//pkg/util/parsers:go_default_library",
|
|
||||||
"//staging/src/k8s.io/api/core/v1:go_default_library",
|
"//staging/src/k8s.io/api/core/v1:go_default_library",
|
||||||
"//staging/src/k8s.io/apimachinery/pkg/util/errors:go_default_library",
|
"//staging/src/k8s.io/apimachinery/pkg/util/errors:go_default_library",
|
||||||
"//staging/src/k8s.io/apimachinery/pkg/util/sets:go_default_library",
|
"//staging/src/k8s.io/apimachinery/pkg/util/sets:go_default_library",
|
||||||
|
@ -28,7 +28,6 @@ import (
|
|||||||
runtimeapi "k8s.io/cri-api/pkg/apis/runtime/v1alpha2"
|
runtimeapi "k8s.io/cri-api/pkg/apis/runtime/v1alpha2"
|
||||||
kubecontainer "k8s.io/kubernetes/pkg/kubelet/container"
|
kubecontainer "k8s.io/kubernetes/pkg/kubelet/container"
|
||||||
"k8s.io/kubernetes/pkg/kubelet/events"
|
"k8s.io/kubernetes/pkg/kubelet/events"
|
||||||
"k8s.io/kubernetes/pkg/util/parsers"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// imageManager provides the functionalities for image pulling.
|
// imageManager provides the functionalities for image pulling.
|
||||||
@ -161,7 +160,7 @@ func applyDefaultImageTag(image string) (string, error) {
|
|||||||
// image to be fully qualified as docker.io/$name if it's a short name
|
// image to be fully qualified as docker.io/$name if it's a short name
|
||||||
// (e.g. just busybox). We don't want that to happen to keep the CRI
|
// (e.g. just busybox). We don't want that to happen to keep the CRI
|
||||||
// agnostic wrt image names and default hostnames.
|
// agnostic wrt image names and default hostnames.
|
||||||
image = image + ":" + parsers.DefaultImageTag
|
image = image + ":latest"
|
||||||
}
|
}
|
||||||
return image, nil
|
return image, nil
|
||||||
}
|
}
|
||||||
|
@ -7,7 +7,6 @@ go_library(
|
|||||||
visibility = ["//visibility:public"],
|
visibility = ["//visibility:public"],
|
||||||
deps = [
|
deps = [
|
||||||
"//pkg/scheduler/framework/v1alpha1:go_default_library",
|
"//pkg/scheduler/framework/v1alpha1:go_default_library",
|
||||||
"//pkg/util/parsers:go_default_library",
|
|
||||||
"//staging/src/k8s.io/api/core/v1:go_default_library",
|
"//staging/src/k8s.io/api/core/v1:go_default_library",
|
||||||
"//staging/src/k8s.io/apimachinery/pkg/runtime:go_default_library",
|
"//staging/src/k8s.io/apimachinery/pkg/runtime:go_default_library",
|
||||||
],
|
],
|
||||||
@ -20,7 +19,6 @@ go_test(
|
|||||||
deps = [
|
deps = [
|
||||||
"//pkg/scheduler/framework/v1alpha1:go_default_library",
|
"//pkg/scheduler/framework/v1alpha1:go_default_library",
|
||||||
"//pkg/scheduler/internal/cache:go_default_library",
|
"//pkg/scheduler/internal/cache:go_default_library",
|
||||||
"//pkg/util/parsers:go_default_library",
|
|
||||||
"//staging/src/k8s.io/api/core/v1:go_default_library",
|
"//staging/src/k8s.io/api/core/v1:go_default_library",
|
||||||
"//staging/src/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library",
|
"//staging/src/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library",
|
||||||
],
|
],
|
||||||
|
@ -24,7 +24,6 @@ import (
|
|||||||
v1 "k8s.io/api/core/v1"
|
v1 "k8s.io/api/core/v1"
|
||||||
"k8s.io/apimachinery/pkg/runtime"
|
"k8s.io/apimachinery/pkg/runtime"
|
||||||
framework "k8s.io/kubernetes/pkg/scheduler/framework/v1alpha1"
|
framework "k8s.io/kubernetes/pkg/scheduler/framework/v1alpha1"
|
||||||
"k8s.io/kubernetes/pkg/util/parsers"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// The two thresholds are used as bounds for the image score range. They correspond to a reasonable size range for
|
// The two thresholds are used as bounds for the image score range. They correspond to a reasonable size range for
|
||||||
@ -122,7 +121,7 @@ func scaledImageScore(imageState *framework.ImageStateSummary, totalNumNodes int
|
|||||||
// in node status; note that if users consistently use one registry format, this should not happen.
|
// in node status; note that if users consistently use one registry format, this should not happen.
|
||||||
func normalizedImageName(name string) string {
|
func normalizedImageName(name string) string {
|
||||||
if strings.LastIndex(name, ":") <= strings.LastIndex(name, "/") {
|
if strings.LastIndex(name, ":") <= strings.LastIndex(name, "/") {
|
||||||
name = name + ":" + parsers.DefaultImageTag
|
name = name + ":latest"
|
||||||
}
|
}
|
||||||
return name
|
return name
|
||||||
}
|
}
|
||||||
|
@ -27,7 +27,6 @@ import (
|
|||||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
framework "k8s.io/kubernetes/pkg/scheduler/framework/v1alpha1"
|
framework "k8s.io/kubernetes/pkg/scheduler/framework/v1alpha1"
|
||||||
"k8s.io/kubernetes/pkg/scheduler/internal/cache"
|
"k8s.io/kubernetes/pkg/scheduler/internal/cache"
|
||||||
"k8s.io/kubernetes/pkg/util/parsers"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestImageLocalityPriority(t *testing.T) {
|
func TestImageLocalityPriority(t *testing.T) {
|
||||||
@ -69,7 +68,7 @@ func TestImageLocalityPriority(t *testing.T) {
|
|||||||
Images: []v1.ContainerImage{
|
Images: []v1.ContainerImage{
|
||||||
{
|
{
|
||||||
Names: []string{
|
Names: []string{
|
||||||
"gcr.io/40:" + parsers.DefaultImageTag,
|
"gcr.io/40:latest",
|
||||||
"gcr.io/40:v1",
|
"gcr.io/40:v1",
|
||||||
"gcr.io/40:v1",
|
"gcr.io/40:v1",
|
||||||
},
|
},
|
||||||
@ -77,14 +76,14 @@ func TestImageLocalityPriority(t *testing.T) {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
Names: []string{
|
Names: []string{
|
||||||
"gcr.io/300:" + parsers.DefaultImageTag,
|
"gcr.io/300:latest",
|
||||||
"gcr.io/300:v1",
|
"gcr.io/300:v1",
|
||||||
},
|
},
|
||||||
SizeBytes: int64(300 * mb),
|
SizeBytes: int64(300 * mb),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Names: []string{
|
Names: []string{
|
||||||
"gcr.io/2000:" + parsers.DefaultImageTag,
|
"gcr.io/2000:latest",
|
||||||
},
|
},
|
||||||
SizeBytes: int64(2000 * mb),
|
SizeBytes: int64(2000 * mb),
|
||||||
},
|
},
|
||||||
@ -95,13 +94,13 @@ func TestImageLocalityPriority(t *testing.T) {
|
|||||||
Images: []v1.ContainerImage{
|
Images: []v1.ContainerImage{
|
||||||
{
|
{
|
||||||
Names: []string{
|
Names: []string{
|
||||||
"gcr.io/250:" + parsers.DefaultImageTag,
|
"gcr.io/250:latest",
|
||||||
},
|
},
|
||||||
SizeBytes: int64(250 * mb),
|
SizeBytes: int64(250 * mb),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Names: []string{
|
Names: []string{
|
||||||
"gcr.io/10:" + parsers.DefaultImageTag,
|
"gcr.io/10:latest",
|
||||||
"gcr.io/10:v1",
|
"gcr.io/10:v1",
|
||||||
},
|
},
|
||||||
SizeBytes: int64(10 * mb),
|
SizeBytes: int64(10 * mb),
|
||||||
|
@ -26,11 +26,6 @@ import (
|
|||||||
dockerref "github.com/docker/distribution/reference"
|
dockerref "github.com/docker/distribution/reference"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
|
||||||
// DefaultImageTag is the default tag for docker image.
|
|
||||||
DefaultImageTag = "latest"
|
|
||||||
)
|
|
||||||
|
|
||||||
// ParseImageName parses a docker image string into three parts: repo, tag and digest.
|
// ParseImageName parses a docker image string into three parts: repo, tag and digest.
|
||||||
// If both tag and digest are empty, a default image tag will be returned.
|
// If both tag and digest are empty, a default image tag will be returned.
|
||||||
func ParseImageName(image string) (string, string, string, error) {
|
func ParseImageName(image string) (string, string, string, error) {
|
||||||
@ -53,7 +48,7 @@ func ParseImageName(image string) (string, string, string, error) {
|
|||||||
}
|
}
|
||||||
// If no tag was specified, use the default "latest".
|
// If no tag was specified, use the default "latest".
|
||||||
if len(tag) == 0 && len(digest) == 0 {
|
if len(tag) == 0 && len(digest) == 0 {
|
||||||
tag = DefaultImageTag
|
tag = "latest"
|
||||||
}
|
}
|
||||||
return repoToPull, tag, digest, nil
|
return repoToPull, tag, digest, nil
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user