mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-13 05:46:16 +00:00
move kubelet constant for podreadytostart to staging
This commit is contained in:
parent
755644a169
commit
c94240e2e2
@ -674,8 +674,9 @@ const (
|
|||||||
// Set pod completion index as a pod label for Indexed Jobs.
|
// Set pod completion index as a pod label for Indexed Jobs.
|
||||||
PodIndexLabel featuregate.Feature = "PodIndexLabel"
|
PodIndexLabel featuregate.Feature = "PodIndexLabel"
|
||||||
|
|
||||||
// owner: @ddebroy
|
// owner: @ddebroy, @kannon92
|
||||||
// alpha: v1.25
|
// alpha: v1.25
|
||||||
|
// beta: v1.29
|
||||||
//
|
//
|
||||||
// Enables reporting of PodReadyToStartContainersCondition condition in pod status after pod
|
// Enables reporting of PodReadyToStartContainersCondition condition in pod status after pod
|
||||||
// sandbox creation and network configuration completes successfully
|
// sandbox creation and network configuration completes successfully
|
||||||
@ -1132,7 +1133,7 @@ var defaultKubernetesFeatureGates = map[featuregate.Feature]featuregate.FeatureS
|
|||||||
|
|
||||||
PodDisruptionConditions: {Default: true, PreRelease: featuregate.Beta},
|
PodDisruptionConditions: {Default: true, PreRelease: featuregate.Beta},
|
||||||
|
|
||||||
PodReadyToStartContainersCondition: {Default: false, PreRelease: featuregate.Alpha},
|
PodReadyToStartContainersCondition: {Default: true, PreRelease: featuregate.Beta},
|
||||||
|
|
||||||
PodHostIPs: {Default: false, PreRelease: featuregate.Alpha},
|
PodHostIPs: {Default: false, PreRelease: featuregate.Alpha},
|
||||||
|
|
||||||
|
@ -3367,7 +3367,7 @@ func Test_generateAPIPodStatus(t *testing.T) {
|
|||||||
LastTransitionTime: normalized_now,
|
LastTransitionTime: normalized_now,
|
||||||
},
|
},
|
||||||
expectedPodReadyToStartContainersCondition: v1.PodCondition{
|
expectedPodReadyToStartContainersCondition: v1.PodCondition{
|
||||||
Type: kubetypes.PodReadyToStartContainers,
|
Type: v1.PodReadyToStartContainers,
|
||||||
Status: v1.ConditionTrue,
|
Status: v1.ConditionTrue,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -3408,7 +3408,7 @@ func Test_generateAPIPodStatus(t *testing.T) {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
expectedPodReadyToStartContainersCondition: v1.PodCondition{
|
expectedPodReadyToStartContainersCondition: v1.PodCondition{
|
||||||
Type: kubetypes.PodReadyToStartContainers,
|
Type: v1.PodReadyToStartContainers,
|
||||||
Status: v1.ConditionTrue,
|
Status: v1.ConditionTrue,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -3448,7 +3448,7 @@ func Test_generateAPIPodStatus(t *testing.T) {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
expectedPodReadyToStartContainersCondition: v1.PodCondition{
|
expectedPodReadyToStartContainersCondition: v1.PodCondition{
|
||||||
Type: kubetypes.PodReadyToStartContainers,
|
Type: v1.PodReadyToStartContainers,
|
||||||
Status: v1.ConditionTrue,
|
Status: v1.ConditionTrue,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -3489,7 +3489,7 @@ func Test_generateAPIPodStatus(t *testing.T) {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
expectedPodReadyToStartContainersCondition: v1.PodCondition{
|
expectedPodReadyToStartContainersCondition: v1.PodCondition{
|
||||||
Type: kubetypes.PodReadyToStartContainers,
|
Type: v1.PodReadyToStartContainers,
|
||||||
Status: v1.ConditionFalse,
|
Status: v1.ConditionFalse,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -3536,7 +3536,7 @@ func Test_generateAPIPodStatus(t *testing.T) {
|
|||||||
Message: "test",
|
Message: "test",
|
||||||
},
|
},
|
||||||
expectedPodReadyToStartContainersCondition: v1.PodCondition{
|
expectedPodReadyToStartContainersCondition: v1.PodCondition{
|
||||||
Type: kubetypes.PodReadyToStartContainers,
|
Type: v1.PodReadyToStartContainers,
|
||||||
Status: v1.ConditionFalse,
|
Status: v1.ConditionFalse,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -3590,7 +3590,7 @@ func Test_generateAPIPodStatus(t *testing.T) {
|
|||||||
Message: "test",
|
Message: "test",
|
||||||
},
|
},
|
||||||
expectedPodReadyToStartContainersCondition: v1.PodCondition{
|
expectedPodReadyToStartContainersCondition: v1.PodCondition{
|
||||||
Type: kubetypes.PodReadyToStartContainers,
|
Type: v1.PodReadyToStartContainers,
|
||||||
Status: v1.ConditionFalse,
|
Status: v1.ConditionFalse,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -3631,7 +3631,7 @@ func Test_generateAPIPodStatus(t *testing.T) {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
expectedPodReadyToStartContainersCondition: v1.PodCondition{
|
expectedPodReadyToStartContainersCondition: v1.PodCondition{
|
||||||
Type: kubetypes.PodReadyToStartContainers,
|
Type: v1.PodReadyToStartContainers,
|
||||||
Status: v1.ConditionTrue,
|
Status: v1.ConditionTrue,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -3687,7 +3687,7 @@ func Test_generateAPIPodStatus(t *testing.T) {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
expectedPodReadyToStartContainersCondition: v1.PodCondition{
|
expectedPodReadyToStartContainersCondition: v1.PodCondition{
|
||||||
Type: kubetypes.PodReadyToStartContainers,
|
Type: v1.PodReadyToStartContainers,
|
||||||
Status: v1.ConditionTrue,
|
Status: v1.ConditionTrue,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -3747,7 +3747,7 @@ func Test_generateAPIPodStatus(t *testing.T) {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
expectedPodReadyToStartContainersCondition: v1.PodCondition{
|
expectedPodReadyToStartContainersCondition: v1.PodCondition{
|
||||||
Type: kubetypes.PodReadyToStartContainers,
|
Type: v1.PodReadyToStartContainers,
|
||||||
Status: v1.ConditionTrue,
|
Status: v1.ConditionTrue,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -247,12 +247,12 @@ func GeneratePodReadyToStartContainersCondition(pod *v1.Pod, podStatus *kubecont
|
|||||||
// fresh sandbox and configure networking for the sandbox.
|
// fresh sandbox and configure networking for the sandbox.
|
||||||
if !newSandboxNeeded {
|
if !newSandboxNeeded {
|
||||||
return v1.PodCondition{
|
return v1.PodCondition{
|
||||||
Type: kubetypes.PodReadyToStartContainers,
|
Type: v1.PodReadyToStartContainers,
|
||||||
Status: v1.ConditionTrue,
|
Status: v1.ConditionTrue,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return v1.PodCondition{
|
return v1.PodCondition{
|
||||||
Type: kubetypes.PodReadyToStartContainers,
|
Type: v1.PodReadyToStartContainers,
|
||||||
Status: v1.ConditionFalse,
|
Status: v1.ConditionFalse,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -26,7 +26,6 @@ import (
|
|||||||
v1 "k8s.io/api/core/v1"
|
v1 "k8s.io/api/core/v1"
|
||||||
runtimeapi "k8s.io/cri-api/pkg/apis/runtime/v1"
|
runtimeapi "k8s.io/cri-api/pkg/apis/runtime/v1"
|
||||||
kubecontainer "k8s.io/kubernetes/pkg/kubelet/container"
|
kubecontainer "k8s.io/kubernetes/pkg/kubelet/container"
|
||||||
kubetypes "k8s.io/kubernetes/pkg/kubelet/types"
|
|
||||||
"k8s.io/utils/pointer"
|
"k8s.io/utils/pointer"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -615,7 +614,7 @@ func TestGeneratePodReadyToStartContainersCondition(t *testing.T) {
|
|||||||
},
|
},
|
||||||
} {
|
} {
|
||||||
t.Run(desc, func(t *testing.T) {
|
t.Run(desc, func(t *testing.T) {
|
||||||
test.expected.Type = kubetypes.PodReadyToStartContainers
|
test.expected.Type = v1.PodReadyToStartContainers
|
||||||
condition := GeneratePodReadyToStartContainersCondition(test.pod, test.status)
|
condition := GeneratePodReadyToStartContainersCondition(test.pod, test.status)
|
||||||
require.Equal(t, test.expected.Type, condition.Type)
|
require.Equal(t, test.expected.Type, condition.Type)
|
||||||
require.Equal(t, test.expected.Status, condition.Status)
|
require.Equal(t, test.expected.Status, condition.Status)
|
||||||
|
@ -634,7 +634,7 @@ func (m *manager) updateStatusInternal(pod *v1.Pod, status v1.PodStatus, forceUp
|
|||||||
updateLastTransitionTime(&status, &oldStatus, v1.PodInitialized)
|
updateLastTransitionTime(&status, &oldStatus, v1.PodInitialized)
|
||||||
|
|
||||||
// Set PodReadyToStartContainersCondition.LastTransitionTime.
|
// Set PodReadyToStartContainersCondition.LastTransitionTime.
|
||||||
updateLastTransitionTime(&status, &oldStatus, kubetypes.PodReadyToStartContainers)
|
updateLastTransitionTime(&status, &oldStatus, v1.PodReadyToStartContainers)
|
||||||
|
|
||||||
// Set PodScheduledCondition.LastTransitionTime.
|
// Set PodScheduledCondition.LastTransitionTime.
|
||||||
updateLastTransitionTime(&status, &oldStatus, v1.PodScheduled)
|
updateLastTransitionTime(&status, &oldStatus, v1.PodScheduled)
|
||||||
|
@ -38,12 +38,3 @@ const (
|
|||||||
LimitedSwap = "LimitedSwap"
|
LimitedSwap = "LimitedSwap"
|
||||||
UnlimitedSwap = "UnlimitedSwap"
|
UnlimitedSwap = "UnlimitedSwap"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Alpha conditions managed by Kubelet that are not yet part of the API. The
|
|
||||||
// entries here should be moved to staging/src/k8s.io.api/core/v1/types.go
|
|
||||||
// once the feature managing the condition graduates to Beta.
|
|
||||||
const (
|
|
||||||
// PodReadyToStartContainers pod sandbox is successfully configured and
|
|
||||||
// the pod is ready to launch containers.
|
|
||||||
PodReadyToStartContainers = "PodReadyToStartContainers"
|
|
||||||
)
|
|
||||||
|
@ -38,7 +38,7 @@ func PodConditionByKubelet(conditionType v1.PodConditionType) bool {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if utilfeature.DefaultFeatureGate.Enabled(features.PodReadyToStartContainersCondition) {
|
if utilfeature.DefaultFeatureGate.Enabled(features.PodReadyToStartContainersCondition) {
|
||||||
if conditionType == PodReadyToStartContainers {
|
if conditionType == v1.PodReadyToStartContainers {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -34,7 +34,7 @@ func TestPodConditionByKubelet(t *testing.T) {
|
|||||||
v1.PodReady,
|
v1.PodReady,
|
||||||
v1.PodInitialized,
|
v1.PodInitialized,
|
||||||
v1.ContainersReady,
|
v1.ContainersReady,
|
||||||
PodReadyToStartContainers,
|
v1.PodReadyToStartContainers,
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, tc := range trueCases {
|
for _, tc := range trueCases {
|
||||||
|
@ -2866,6 +2866,9 @@ const (
|
|||||||
// DisruptionTarget indicates the pod is about to be terminated due to a
|
// DisruptionTarget indicates the pod is about to be terminated due to a
|
||||||
// disruption (such as preemption, eviction API or garbage-collection).
|
// disruption (such as preemption, eviction API or garbage-collection).
|
||||||
DisruptionTarget PodConditionType = "DisruptionTarget"
|
DisruptionTarget PodConditionType = "DisruptionTarget"
|
||||||
|
// PodReadyToStartContainers pod sandbox is successfully configured and
|
||||||
|
// the pod is ready to launch containers.
|
||||||
|
PodReadyToStartContainers PodConditionType = "PodReadyToStartContainers"
|
||||||
)
|
)
|
||||||
|
|
||||||
// These are reasons for a pod's transition to a condition.
|
// These are reasons for a pod's transition to a condition.
|
||||||
|
@ -30,7 +30,6 @@ import (
|
|||||||
"k8s.io/apimachinery/pkg/fields"
|
"k8s.io/apimachinery/pkg/fields"
|
||||||
"k8s.io/apimachinery/pkg/util/uuid"
|
"k8s.io/apimachinery/pkg/util/uuid"
|
||||||
"k8s.io/kubernetes/pkg/kubelet/events"
|
"k8s.io/kubernetes/pkg/kubelet/events"
|
||||||
kubetypes "k8s.io/kubernetes/pkg/kubelet/types"
|
|
||||||
"k8s.io/kubernetes/test/e2e/framework"
|
"k8s.io/kubernetes/test/e2e/framework"
|
||||||
e2eevents "k8s.io/kubernetes/test/e2e/framework/events"
|
e2eevents "k8s.io/kubernetes/test/e2e/framework/events"
|
||||||
e2epod "k8s.io/kubernetes/test/e2e/framework/pod"
|
e2epod "k8s.io/kubernetes/test/e2e/framework/pod"
|
||||||
@ -41,6 +40,7 @@ import (
|
|||||||
kubeletconfig "k8s.io/kubernetes/pkg/kubelet/apis/config"
|
kubeletconfig "k8s.io/kubernetes/pkg/kubelet/apis/config"
|
||||||
|
|
||||||
"github.com/onsi/ginkgo/v2"
|
"github.com/onsi/ginkgo/v2"
|
||||||
|
"github.com/onsi/gomega"
|
||||||
)
|
)
|
||||||
|
|
||||||
var _ = SIGDescribe("Pod conditions managed by Kubelet", func() {
|
var _ = SIGDescribe("Pod conditions managed by Kubelet", func() {
|
||||||
@ -113,7 +113,7 @@ func runPodFailingConditionsTest(f *framework.Framework, hasInitContainers, chec
|
|||||||
|
|
||||||
// Verify PodReadyToStartContainers is not set (since sandboxcreation is blocked)
|
// Verify PodReadyToStartContainers is not set (since sandboxcreation is blocked)
|
||||||
if checkPodReadyToStart {
|
if checkPodReadyToStart {
|
||||||
_, err := getTransitionTimeForPodConditionWithStatus(p, kubetypes.PodReadyToStartContainers, false)
|
_, err := getTransitionTimeForPodConditionWithStatus(p, v1.PodReadyToStartContainers, false)
|
||||||
framework.ExpectNoError(err)
|
framework.ExpectNoError(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -125,9 +125,7 @@ func runPodFailingConditionsTest(f *framework.Framework, hasInitContainers, chec
|
|||||||
// Verify PodInitialized is set if init containers are not present (since without init containers, it gets set very early)
|
// Verify PodInitialized is set if init containers are not present (since without init containers, it gets set very early)
|
||||||
initializedTime, err := getTransitionTimeForPodConditionWithStatus(p, v1.PodInitialized, true)
|
initializedTime, err := getTransitionTimeForPodConditionWithStatus(p, v1.PodInitialized, true)
|
||||||
framework.ExpectNoError(err)
|
framework.ExpectNoError(err)
|
||||||
if initializedTime.Before(scheduledTime) {
|
gomega.Expect(initializedTime.Before(scheduledTime)).NotTo(gomega.BeTrue(), fmt.Sprintf("pod without init containers is initialized at: %v which is before pod scheduled at: %v", initializedTime, scheduledTime))
|
||||||
framework.Failf("pod without init containers is initialized at: %v which is before pod scheduled at: %v", initializedTime, scheduledTime)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Verify ContainersReady is not set (since sandboxcreation is blocked)
|
// Verify ContainersReady is not set (since sandboxcreation is blocked)
|
||||||
@ -164,47 +162,33 @@ func runPodReadyConditionsTest(f *framework.Framework, hasInitContainers, checkP
|
|||||||
condBeforeContainersReadyTransitionTime := initializedTime
|
condBeforeContainersReadyTransitionTime := initializedTime
|
||||||
errSubstrIfContainersReadyTooEarly := "is initialized"
|
errSubstrIfContainersReadyTooEarly := "is initialized"
|
||||||
if checkPodReadyToStart {
|
if checkPodReadyToStart {
|
||||||
readyToStartContainersTime, err := getTransitionTimeForPodConditionWithStatus(p, kubetypes.PodReadyToStartContainers, true)
|
readyToStartContainersTime, err := getTransitionTimeForPodConditionWithStatus(p, v1.PodReadyToStartContainers, true)
|
||||||
framework.ExpectNoError(err)
|
framework.ExpectNoError(err)
|
||||||
|
|
||||||
if hasInitContainers {
|
if hasInitContainers {
|
||||||
// With init containers, verify the sequence of conditions is: Scheduled => PodReadyToStartContainers => Initialized
|
// With init containers, verify the sequence of conditions is: Scheduled => PodReadyToStartContainers => Initialized
|
||||||
if readyToStartContainersTime.Before(scheduledTime) {
|
gomega.Expect(readyToStartContainersTime.Before(scheduledTime)).ToNot(gomega.BeTrue(), fmt.Sprintf("pod with init containers is initialized at: %v which is before pod has ready to start at: %v", initializedTime, readyToStartContainersTime))
|
||||||
framework.Failf("pod with init containers is initialized at: %v which is before pod has ready to start at: %v", initializedTime, readyToStartContainersTime)
|
gomega.Expect(initializedTime.Before(readyToStartContainersTime)).ToNot(gomega.BeTrue(), fmt.Sprintf("pod with init containers is initialized at: %v which is before pod has ready to start at: %v", initializedTime, readyToStartContainersTime))
|
||||||
}
|
|
||||||
if initializedTime.Before(readyToStartContainersTime) {
|
|
||||||
framework.Failf("pod with init containers is initialized at: %v which is before pod has ready to start at: %v", initializedTime, readyToStartContainersTime)
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
// Without init containers, verify the sequence of conditions is: Scheduled => Initialized => PodReadyToStartContainers
|
// Without init containers, verify the sequence of conditions is: Scheduled => Initialized => PodReadyToStartContainers
|
||||||
condBeforeContainersReadyTransitionTime = readyToStartContainersTime
|
condBeforeContainersReadyTransitionTime = readyToStartContainersTime
|
||||||
errSubstrIfContainersReadyTooEarly = "ready to start"
|
errSubstrIfContainersReadyTooEarly = "ready to start"
|
||||||
if initializedTime.Before(scheduledTime) {
|
gomega.Expect(initializedTime.Before(scheduledTime)).NotTo(gomega.BeTrue(), fmt.Sprintf("pod without init containers initialized at: %v which is before pod scheduled at: %v", initializedTime, scheduledTime))
|
||||||
framework.Failf("pod without init containers initialized at: %v which is before pod scheduled at: %v", initializedTime, scheduledTime)
|
gomega.Expect(readyToStartContainersTime.Before(initializedTime)).NotTo(gomega.BeTrue(), fmt.Sprintf("pod without init containers has ready to start at: %v which is before pod is initialized at: %v", readyToStartContainersTime, initializedTime))
|
||||||
}
|
|
||||||
if readyToStartContainersTime.Before(initializedTime) {
|
|
||||||
framework.Failf("pod without init containers has ready to start at: %v which is before pod is initialized at: %v", readyToStartContainersTime, initializedTime)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// In the absence of PodHasReadyToStartContainers feature disabled, verify the sequence is: Scheduled => Initialized
|
// In the absence of PodHasReadyToStartContainers feature disabled, verify the sequence is: Scheduled => Initialized
|
||||||
if initializedTime.Before(scheduledTime) {
|
gomega.Expect(initializedTime.Before(scheduledTime)).NotTo(gomega.BeTrue(), fmt.Sprintf("pod initialized at: %v which is before pod scheduled at: %v", initializedTime, scheduledTime))
|
||||||
framework.Failf("pod initialized at: %v which is before pod scheduled at: %v", initializedTime, scheduledTime)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
// Verify the next condition to get set is ContainersReady
|
// Verify the next condition to get set is ContainersReady
|
||||||
containersReadyTime, err := getTransitionTimeForPodConditionWithStatus(p, v1.ContainersReady, true)
|
containersReadyTime, err := getTransitionTimeForPodConditionWithStatus(p, v1.ContainersReady, true)
|
||||||
framework.ExpectNoError(err)
|
framework.ExpectNoError(err)
|
||||||
if containersReadyTime.Before(condBeforeContainersReadyTransitionTime) {
|
gomega.Expect(containersReadyTime.Before(condBeforeContainersReadyTransitionTime)).NotTo(gomega.BeTrue(), fmt.Sprintf("containers ready at: %v which is before pod %s: %v", containersReadyTime, errSubstrIfContainersReadyTooEarly, initializedTime))
|
||||||
framework.Failf("containers ready at: %v which is before pod %s: %v", containersReadyTime, errSubstrIfContainersReadyTooEarly, initializedTime)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Verify ContainersReady => PodReady
|
// Verify ContainersReady => PodReady
|
||||||
podReadyTime, err := getTransitionTimeForPodConditionWithStatus(p, v1.PodReady, true)
|
podReadyTime, err := getTransitionTimeForPodConditionWithStatus(p, v1.PodReady, true)
|
||||||
framework.ExpectNoError(err)
|
framework.ExpectNoError(err)
|
||||||
if podReadyTime.Before(containersReadyTime) {
|
gomega.Expect(podReadyTime.Before(containersReadyTime)).NotTo(gomega.BeTrue(), fmt.Sprintf("pod ready at: %v which is before pod containers ready at: %v", podReadyTime, containersReadyTime))
|
||||||
framework.Failf("pod ready at: %v which is before pod containers ready at: %v", podReadyTime, containersReadyTime)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user