Skip to content

Commit

Permalink
move kubelet constant for podreadytostart to staging
Browse files Browse the repository at this point in the history
  • Loading branch information
kannon92 committed Jul 28, 2023
1 parent 97c7dbc commit c67ff58
Show file tree
Hide file tree
Showing 10 changed files with 23 additions and 30 deletions.
5 changes: 3 additions & 2 deletions pkg/features/kube_features.go
Original file line number Diff line number Diff line change
Expand Up @@ -664,8 +664,9 @@ const (
// Set pod completion index as a pod label for Indexed Jobs.
PodIndexLabel featuregate.Feature = "PodIndexLabel"

// owner: @ddebroy
// owner: @ddebroy, @kannon92
// alpha: v1.25
// beta: v1.29
//
// Enables reporting of PodReadyToStartContainersCondition condition in pod status after pod
// sandbox creation and network configuration completes successfully
Expand Down Expand Up @@ -1119,7 +1120,7 @@ var defaultKubernetesFeatureGates = map[featuregate.Feature]featuregate.FeatureS

PodDisruptionConditions: {Default: true, PreRelease: featuregate.Beta},

PodReadyToStartContainersCondition: {Default: false, PreRelease: featuregate.Alpha},
PodReadyToStartContainersCondition: {Default: true, PreRelease: featuregate.Beta},

PodHostIPs: {Default: false, PreRelease: featuregate.Alpha},

Expand Down
18 changes: 9 additions & 9 deletions pkg/kubelet/kubelet_pods_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3367,7 +3367,7 @@ func Test_generateAPIPodStatus(t *testing.T) {
LastTransitionTime: normalized_now,
},
expectedPodReadyToStartContainersCondition: v1.PodCondition{
Type: kubetypes.PodReadyToStartContainers,
Type: v1.PodReadyToStartContainers,
Status: v1.ConditionTrue,
},
},
Expand Down Expand Up @@ -3408,7 +3408,7 @@ func Test_generateAPIPodStatus(t *testing.T) {
},
},
expectedPodReadyToStartContainersCondition: v1.PodCondition{
Type: kubetypes.PodReadyToStartContainers,
Type: v1.PodReadyToStartContainers,
Status: v1.ConditionTrue,
},
},
Expand Down Expand Up @@ -3448,7 +3448,7 @@ func Test_generateAPIPodStatus(t *testing.T) {
},
},
expectedPodReadyToStartContainersCondition: v1.PodCondition{
Type: kubetypes.PodReadyToStartContainers,
Type: v1.PodReadyToStartContainers,
Status: v1.ConditionTrue,
},
},
Expand Down Expand Up @@ -3489,7 +3489,7 @@ func Test_generateAPIPodStatus(t *testing.T) {
},
},
expectedPodReadyToStartContainersCondition: v1.PodCondition{
Type: kubetypes.PodReadyToStartContainers,
Type: v1.PodReadyToStartContainers,
Status: v1.ConditionFalse,
},
},
Expand Down Expand Up @@ -3536,7 +3536,7 @@ func Test_generateAPIPodStatus(t *testing.T) {
Message: "test",
},
expectedPodReadyToStartContainersCondition: v1.PodCondition{
Type: kubetypes.PodReadyToStartContainers,
Type: v1.PodReadyToStartContainers,
Status: v1.ConditionFalse,
},
},
Expand Down Expand Up @@ -3590,7 +3590,7 @@ func Test_generateAPIPodStatus(t *testing.T) {
Message: "test",
},
expectedPodReadyToStartContainersCondition: v1.PodCondition{
Type: kubetypes.PodReadyToStartContainers,
Type: v1.PodReadyToStartContainers,
Status: v1.ConditionFalse,
},
},
Expand Down Expand Up @@ -3631,7 +3631,7 @@ func Test_generateAPIPodStatus(t *testing.T) {
},
},
expectedPodReadyToStartContainersCondition: v1.PodCondition{
Type: kubetypes.PodReadyToStartContainers,
Type: v1.PodReadyToStartContainers,
Status: v1.ConditionTrue,
},
},
Expand Down Expand Up @@ -3687,7 +3687,7 @@ func Test_generateAPIPodStatus(t *testing.T) {
},
},
expectedPodReadyToStartContainersCondition: v1.PodCondition{
Type: kubetypes.PodReadyToStartContainers,
Type: v1.PodReadyToStartContainers,
Status: v1.ConditionTrue,
},
},
Expand Down Expand Up @@ -3747,7 +3747,7 @@ func Test_generateAPIPodStatus(t *testing.T) {
},
},
expectedPodReadyToStartContainersCondition: v1.PodCondition{
Type: kubetypes.PodReadyToStartContainers,
Type: v1.PodReadyToStartContainers,
Status: v1.ConditionTrue,
},
},
Expand Down
4 changes: 2 additions & 2 deletions pkg/kubelet/status/generate.go
Original file line number Diff line number Diff line change
Expand Up @@ -247,12 +247,12 @@ func GeneratePodReadyToStartContainersCondition(pod *v1.Pod, podStatus *kubecont
// fresh sandbox and configure networking for the sandbox.
if !newSandboxNeeded {
return v1.PodCondition{
Type: kubetypes.PodReadyToStartContainers,
Type: v1.PodReadyToStartContainers,
Status: v1.ConditionTrue,
}
}
return v1.PodCondition{
Type: kubetypes.PodReadyToStartContainers,
Type: v1.PodReadyToStartContainers,
Status: v1.ConditionFalse,
}
}
Expand Down
3 changes: 1 addition & 2 deletions pkg/kubelet/status/generate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ import (
v1 "k8s.io/api/core/v1"
runtimeapi "k8s.io/cri-api/pkg/apis/runtime/v1"
kubecontainer "k8s.io/kubernetes/pkg/kubelet/container"
kubetypes "k8s.io/kubernetes/pkg/kubelet/types"
"k8s.io/utils/pointer"
)

Expand Down Expand Up @@ -615,7 +614,7 @@ func TestGeneratePodReadyToStartContainersCondition(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)
require.Equal(t, test.expected.Type, condition.Type)
require.Equal(t, test.expected.Status, condition.Status)
Expand Down
2 changes: 1 addition & 1 deletion pkg/kubelet/status/status_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -634,7 +634,7 @@ func (m *manager) updateStatusInternal(pod *v1.Pod, status v1.PodStatus, forceUp
updateLastTransitionTime(&status, &oldStatus, v1.PodInitialized)

// Set PodReadyToStartContainersCondition.LastTransitionTime.
updateLastTransitionTime(&status, &oldStatus, kubetypes.PodReadyToStartContainers)
updateLastTransitionTime(&status, &oldStatus, v1.PodReadyToStartContainers)

// Set PodScheduledCondition.LastTransitionTime.
updateLastTransitionTime(&status, &oldStatus, v1.PodScheduled)
Expand Down
9 changes: 0 additions & 9 deletions pkg/kubelet/types/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,3 @@ const (
LimitedSwap = "LimitedSwap"
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"
)
2 changes: 1 addition & 1 deletion pkg/kubelet/types/pod_status.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ func PodConditionByKubelet(conditionType v1.PodConditionType) bool {
}
}
if utilfeature.DefaultFeatureGate.Enabled(features.PodReadyToStartContainersCondition) {
if conditionType == PodReadyToStartContainers {
if conditionType == v1.PodReadyToStartContainers {
return true
}
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/kubelet/types/pod_status_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ func TestPodConditionByKubelet(t *testing.T) {
v1.PodReady,
v1.PodInitialized,
v1.ContainersReady,
PodReadyToStartContainers,
v1.PodReadyToStartContainers,
}

for _, tc := range trueCases {
Expand Down
3 changes: 3 additions & 0 deletions staging/src/k8s.io/api/core/v1/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -2845,6 +2845,9 @@ const (
// DisruptionTarget indicates the pod is about to be terminated due to a
// disruption (such as preemption, eviction API or garbage-collection).
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.
Expand Down
5 changes: 2 additions & 3 deletions test/e2e_node/pod_conditions_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ import (
"k8s.io/apimachinery/pkg/fields"
"k8s.io/apimachinery/pkg/util/uuid"
"k8s.io/kubernetes/pkg/kubelet/events"
kubetypes "k8s.io/kubernetes/pkg/kubelet/types"
"k8s.io/kubernetes/test/e2e/framework"
e2eevents "k8s.io/kubernetes/test/e2e/framework/events"
e2epod "k8s.io/kubernetes/test/e2e/framework/pod"
Expand Down Expand Up @@ -113,7 +112,7 @@ func runPodFailingConditionsTest(f *framework.Framework, hasInitContainers, chec

// Verify PodReadyToStartContainers is not set (since sandboxcreation is blocked)
if checkPodReadyToStart {
_, err := getTransitionTimeForPodConditionWithStatus(p, kubetypes.PodReadyToStartContainers, false)
_, err := getTransitionTimeForPodConditionWithStatus(p, v1.PodReadyToStartContainers, false)
framework.ExpectNoError(err)
}

Expand Down Expand Up @@ -160,7 +159,7 @@ func runPodReadyConditionsTest(f *framework.Framework, hasInitContainers, checkP
condBeforeContainersReadyTransitionTime := initializedTime
errSubstrIfContainersReadyTooEarly := "is initialized"
if checkPodReadyToStart {
readyToStartContainersTime, err := getTransitionTimeForPodConditionWithStatus(p, kubetypes.PodReadyToStartContainers, true)
readyToStartContainersTime, err := getTransitionTimeForPodConditionWithStatus(p, v1.PodReadyToStartContainers, true)
framework.ExpectNoError(err)

if hasInitContainers {
Expand Down

0 comments on commit c67ff58

Please sign in to comment.