mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-16 23:29:21 +00:00
feat: rename PodHasNetwork to PodReadyToStartContainers
This commit is contained in:
parent
f871d5fabe
commit
5f489a3327
@ -630,9 +630,9 @@ const (
|
|||||||
// owner: @ddebroy
|
// owner: @ddebroy
|
||||||
// alpha: v1.25
|
// alpha: v1.25
|
||||||
//
|
//
|
||||||
// Enables reporting of PodHasNetwork 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
|
||||||
PodHasNetworkCondition featuregate.Feature = "PodHasNetworkCondition"
|
PodReadyToStartContainersCondition featuregate.Feature = "PodReadyToStartContainersCondition"
|
||||||
|
|
||||||
// owner: @Huang-Wei
|
// owner: @Huang-Wei
|
||||||
// kep: https://kep.k8s.io/3521
|
// kep: https://kep.k8s.io/3521
|
||||||
@ -1043,7 +1043,7 @@ var defaultKubernetesFeatureGates = map[featuregate.Feature]featuregate.FeatureS
|
|||||||
|
|
||||||
PodDisruptionConditions: {Default: true, PreRelease: featuregate.Beta},
|
PodDisruptionConditions: {Default: true, PreRelease: featuregate.Beta},
|
||||||
|
|
||||||
PodHasNetworkCondition: {Default: false, PreRelease: featuregate.Alpha},
|
PodReadyToStartContainersCondition: {Default: false, PreRelease: featuregate.Alpha},
|
||||||
|
|
||||||
PodSchedulingReadiness: {Default: true, PreRelease: featuregate.Beta},
|
PodSchedulingReadiness: {Default: true, PreRelease: featuregate.Beta},
|
||||||
|
|
||||||
|
@ -1605,8 +1605,8 @@ func (kl *Kubelet) generateAPIPodStatus(pod *v1.Pod, podStatus *kubecontainer.Po
|
|||||||
}
|
}
|
||||||
|
|
||||||
// set all Kubelet-owned conditions
|
// set all Kubelet-owned conditions
|
||||||
if utilfeature.DefaultFeatureGate.Enabled(features.PodHasNetworkCondition) {
|
if utilfeature.DefaultFeatureGate.Enabled(features.PodReadyToStartContainersCondition) {
|
||||||
s.Conditions = append(s.Conditions, status.GeneratePodHasNetworkCondition(pod, podStatus))
|
s.Conditions = append(s.Conditions, status.GeneratePodReadyToStartContainersCondition(pod, podStatus))
|
||||||
}
|
}
|
||||||
s.Conditions = append(s.Conditions, status.GeneratePodInitializedCondition(&pod.Spec, s.InitContainerStatuses, s.Phase))
|
s.Conditions = append(s.Conditions, status.GeneratePodInitializedCondition(&pod.Spec, s.InitContainerStatuses, s.Phase))
|
||||||
s.Conditions = append(s.Conditions, status.GeneratePodReadyCondition(&pod.Spec, s.Conditions, s.ContainerStatuses, s.Phase))
|
s.Conditions = append(s.Conditions, status.GeneratePodReadyCondition(&pod.Spec, s.Conditions, s.ContainerStatuses, s.Phase))
|
||||||
|
@ -2819,16 +2819,16 @@ func Test_generateAPIPodStatus(t *testing.T) {
|
|||||||
normalized_now := now.Rfc3339Copy()
|
normalized_now := now.Rfc3339Copy()
|
||||||
|
|
||||||
tests := []struct {
|
tests := []struct {
|
||||||
name string
|
name string
|
||||||
pod *v1.Pod
|
pod *v1.Pod
|
||||||
currentStatus *kubecontainer.PodStatus
|
currentStatus *kubecontainer.PodStatus
|
||||||
unreadyContainer []string
|
unreadyContainer []string
|
||||||
previousStatus v1.PodStatus
|
previousStatus v1.PodStatus
|
||||||
isPodTerminal bool
|
isPodTerminal bool
|
||||||
enablePodDisruptionConditions bool
|
enablePodDisruptionConditions bool
|
||||||
expected v1.PodStatus
|
expected v1.PodStatus
|
||||||
expectedPodDisruptionCondition v1.PodCondition
|
expectedPodDisruptionCondition v1.PodCondition
|
||||||
expectedPodHasNetworkCondition v1.PodCondition
|
expectedPodReadyToStartContainersCondition v1.PodCondition
|
||||||
}{
|
}{
|
||||||
{
|
{
|
||||||
name: "pod disruption condition is copied over and the phase is set to failed when deleted; PodDisruptionConditions enabled",
|
name: "pod disruption condition is copied over and the phase is set to failed when deleted; PodDisruptionConditions enabled",
|
||||||
@ -2881,8 +2881,8 @@ func Test_generateAPIPodStatus(t *testing.T) {
|
|||||||
Status: v1.ConditionTrue,
|
Status: v1.ConditionTrue,
|
||||||
LastTransitionTime: normalized_now,
|
LastTransitionTime: normalized_now,
|
||||||
},
|
},
|
||||||
expectedPodHasNetworkCondition: v1.PodCondition{
|
expectedPodReadyToStartContainersCondition: v1.PodCondition{
|
||||||
Type: kubetypes.PodHasNetwork,
|
Type: kubetypes.PodReadyToStartContainers,
|
||||||
Status: v1.ConditionTrue,
|
Status: v1.ConditionTrue,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -2920,8 +2920,8 @@ func Test_generateAPIPodStatus(t *testing.T) {
|
|||||||
ready(waitingWithLastTerminationUnknown("containerB", 0)),
|
ready(waitingWithLastTerminationUnknown("containerB", 0)),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
expectedPodHasNetworkCondition: v1.PodCondition{
|
expectedPodReadyToStartContainersCondition: v1.PodCondition{
|
||||||
Type: kubetypes.PodHasNetwork,
|
Type: kubetypes.PodReadyToStartContainers,
|
||||||
Status: v1.ConditionTrue,
|
Status: v1.ConditionTrue,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -2958,8 +2958,8 @@ func Test_generateAPIPodStatus(t *testing.T) {
|
|||||||
ready(waitingWithLastTerminationUnknown("containerB", 1)),
|
ready(waitingWithLastTerminationUnknown("containerB", 1)),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
expectedPodHasNetworkCondition: v1.PodCondition{
|
expectedPodReadyToStartContainersCondition: v1.PodCondition{
|
||||||
Type: kubetypes.PodHasNetwork,
|
Type: kubetypes.PodReadyToStartContainers,
|
||||||
Status: v1.ConditionTrue,
|
Status: v1.ConditionTrue,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -2997,8 +2997,8 @@ func Test_generateAPIPodStatus(t *testing.T) {
|
|||||||
ready(waitingWithLastTerminationUnknown("containerB", 1)),
|
ready(waitingWithLastTerminationUnknown("containerB", 1)),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
expectedPodHasNetworkCondition: v1.PodCondition{
|
expectedPodReadyToStartContainersCondition: v1.PodCondition{
|
||||||
Type: kubetypes.PodHasNetwork,
|
Type: kubetypes.PodReadyToStartContainers,
|
||||||
Status: v1.ConditionFalse,
|
Status: v1.ConditionFalse,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -3042,8 +3042,8 @@ func Test_generateAPIPodStatus(t *testing.T) {
|
|||||||
Reason: "Test",
|
Reason: "Test",
|
||||||
Message: "test",
|
Message: "test",
|
||||||
},
|
},
|
||||||
expectedPodHasNetworkCondition: v1.PodCondition{
|
expectedPodReadyToStartContainersCondition: v1.PodCondition{
|
||||||
Type: kubetypes.PodHasNetwork,
|
Type: kubetypes.PodReadyToStartContainers,
|
||||||
Status: v1.ConditionFalse,
|
Status: v1.ConditionFalse,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -3094,8 +3094,8 @@ func Test_generateAPIPodStatus(t *testing.T) {
|
|||||||
Reason: "Test",
|
Reason: "Test",
|
||||||
Message: "test",
|
Message: "test",
|
||||||
},
|
},
|
||||||
expectedPodHasNetworkCondition: v1.PodCondition{
|
expectedPodReadyToStartContainersCondition: v1.PodCondition{
|
||||||
Type: kubetypes.PodHasNetwork,
|
Type: kubetypes.PodReadyToStartContainers,
|
||||||
Status: v1.ConditionFalse,
|
Status: v1.ConditionFalse,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -3133,8 +3133,8 @@ func Test_generateAPIPodStatus(t *testing.T) {
|
|||||||
ready(waitingStateWithReason("containerB", "ContainerCreating")),
|
ready(waitingStateWithReason("containerB", "ContainerCreating")),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
expectedPodHasNetworkCondition: v1.PodCondition{
|
expectedPodReadyToStartContainersCondition: v1.PodCondition{
|
||||||
Type: kubetypes.PodHasNetwork,
|
Type: kubetypes.PodReadyToStartContainers,
|
||||||
Status: v1.ConditionTrue,
|
Status: v1.ConditionTrue,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -3187,8 +3187,8 @@ func Test_generateAPIPodStatus(t *testing.T) {
|
|||||||
ready(withID(runningStateWithStartedAt("containerB", time.Unix(1, 0).UTC()), "://foo")),
|
ready(withID(runningStateWithStartedAt("containerB", time.Unix(1, 0).UTC()), "://foo")),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
expectedPodHasNetworkCondition: v1.PodCondition{
|
expectedPodReadyToStartContainersCondition: v1.PodCondition{
|
||||||
Type: kubetypes.PodHasNetwork,
|
Type: kubetypes.PodReadyToStartContainers,
|
||||||
Status: v1.ConditionTrue,
|
Status: v1.ConditionTrue,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -3245,17 +3245,17 @@ func Test_generateAPIPodStatus(t *testing.T) {
|
|||||||
ready(withID(runningStateWithStartedAt("containerB", time.Unix(2, 0).UTC()), "://c2")),
|
ready(withID(runningStateWithStartedAt("containerB", time.Unix(2, 0).UTC()), "://c2")),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
expectedPodHasNetworkCondition: v1.PodCondition{
|
expectedPodReadyToStartContainersCondition: v1.PodCondition{
|
||||||
Type: kubetypes.PodHasNetwork,
|
Type: kubetypes.PodReadyToStartContainers,
|
||||||
Status: v1.ConditionTrue,
|
Status: v1.ConditionTrue,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
for _, test := range tests {
|
for _, test := range tests {
|
||||||
for _, enablePodHasNetworkCondition := range []bool{false, true} {
|
for _, enablePodReadyToStartContainersCondition := range []bool{false, true} {
|
||||||
t.Run(test.name, func(t *testing.T) {
|
t.Run(test.name, func(t *testing.T) {
|
||||||
defer featuregatetesting.SetFeatureGateDuringTest(t, utilfeature.DefaultFeatureGate, features.PodDisruptionConditions, test.enablePodDisruptionConditions)()
|
defer featuregatetesting.SetFeatureGateDuringTest(t, utilfeature.DefaultFeatureGate, features.PodDisruptionConditions, test.enablePodDisruptionConditions)()
|
||||||
defer featuregatetesting.SetFeatureGateDuringTest(t, utilfeature.DefaultFeatureGate, features.PodHasNetworkCondition, enablePodHasNetworkCondition)()
|
defer featuregatetesting.SetFeatureGateDuringTest(t, utilfeature.DefaultFeatureGate, features.PodReadyToStartContainersCondition, enablePodReadyToStartContainersCondition)()
|
||||||
testKubelet := newTestKubelet(t, false /* controllerAttachDetachEnabled */)
|
testKubelet := newTestKubelet(t, false /* controllerAttachDetachEnabled */)
|
||||||
defer testKubelet.Cleanup()
|
defer testKubelet.Cleanup()
|
||||||
kl := testKubelet.kubelet
|
kl := testKubelet.kubelet
|
||||||
@ -3265,8 +3265,8 @@ func Test_generateAPIPodStatus(t *testing.T) {
|
|||||||
}
|
}
|
||||||
expected := test.expected.DeepCopy()
|
expected := test.expected.DeepCopy()
|
||||||
actual := kl.generateAPIPodStatus(test.pod, test.currentStatus, test.isPodTerminal)
|
actual := kl.generateAPIPodStatus(test.pod, test.currentStatus, test.isPodTerminal)
|
||||||
if enablePodHasNetworkCondition {
|
if enablePodReadyToStartContainersCondition {
|
||||||
expected.Conditions = append([]v1.PodCondition{test.expectedPodHasNetworkCondition}, expected.Conditions...)
|
expected.Conditions = append([]v1.PodCondition{test.expectedPodReadyToStartContainersCondition}, expected.Conditions...)
|
||||||
}
|
}
|
||||||
if test.enablePodDisruptionConditions {
|
if test.enablePodDisruptionConditions {
|
||||||
expected.Conditions = append([]v1.PodCondition{test.expectedPodDisruptionCondition}, expected.Conditions...)
|
expected.Conditions = append([]v1.PodCondition{test.expectedPodDisruptionCondition}, expected.Conditions...)
|
||||||
|
@ -198,7 +198,7 @@ func GeneratePodInitializedCondition(spec *v1.PodSpec, containerStatuses []v1.Co
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func GeneratePodHasNetworkCondition(pod *v1.Pod, podStatus *kubecontainer.PodStatus) v1.PodCondition {
|
func GeneratePodReadyToStartContainersCondition(pod *v1.Pod, podStatus *kubecontainer.PodStatus) v1.PodCondition {
|
||||||
newSandboxNeeded, _, _ := runtimeutil.PodSandboxChanged(pod, podStatus)
|
newSandboxNeeded, _, _ := runtimeutil.PodSandboxChanged(pod, podStatus)
|
||||||
// if a new sandbox does not need to be created for a pod, it indicates that
|
// if a new sandbox does not need to be created for a pod, it indicates that
|
||||||
// a sandbox for the pod with networking configured already exists.
|
// a sandbox for the pod with networking configured already exists.
|
||||||
@ -206,12 +206,12 @@ func GeneratePodHasNetworkCondition(pod *v1.Pod, podStatus *kubecontainer.PodSta
|
|||||||
// 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.PodHasNetwork,
|
Type: kubetypes.PodReadyToStartContainers,
|
||||||
Status: v1.ConditionTrue,
|
Status: v1.ConditionTrue,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return v1.PodCondition{
|
return v1.PodCondition{
|
||||||
Type: kubetypes.PodHasNetwork,
|
Type: kubetypes.PodReadyToStartContainers,
|
||||||
Status: v1.ConditionFalse,
|
Status: v1.ConditionFalse,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -422,7 +422,7 @@ func TestGeneratePodInitializedCondition(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestGeneratePodHasNetworkCondition(t *testing.T) {
|
func TestGeneratePodReadyToStartContainersCondition(t *testing.T) {
|
||||||
for desc, test := range map[string]struct {
|
for desc, test := range map[string]struct {
|
||||||
pod *v1.Pod
|
pod *v1.Pod
|
||||||
status *kubecontainer.PodStatus
|
status *kubecontainer.PodStatus
|
||||||
@ -485,8 +485,8 @@ func TestGeneratePodHasNetworkCondition(t *testing.T) {
|
|||||||
},
|
},
|
||||||
} {
|
} {
|
||||||
t.Run(desc, func(t *testing.T) {
|
t.Run(desc, func(t *testing.T) {
|
||||||
test.expected.Type = kubetypes.PodHasNetwork
|
test.expected.Type = kubetypes.PodReadyToStartContainers
|
||||||
condition := GeneratePodHasNetworkCondition(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)
|
||||||
})
|
})
|
||||||
|
@ -589,8 +589,8 @@ func (m *manager) updateStatusInternal(pod *v1.Pod, status v1.PodStatus, forceUp
|
|||||||
// Set InitializedCondition.LastTransitionTime.
|
// Set InitializedCondition.LastTransitionTime.
|
||||||
updateLastTransitionTime(&status, &oldStatus, v1.PodInitialized)
|
updateLastTransitionTime(&status, &oldStatus, v1.PodInitialized)
|
||||||
|
|
||||||
// Set PodHasNetwork.LastTransitionTime.
|
// Set PodReadyToStartContainersCondition.LastTransitionTime.
|
||||||
updateLastTransitionTime(&status, &oldStatus, kubetypes.PodHasNetwork)
|
updateLastTransitionTime(&status, &oldStatus, kubetypes.PodReadyToStartContainers)
|
||||||
|
|
||||||
// Set PodScheduledCondition.LastTransitionTime.
|
// Set PodScheduledCondition.LastTransitionTime.
|
||||||
updateLastTransitionTime(&status, &oldStatus, v1.PodScheduled)
|
updateLastTransitionTime(&status, &oldStatus, v1.PodScheduled)
|
||||||
|
@ -43,8 +43,7 @@ const (
|
|||||||
// entries here should be moved to staging/src/k8s.io.api/core/v1/types.go
|
// entries here should be moved to staging/src/k8s.io.api/core/v1/types.go
|
||||||
// once the feature managing the condition graduates to Beta.
|
// once the feature managing the condition graduates to Beta.
|
||||||
const (
|
const (
|
||||||
// PodHasNetwork indicates networking has been configured successfully for the
|
// PodReadyToStartContainers pod sandbox is successfully configured and
|
||||||
// pod and IP address(es) assigned. Images for containers specified in the pod
|
// the pod is ready to launch containers.
|
||||||
// spec can be pulled and containers launched after this condition is true.
|
PodReadyToStartContainers = "PodReadyToStartContainers"
|
||||||
PodHasNetwork = "PodHasNetwork"
|
|
||||||
)
|
)
|
||||||
|
@ -37,8 +37,8 @@ func PodConditionByKubelet(conditionType v1.PodConditionType) bool {
|
|||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if utilfeature.DefaultFeatureGate.Enabled(features.PodHasNetworkCondition) {
|
if utilfeature.DefaultFeatureGate.Enabled(features.PodReadyToStartContainersCondition) {
|
||||||
if conditionType == PodHasNetwork {
|
if conditionType == PodReadyToStartContainers {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -26,7 +26,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func TestPodConditionByKubelet(t *testing.T) {
|
func TestPodConditionByKubelet(t *testing.T) {
|
||||||
defer featuregatetesting.SetFeatureGateDuringTest(t, utilfeature.DefaultFeatureGate, features.PodHasNetworkCondition, true)()
|
defer featuregatetesting.SetFeatureGateDuringTest(t, utilfeature.DefaultFeatureGate, features.PodReadyToStartContainersCondition, true)()
|
||||||
defer featuregatetesting.SetFeatureGateDuringTest(t, utilfeature.DefaultFeatureGate, features.PodDisruptionConditions, true)()
|
defer featuregatetesting.SetFeatureGateDuringTest(t, utilfeature.DefaultFeatureGate, features.PodDisruptionConditions, true)()
|
||||||
|
|
||||||
trueCases := []v1.PodConditionType{
|
trueCases := []v1.PodConditionType{
|
||||||
@ -34,7 +34,7 @@ func TestPodConditionByKubelet(t *testing.T) {
|
|||||||
v1.PodReady,
|
v1.PodReady,
|
||||||
v1.PodInitialized,
|
v1.PodInitialized,
|
||||||
v1.ContainersReady,
|
v1.ContainersReady,
|
||||||
PodHasNetwork,
|
PodReadyToStartContainers,
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, tc := range trueCases {
|
for _, tc := range trueCases {
|
||||||
|
@ -47,10 +47,10 @@ var _ = SIGDescribe("Pod conditions managed by Kubelet", func() {
|
|||||||
f := framework.NewDefaultFramework("pod-conditions")
|
f := framework.NewDefaultFramework("pod-conditions")
|
||||||
f.NamespacePodSecurityEnforceLevel = admissionapi.LevelBaseline
|
f.NamespacePodSecurityEnforceLevel = admissionapi.LevelBaseline
|
||||||
|
|
||||||
ginkgo.Context("including PodHasNetwork condition [Serial] [Feature:PodHasNetwork]", func() {
|
ginkgo.Context("including PodReadyToStartContainers condition [Serial] [Feature:PodReadyToStartContainersCondition]", func() {
|
||||||
tempSetCurrentKubeletConfig(f, func(ctx context.Context, initialConfig *kubeletconfig.KubeletConfiguration) {
|
tempSetCurrentKubeletConfig(f, func(ctx context.Context, initialConfig *kubeletconfig.KubeletConfiguration) {
|
||||||
initialConfig.FeatureGates = map[string]bool{
|
initialConfig.FeatureGates = map[string]bool{
|
||||||
string(features.PodHasNetworkCondition): true,
|
string(features.PodReadyToStartContainersCondition): true,
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
ginkgo.It("a pod without init containers should report all conditions set in expected order after the pod is up", runPodReadyConditionsTest(f, false, true))
|
ginkgo.It("a pod without init containers should report all conditions set in expected order after the pod is up", runPodReadyConditionsTest(f, false, true))
|
||||||
@ -59,7 +59,7 @@ var _ = SIGDescribe("Pod conditions managed by Kubelet", func() {
|
|||||||
ginkgo.It("a pod failing to mount volumes and with init containers should report just the scheduled condition set", runPodFailingConditionsTest(f, true, true))
|
ginkgo.It("a pod failing to mount volumes and with init containers should report just the scheduled condition set", runPodFailingConditionsTest(f, true, true))
|
||||||
})
|
})
|
||||||
|
|
||||||
ginkgo.Context("without PodHasNetwork condition", func() {
|
ginkgo.Context("without PodReadyToStartContainersCondition condition", func() {
|
||||||
ginkgo.It("a pod without init containers should report all conditions set in expected order after the pod is up", runPodReadyConditionsTest(f, false, false))
|
ginkgo.It("a pod without init containers should report all conditions set in expected order after the pod is up", runPodReadyConditionsTest(f, false, false))
|
||||||
ginkgo.It("a pod with init containers should report all conditions set in expected order after the pod is up", runPodReadyConditionsTest(f, true, false))
|
ginkgo.It("a pod with init containers should report all conditions set in expected order after the pod is up", runPodReadyConditionsTest(f, true, false))
|
||||||
ginkgo.It("a pod failing to mount volumes and without init containers should report scheduled and initialized conditions set", runPodFailingConditionsTest(f, false, false))
|
ginkgo.It("a pod failing to mount volumes and without init containers should report scheduled and initialized conditions set", runPodFailingConditionsTest(f, false, false))
|
||||||
@ -67,7 +67,7 @@ var _ = SIGDescribe("Pod conditions managed by Kubelet", func() {
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
func runPodFailingConditionsTest(f *framework.Framework, hasInitContainers, checkPodHasNetwork bool) func(ctx context.Context) {
|
func runPodFailingConditionsTest(f *framework.Framework, hasInitContainers, checkPodReadyToStart bool) func(ctx context.Context) {
|
||||||
return func(ctx context.Context) {
|
return func(ctx context.Context) {
|
||||||
ginkgo.By("creating a pod whose sandbox creation is blocked due to a missing volume")
|
ginkgo.By("creating a pod whose sandbox creation is blocked due to a missing volume")
|
||||||
|
|
||||||
@ -109,9 +109,9 @@ func runPodFailingConditionsTest(f *framework.Framework, hasInitContainers, chec
|
|||||||
scheduledTime, err := getTransitionTimeForPodConditionWithStatus(p, v1.PodScheduled, true)
|
scheduledTime, err := getTransitionTimeForPodConditionWithStatus(p, v1.PodScheduled, true)
|
||||||
framework.ExpectNoError(err)
|
framework.ExpectNoError(err)
|
||||||
|
|
||||||
// Verify PodHasNetwork is not set (since sandboxcreation is blocked)
|
// Verify PodReadyToStartContainers is not set (since sandboxcreation is blocked)
|
||||||
if checkPodHasNetwork {
|
if checkPodReadyToStart {
|
||||||
_, err := getTransitionTimeForPodConditionWithStatus(p, kubetypes.PodHasNetwork, false)
|
_, err := getTransitionTimeForPodConditionWithStatus(p, kubetypes.PodReadyToStartContainers, false)
|
||||||
framework.ExpectNoError(err)
|
framework.ExpectNoError(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -135,7 +135,7 @@ func runPodFailingConditionsTest(f *framework.Framework, hasInitContainers, chec
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func runPodReadyConditionsTest(f *framework.Framework, hasInitContainers, checkPodHasNetwork bool) func(ctx context.Context) {
|
func runPodReadyConditionsTest(f *framework.Framework, hasInitContainers, checkPodReadyToStart bool) func(ctx context.Context) {
|
||||||
return func(ctx context.Context) {
|
return func(ctx context.Context) {
|
||||||
ginkgo.By("creating a pod that successfully comes up in a ready/running state")
|
ginkgo.By("creating a pod that successfully comes up in a ready/running state")
|
||||||
|
|
||||||
@ -157,23 +157,23 @@ func runPodReadyConditionsTest(f *framework.Framework, hasInitContainers, checkP
|
|||||||
|
|
||||||
condBeforeContainersReadyTransitionTime := initializedTime
|
condBeforeContainersReadyTransitionTime := initializedTime
|
||||||
errSubstrIfContainersReadyTooEarly := "is initialized"
|
errSubstrIfContainersReadyTooEarly := "is initialized"
|
||||||
if checkPodHasNetwork {
|
if checkPodReadyToStart {
|
||||||
hasNetworkTime, err := getTransitionTimeForPodConditionWithStatus(p, kubetypes.PodHasNetwork, true)
|
readyToStartContainersTime, err := getTransitionTimeForPodConditionWithStatus(p, kubetypes.PodReadyToStartContainers, true)
|
||||||
framework.ExpectNoError(err)
|
framework.ExpectNoError(err)
|
||||||
|
|
||||||
if hasInitContainers {
|
if hasInitContainers {
|
||||||
// With init containers, verify the sequence of conditions is: Scheduled => HasNetwork => Initialized
|
// With init containers, verify the sequence of conditions is: Scheduled => PodReadyToStartContainers => Initialized
|
||||||
framework.ExpectNotEqual(hasNetworkTime.Before(scheduledTime), true, fmt.Sprintf("pod with init containers is initialized at: %v which is before pod has network at: %v", initializedTime, hasNetworkTime))
|
framework.ExpectNotEqual(readyToStartContainersTime.Before(scheduledTime), true, fmt.Sprintf("pod with init containers is initialized at: %v which is before pod has ready to start at: %v", initializedTime, readyToStartContainersTime))
|
||||||
framework.ExpectNotEqual(initializedTime.Before(hasNetworkTime), true, fmt.Sprintf("pod with init containers is initialized at: %v which is before pod has network at: %v", initializedTime, hasNetworkTime))
|
framework.ExpectNotEqual(initializedTime.Before(readyToStartContainersTime), true, fmt.Sprintf("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 => HasNetwork
|
// Without init containers, verify the sequence of conditions is: Scheduled => Initialized => PodReadyToStartContainers
|
||||||
condBeforeContainersReadyTransitionTime = hasNetworkTime
|
condBeforeContainersReadyTransitionTime = readyToStartContainersTime
|
||||||
errSubstrIfContainersReadyTooEarly = "has network"
|
errSubstrIfContainersReadyTooEarly = "ready to start"
|
||||||
framework.ExpectNotEqual(initializedTime.Before(scheduledTime), true, fmt.Sprintf("pod without init containers initialized at: %v which is before pod scheduled at: %v", initializedTime, scheduledTime))
|
framework.ExpectNotEqual(initializedTime.Before(scheduledTime), true, fmt.Sprintf("pod without init containers initialized at: %v which is before pod scheduled at: %v", initializedTime, scheduledTime))
|
||||||
framework.ExpectNotEqual(hasNetworkTime.Before(initializedTime), true, fmt.Sprintf("pod without init containers has network at: %v which is before pod is initialized at: %v", hasNetworkTime, initializedTime))
|
framework.ExpectNotEqual(readyToStartContainersTime.Before(initializedTime), true, fmt.Sprintf("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 HasNetwork feature disabled, verify the sequence is: Scheduled => Initialized
|
// In the absence of PodHasReadyToStartContainers feature disabled, verify the sequence is: Scheduled => Initialized
|
||||||
framework.ExpectNotEqual(initializedTime.Before(scheduledTime), true, fmt.Sprintf("pod initialized at: %v which is before pod scheduled at: %v", initializedTime, scheduledTime))
|
framework.ExpectNotEqual(initializedTime.Before(scheduledTime), true, fmt.Sprintf("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
|
||||||
|
Loading…
Reference in New Issue
Block a user