mirror of
https://github.com/ceph/ceph-csi.git
synced 2025-06-13 18:43:34 +00:00
rebase: update kubernetes dep to 1.24.0
As kubernetes 1.24.0 is released, updating kubernetes dependencies to 1.24.0 updates: #3086 Signed-off-by: Madhu Rajanna <madhupr007@gmail.com>
This commit is contained in:
committed by
mergify[bot]
parent
fc1529f268
commit
c4f79d455f
4
vendor/k8s.io/kubernetes/pkg/kubelet/apis/config/OWNERS
generated
vendored
4
vendor/k8s.io/kubernetes/pkg/kubelet/apis/config/OWNERS
generated
vendored
@ -4,6 +4,6 @@
|
||||
options:
|
||||
no_parent_owners: true
|
||||
approvers:
|
||||
- api-approvers
|
||||
- api-approvers
|
||||
reviewers:
|
||||
- sig-node-api-reviewers
|
||||
- sig-node-api-reviewers
|
||||
|
26
vendor/k8s.io/kubernetes/pkg/kubelet/apis/config/types.go
generated
vendored
26
vendor/k8s.io/kubernetes/pkg/kubelet/apis/config/types.go
generated
vendored
@ -98,7 +98,7 @@ type KubeletConfiguration struct {
|
||||
// staticPodURL is the URL for accessing static pods to run
|
||||
StaticPodURL string
|
||||
// staticPodURLHeader is a map of slices with HTTP headers to use when accessing the podURL
|
||||
StaticPodURLHeader map[string][]string
|
||||
StaticPodURLHeader map[string][]string `datapolicy:"token"`
|
||||
// address is the IP address for the Kubelet to serve on (set to 0.0.0.0
|
||||
// for all interfaces)
|
||||
Address string
|
||||
@ -340,9 +340,10 @@ type KubeletConfiguration struct {
|
||||
ContainerLogMaxFiles int32
|
||||
// ConfigMapAndSecretChangeDetectionStrategy is a mode in which config map and secret managers are running.
|
||||
ConfigMapAndSecretChangeDetectionStrategy ResourceChangeDetectionStrategy
|
||||
// A comma separated allowlist of unsafe sysctls or sysctl patterns (ending in *).
|
||||
// Unsafe sysctl groups are kernel.shm*, kernel.msg*, kernel.sem, fs.mqueue.*, and net.*.
|
||||
// These sysctls are namespaced but not allowed by default. For example: "kernel.msg*,net.ipv4.route.min_pmtu"
|
||||
// A comma separated allowlist of unsafe sysctls or sysctl patterns (ending in `*`).
|
||||
// Unsafe sysctl groups are `kernel.shm*`, `kernel.msg*`, `kernel.sem`, `fs.mqueue.*`, and `net.*`.
|
||||
// These sysctls are namespaced but not allowed by default.
|
||||
// For example: "`kernel.msg*,net.ipv4.route.min_pmtu`"
|
||||
// +optional
|
||||
AllowedUnsafeSysctls []string
|
||||
// kernelMemcgNotification if enabled, the kubelet will integrate with the kernel memcg
|
||||
@ -554,9 +555,9 @@ type CredentialProvider struct {
|
||||
//
|
||||
// Each entry in matchImages is a pattern which can optionally contain a port and a path.
|
||||
// Globs can be used in the domain, but not in the port or the path. Globs are supported
|
||||
// as subdomains like '*.k8s.io' or 'k8s.*.io', and top-level-domains such as 'k8s.*'.
|
||||
// Matching partial subdomains like 'app*.k8s.io' is also supported. Each glob can only match
|
||||
// a single subdomain segment, so *.io does not match *.k8s.io.
|
||||
// as subdomains like `*.k8s.io` or `k8s.*.io`, and top-level-domains such as `k8s.*`.
|
||||
// Matching partial subdomains like `app*.k8s.io` is also supported. Each glob can only match
|
||||
// a single subdomain segment, so `*.io` does not match *.k8s.io.
|
||||
//
|
||||
// A match exists between an image and a matchImage when all of the below are true:
|
||||
// - Both contain the same number of domain parts and each part matches.
|
||||
@ -564,11 +565,11 @@ type CredentialProvider struct {
|
||||
// - If the imageMatch contains a port, then the port must match in the image as well.
|
||||
//
|
||||
// Example values of matchImages:
|
||||
// - 123456789.dkr.ecr.us-east-1.amazonaws.com
|
||||
// - *.azurecr.io
|
||||
// - gcr.io
|
||||
// - *.*.registry.io
|
||||
// - registry.io:8080/path
|
||||
// - `123456789.dkr.ecr.us-east-1.amazonaws.com`
|
||||
// - `*.azurecr.io`
|
||||
// - `gcr.io`
|
||||
// - `*.*.registry.io`
|
||||
// - `registry.io:8080/path`
|
||||
MatchImages []string
|
||||
|
||||
// defaultCacheDuration is the default duration the plugin will cache credentials in-memory
|
||||
@ -578,6 +579,7 @@ type CredentialProvider struct {
|
||||
// Required input version of the exec CredentialProviderRequest. The returned CredentialProviderResponse
|
||||
// MUST use the same encoding version as the input. Current supported values are:
|
||||
// - credentialprovider.kubelet.k8s.io/v1alpha1
|
||||
// - credentialprovider.kubelet.k8s.io/v1beta1
|
||||
APIVersion string
|
||||
|
||||
// Arguments to pass to the command when executing it.
|
||||
|
101
vendor/k8s.io/kubernetes/pkg/kubelet/server/metrics/metrics.go
generated
vendored
Normal file
101
vendor/k8s.io/kubernetes/pkg/kubelet/server/metrics/metrics.go
generated
vendored
Normal file
@ -0,0 +1,101 @@
|
||||
/*
|
||||
Copyright 2019 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 metrics
|
||||
|
||||
import (
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"k8s.io/component-base/metrics"
|
||||
"k8s.io/component-base/metrics/legacyregistry"
|
||||
)
|
||||
|
||||
const (
|
||||
kubeletSubsystem = "kubelet"
|
||||
)
|
||||
|
||||
var (
|
||||
// HTTPRequests tracks the number of the http requests received since the server started.
|
||||
HTTPRequests = metrics.NewCounterVec(
|
||||
&metrics.CounterOpts{
|
||||
Subsystem: kubeletSubsystem,
|
||||
Name: "http_requests_total",
|
||||
Help: "Number of the http requests received since the server started",
|
||||
StabilityLevel: metrics.ALPHA,
|
||||
},
|
||||
// server_type aims to differentiate the readonly server and the readwrite server.
|
||||
// long_running marks whether the request is long-running or not.
|
||||
// Currently, long-running requests include exec/attach/portforward/debug.
|
||||
[]string{"method", "path", "server_type", "long_running"},
|
||||
)
|
||||
// HTTPRequestsDuration tracks the duration in seconds to serve http requests.
|
||||
HTTPRequestsDuration = metrics.NewHistogramVec(
|
||||
&metrics.HistogramOpts{
|
||||
Subsystem: kubeletSubsystem,
|
||||
Name: "http_requests_duration_seconds",
|
||||
Help: "Duration in seconds to serve http requests",
|
||||
// Use DefBuckets for now, will customize the buckets if necessary.
|
||||
Buckets: metrics.DefBuckets,
|
||||
StabilityLevel: metrics.ALPHA,
|
||||
},
|
||||
[]string{"method", "path", "server_type", "long_running"},
|
||||
)
|
||||
// HTTPInflightRequests tracks the number of the inflight http requests.
|
||||
HTTPInflightRequests = metrics.NewGaugeVec(
|
||||
&metrics.GaugeOpts{
|
||||
Subsystem: kubeletSubsystem,
|
||||
Name: "http_inflight_requests",
|
||||
Help: "Number of the inflight http requests",
|
||||
StabilityLevel: metrics.ALPHA,
|
||||
},
|
||||
[]string{"method", "path", "server_type", "long_running"},
|
||||
)
|
||||
// VolumeStatCalDuration tracks the duration in seconds to calculate volume stats.
|
||||
// this metric is mainly for comparison between fsquota monitoring and `du` for disk usage.
|
||||
VolumeStatCalDuration = metrics.NewHistogramVec(
|
||||
&metrics.HistogramOpts{
|
||||
Subsystem: kubeletSubsystem,
|
||||
Name: "volume_metric_collection_duration_seconds",
|
||||
Help: "Duration in seconds to calculate volume stats",
|
||||
Buckets: metrics.DefBuckets,
|
||||
StabilityLevel: metrics.ALPHA,
|
||||
},
|
||||
[]string{"metric_source"},
|
||||
)
|
||||
)
|
||||
|
||||
var registerMetrics sync.Once
|
||||
|
||||
// Register all metrics.
|
||||
func Register() {
|
||||
registerMetrics.Do(func() {
|
||||
legacyregistry.MustRegister(HTTPRequests)
|
||||
legacyregistry.MustRegister(HTTPRequestsDuration)
|
||||
legacyregistry.MustRegister(HTTPInflightRequests)
|
||||
legacyregistry.MustRegister(VolumeStatCalDuration)
|
||||
})
|
||||
}
|
||||
|
||||
// SinceInSeconds gets the time since the specified start in seconds.
|
||||
func SinceInSeconds(start time.Time) float64 {
|
||||
return time.Since(start).Seconds()
|
||||
}
|
||||
|
||||
// CollectVolumeStatCalDuration collects the duration in seconds to calculate volume stats.
|
||||
func CollectVolumeStatCalDuration(metricSource string, start time.Time) {
|
||||
VolumeStatCalDuration.WithLabelValues(metricSource).Observe(SinceInSeconds(start))
|
||||
}
|
46
vendor/k8s.io/kubernetes/pkg/kubelet/types/constants.go
generated
vendored
46
vendor/k8s.io/kubernetes/pkg/kubelet/types/constants.go
generated
vendored
@ -1,46 +0,0 @@
|
||||
/*
|
||||
Copyright 2015 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 types
|
||||
|
||||
const (
|
||||
// ResolvConfDefault is the system default DNS resolver configuration.
|
||||
ResolvConfDefault = "/etc/resolv.conf"
|
||||
// RFC3339NanoFixed is the fixed width version of time.RFC3339Nano.
|
||||
RFC3339NanoFixed = "2006-01-02T15:04:05.000000000Z07:00"
|
||||
// RFC3339NanoLenient is the variable width RFC3339 time format for lenient parsing of strings into timestamps.
|
||||
RFC3339NanoLenient = "2006-01-02T15:04:05.999999999Z07:00"
|
||||
)
|
||||
|
||||
// Different container runtimes.
|
||||
const (
|
||||
DockerContainerRuntime = "docker"
|
||||
RemoteContainerRuntime = "remote"
|
||||
)
|
||||
|
||||
// User visible keys for managing node allocatable enforcement on the node.
|
||||
const (
|
||||
NodeAllocatableEnforcementKey = "pods"
|
||||
SystemReservedEnforcementKey = "system-reserved"
|
||||
KubeReservedEnforcementKey = "kube-reserved"
|
||||
NodeAllocatableNoneKey = "none"
|
||||
)
|
||||
|
||||
// SwapBehavior types
|
||||
const (
|
||||
LimitedSwap = "LimitedSwap"
|
||||
UnlimitedSwap = "UnlimitedSwap"
|
||||
)
|
18
vendor/k8s.io/kubernetes/pkg/kubelet/types/doc.go
generated
vendored
18
vendor/k8s.io/kubernetes/pkg/kubelet/types/doc.go
generated
vendored
@ -1,18 +0,0 @@
|
||||
/*
|
||||
Copyright 2015 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 types contains common types in the Kubelet.
|
||||
package types // import "k8s.io/kubernetes/pkg/kubelet/types"
|
45
vendor/k8s.io/kubernetes/pkg/kubelet/types/labels.go
generated
vendored
45
vendor/k8s.io/kubernetes/pkg/kubelet/types/labels.go
generated
vendored
@ -1,45 +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 types
|
||||
|
||||
// Label keys for labels used in this package.
|
||||
const (
|
||||
KubernetesPodNameLabel = "io.kubernetes.pod.name"
|
||||
KubernetesPodNamespaceLabel = "io.kubernetes.pod.namespace"
|
||||
KubernetesPodUIDLabel = "io.kubernetes.pod.uid"
|
||||
KubernetesContainerNameLabel = "io.kubernetes.container.name"
|
||||
)
|
||||
|
||||
// GetContainerName returns the value of the KubernetesContainerNameLabel.
|
||||
func GetContainerName(labels map[string]string) string {
|
||||
return labels[KubernetesContainerNameLabel]
|
||||
}
|
||||
|
||||
// GetPodName returns the value of the KubernetesPodNameLabel.
|
||||
func GetPodName(labels map[string]string) string {
|
||||
return labels[KubernetesPodNameLabel]
|
||||
}
|
||||
|
||||
// GetPodUID returns the value of the KubernetesPodUIDLabel.
|
||||
func GetPodUID(labels map[string]string) string {
|
||||
return labels[KubernetesPodUIDLabel]
|
||||
}
|
||||
|
||||
// GetPodNamespace returns the value of the KubernetesPodNamespaceLabel.
|
||||
func GetPodNamespace(labels map[string]string) string {
|
||||
return labels[KubernetesPodNamespaceLabel]
|
||||
}
|
39
vendor/k8s.io/kubernetes/pkg/kubelet/types/pod_status.go
generated
vendored
39
vendor/k8s.io/kubernetes/pkg/kubelet/types/pod_status.go
generated
vendored
@ -1,39 +0,0 @@
|
||||
/*
|
||||
Copyright 2018 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 types
|
||||
|
||||
import (
|
||||
v1 "k8s.io/api/core/v1"
|
||||
)
|
||||
|
||||
// PodConditionsByKubelet is the list of pod conditions owned by kubelet
|
||||
var PodConditionsByKubelet = []v1.PodConditionType{
|
||||
v1.PodScheduled,
|
||||
v1.PodReady,
|
||||
v1.PodInitialized,
|
||||
v1.ContainersReady,
|
||||
}
|
||||
|
||||
// PodConditionByKubelet returns if the pod condition type is owned by kubelet
|
||||
func PodConditionByKubelet(conditionType v1.PodConditionType) bool {
|
||||
for _, c := range PodConditionsByKubelet {
|
||||
if c == conditionType {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
194
vendor/k8s.io/kubernetes/pkg/kubelet/types/pod_update.go
generated
vendored
194
vendor/k8s.io/kubernetes/pkg/kubelet/types/pod_update.go
generated
vendored
@ -1,194 +0,0 @@
|
||||
/*
|
||||
Copyright 2014 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 types
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
v1 "k8s.io/api/core/v1"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/kubernetes/pkg/apis/scheduling"
|
||||
)
|
||||
|
||||
// Annotation keys for annotations used in this package.
|
||||
const (
|
||||
ConfigSourceAnnotationKey = "kubernetes.io/config.source"
|
||||
ConfigMirrorAnnotationKey = v1.MirrorPodAnnotationKey
|
||||
ConfigFirstSeenAnnotationKey = "kubernetes.io/config.seen"
|
||||
ConfigHashAnnotationKey = "kubernetes.io/config.hash"
|
||||
)
|
||||
|
||||
// PodOperation defines what changes will be made on a pod configuration.
|
||||
type PodOperation int
|
||||
|
||||
// These constants identify the PodOperations that can be made on a pod configuration.
|
||||
const (
|
||||
// SET is the current pod configuration.
|
||||
SET PodOperation = iota
|
||||
// ADD signifies pods that are new to this source.
|
||||
ADD
|
||||
// DELETE signifies pods that are gracefully deleted from this source.
|
||||
DELETE
|
||||
// REMOVE signifies pods that have been removed from this source.
|
||||
REMOVE
|
||||
// UPDATE signifies pods have been updated in this source.
|
||||
UPDATE
|
||||
// RECONCILE signifies pods that have unexpected status in this source,
|
||||
// kubelet should reconcile status with this source.
|
||||
RECONCILE
|
||||
)
|
||||
|
||||
// These constants identify the sources of pods.
|
||||
const (
|
||||
// Filesource idenitified updates from a file.
|
||||
FileSource = "file"
|
||||
// HTTPSource identifies updates from querying a web page.
|
||||
HTTPSource = "http"
|
||||
// ApiserverSource identifies updates from Kubernetes API Server.
|
||||
ApiserverSource = "api"
|
||||
// AllSource identifies updates from all sources.
|
||||
AllSource = "*"
|
||||
)
|
||||
|
||||
// NamespaceDefault is a string representing the default namespace.
|
||||
const NamespaceDefault = metav1.NamespaceDefault
|
||||
|
||||
// PodUpdate defines an operation sent on the channel. You can add or remove single services by
|
||||
// sending an array of size one and Op == ADD|REMOVE (with REMOVE, only the ID is required).
|
||||
// For setting the state of the system to a given state for this source configuration, set
|
||||
// Pods as desired and Op to SET, which will reset the system state to that specified in this
|
||||
// operation for this source channel. To remove all pods, set Pods to empty object and Op to SET.
|
||||
//
|
||||
// Additionally, Pods should never be nil - it should always point to an empty slice. While
|
||||
// functionally similar, this helps our unit tests properly check that the correct PodUpdates
|
||||
// are generated.
|
||||
type PodUpdate struct {
|
||||
Pods []*v1.Pod
|
||||
Op PodOperation
|
||||
Source string
|
||||
}
|
||||
|
||||
// GetValidatedSources gets all validated sources from the specified sources.
|
||||
func GetValidatedSources(sources []string) ([]string, error) {
|
||||
validated := make([]string, 0, len(sources))
|
||||
for _, source := range sources {
|
||||
switch source {
|
||||
case AllSource:
|
||||
return []string{FileSource, HTTPSource, ApiserverSource}, nil
|
||||
case FileSource, HTTPSource, ApiserverSource:
|
||||
validated = append(validated, source)
|
||||
case "":
|
||||
// Skip
|
||||
default:
|
||||
return []string{}, fmt.Errorf("unknown pod source %q", source)
|
||||
}
|
||||
}
|
||||
return validated, nil
|
||||
}
|
||||
|
||||
// GetPodSource returns the source of the pod based on the annotation.
|
||||
func GetPodSource(pod *v1.Pod) (string, error) {
|
||||
if pod.Annotations != nil {
|
||||
if source, ok := pod.Annotations[ConfigSourceAnnotationKey]; ok {
|
||||
return source, nil
|
||||
}
|
||||
}
|
||||
return "", fmt.Errorf("cannot get source of pod %q", pod.UID)
|
||||
}
|
||||
|
||||
// SyncPodType classifies pod updates, eg: create, update.
|
||||
type SyncPodType int
|
||||
|
||||
const (
|
||||
// SyncPodSync is when the pod is synced to ensure desired state
|
||||
SyncPodSync SyncPodType = iota
|
||||
// SyncPodUpdate is when the pod is updated from source
|
||||
SyncPodUpdate
|
||||
// SyncPodCreate is when the pod is created from source
|
||||
SyncPodCreate
|
||||
// SyncPodKill is when the pod should have no running containers. A pod stopped in this way could be
|
||||
// restarted in the future due config changes.
|
||||
SyncPodKill
|
||||
)
|
||||
|
||||
func (sp SyncPodType) String() string {
|
||||
switch sp {
|
||||
case SyncPodCreate:
|
||||
return "create"
|
||||
case SyncPodUpdate:
|
||||
return "update"
|
||||
case SyncPodSync:
|
||||
return "sync"
|
||||
case SyncPodKill:
|
||||
return "kill"
|
||||
default:
|
||||
return "unknown"
|
||||
}
|
||||
}
|
||||
|
||||
// IsMirrorPod returns true if the passed Pod is a Mirror Pod.
|
||||
func IsMirrorPod(pod *v1.Pod) bool {
|
||||
if pod.Annotations == nil {
|
||||
return false
|
||||
}
|
||||
_, ok := pod.Annotations[ConfigMirrorAnnotationKey]
|
||||
return ok
|
||||
}
|
||||
|
||||
// IsStaticPod returns true if the pod is a static pod.
|
||||
func IsStaticPod(pod *v1.Pod) bool {
|
||||
source, err := GetPodSource(pod)
|
||||
return err == nil && source != ApiserverSource
|
||||
}
|
||||
|
||||
// IsCriticalPod returns true if pod's priority is greater than or equal to SystemCriticalPriority.
|
||||
func IsCriticalPod(pod *v1.Pod) bool {
|
||||
if IsStaticPod(pod) {
|
||||
return true
|
||||
}
|
||||
if IsMirrorPod(pod) {
|
||||
return true
|
||||
}
|
||||
if pod.Spec.Priority != nil && IsCriticalPodBasedOnPriority(*pod.Spec.Priority) {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
// Preemptable returns true if preemptor pod can preempt preemptee pod
|
||||
// if preemptee is not critical or if preemptor's priority is greater than preemptee's priority
|
||||
func Preemptable(preemptor, preemptee *v1.Pod) bool {
|
||||
if IsCriticalPod(preemptor) && !IsCriticalPod(preemptee) {
|
||||
return true
|
||||
}
|
||||
if (preemptor != nil && preemptor.Spec.Priority != nil) &&
|
||||
(preemptee != nil && preemptee.Spec.Priority != nil) {
|
||||
return *(preemptor.Spec.Priority) > *(preemptee.Spec.Priority)
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
// IsCriticalPodBasedOnPriority checks if the given pod is a critical pod based on priority resolved from pod Spec.
|
||||
func IsCriticalPodBasedOnPriority(priority int32) bool {
|
||||
return priority >= scheduling.SystemCriticalPriority
|
||||
}
|
||||
|
||||
// IsNodeCriticalPod checks if the given pod is a system-node-critical
|
||||
func IsNodeCriticalPod(pod *v1.Pod) bool {
|
||||
return IsCriticalPod(pod) && (pod.Spec.PriorityClassName == scheduling.SystemNodeCritical)
|
||||
}
|
115
vendor/k8s.io/kubernetes/pkg/kubelet/types/types.go
generated
vendored
115
vendor/k8s.io/kubernetes/pkg/kubelet/types/types.go
generated
vendored
@ -1,115 +0,0 @@
|
||||
/*
|
||||
Copyright 2015 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 types
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"time"
|
||||
|
||||
v1 "k8s.io/api/core/v1"
|
||||
"k8s.io/apimachinery/pkg/types"
|
||||
)
|
||||
|
||||
// TODO: Reconcile custom types in kubelet/types and this subpackage
|
||||
|
||||
// HTTPGetter is an interface representing the ability to perform HTTP GET requests.
|
||||
type HTTPGetter interface {
|
||||
// Get issues a GET to the specified URL.
|
||||
Get(url string) (*http.Response, error)
|
||||
}
|
||||
|
||||
// Timestamp wraps around time.Time and offers utilities to format and parse
|
||||
// the time using RFC3339Nano
|
||||
type Timestamp struct {
|
||||
time time.Time
|
||||
}
|
||||
|
||||
// NewTimestamp returns a Timestamp object using the current time.
|
||||
func NewTimestamp() *Timestamp {
|
||||
return &Timestamp{time.Now()}
|
||||
}
|
||||
|
||||
// ConvertToTimestamp takes a string, parses it using the RFC3339NanoLenient layout,
|
||||
// and converts it to a Timestamp object.
|
||||
func ConvertToTimestamp(timeString string) *Timestamp {
|
||||
parsed, _ := time.Parse(RFC3339NanoLenient, timeString)
|
||||
return &Timestamp{parsed}
|
||||
}
|
||||
|
||||
// Get returns the time as time.Time.
|
||||
func (t *Timestamp) Get() time.Time {
|
||||
return t.time
|
||||
}
|
||||
|
||||
// GetString returns the time in the string format using the RFC3339NanoFixed
|
||||
// layout.
|
||||
func (t *Timestamp) GetString() string {
|
||||
return t.time.Format(RFC3339NanoFixed)
|
||||
}
|
||||
|
||||
// SortedContainerStatuses is a type to help sort container statuses based on container names.
|
||||
type SortedContainerStatuses []v1.ContainerStatus
|
||||
|
||||
func (s SortedContainerStatuses) Len() int { return len(s) }
|
||||
func (s SortedContainerStatuses) Swap(i, j int) { s[i], s[j] = s[j], s[i] }
|
||||
|
||||
func (s SortedContainerStatuses) Less(i, j int) bool {
|
||||
return s[i].Name < s[j].Name
|
||||
}
|
||||
|
||||
// SortInitContainerStatuses ensures that statuses are in the order that their
|
||||
// init container appears in the pod spec
|
||||
func SortInitContainerStatuses(p *v1.Pod, statuses []v1.ContainerStatus) {
|
||||
containers := p.Spec.InitContainers
|
||||
current := 0
|
||||
for _, container := range containers {
|
||||
for j := current; j < len(statuses); j++ {
|
||||
if container.Name == statuses[j].Name {
|
||||
statuses[current], statuses[j] = statuses[j], statuses[current]
|
||||
current++
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// SortStatusesOfInitContainers returns the statuses of InitContainers of pod p,
|
||||
// in the order that they appear in its spec.
|
||||
func SortStatusesOfInitContainers(p *v1.Pod, statusMap map[string]*v1.ContainerStatus) []v1.ContainerStatus {
|
||||
containers := p.Spec.InitContainers
|
||||
statuses := []v1.ContainerStatus{}
|
||||
for _, container := range containers {
|
||||
if status, found := statusMap[container.Name]; found {
|
||||
statuses = append(statuses, *status)
|
||||
}
|
||||
}
|
||||
return statuses
|
||||
}
|
||||
|
||||
// Reservation represents reserved resources for non-pod components.
|
||||
type Reservation struct {
|
||||
// System represents resources reserved for non-kubernetes components.
|
||||
System v1.ResourceList
|
||||
// Kubernetes represents resources reserved for kubernetes system components.
|
||||
Kubernetes v1.ResourceList
|
||||
}
|
||||
|
||||
// ResolvedPodUID is a pod UID which has been translated/resolved to the representation known to kubelets.
|
||||
type ResolvedPodUID types.UID
|
||||
|
||||
// MirrorPodUID is a pod UID for a mirror pod.
|
||||
type MirrorPodUID types.UID
|
Reference in New Issue
Block a user