Skip to content

Commit 8d27bf2

Browse files
committed
Leave TODOs in pkg/kubelet/kuberuntime for later removal
This leaves TODOs in pkg/kubelet/kuberuntime to remove these redundant code paths later, since they are supposed to be a subset of the new code paths.
1 parent 0bee0bc commit 8d27bf2

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

pkg/kubelet/kuberuntime/kuberuntime_container.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -929,6 +929,8 @@ func (m *kubeGenericRuntimeManager) purgeInitContainers(ctx context.Context, pod
929929
// index of next init container to start, or done if there are no further init containers.
930930
// Status is only returned if an init container is failed, in which case next will
931931
// point to the current container.
932+
// TODO: Remove this function as this is a subset of the
933+
// computeInitContainerActions.
932934
func findNextInitContainerToRun(pod *v1.Pod, podStatus *kubecontainer.PodStatus) (status *kubecontainer.Status, next *v1.Container, done bool) {
933935
if len(pod.Spec.InitContainers) == 0 {
934936
return nil, nil, true

pkg/kubelet/kuberuntime/kuberuntime_manager.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -496,6 +496,8 @@ type podActions struct {
496496
Attempt uint32
497497

498498
// The next init container to start.
499+
// TODO: Either this or InitContainersToStart will be used. Remove this
500+
// field once it is not needed.
499501
NextInitContainerToStart *v1.Container
500502
// InitContainersToStart keeps a list of indexes for the init containers to
501503
// start, where the index is the index of the specific init container in the
@@ -934,6 +936,8 @@ func (m *kubeGenericRuntimeManager) computePodActions(ctx context.Context, pod *
934936
// is done and there is no container to start.
935937
if len(containersToStart) == 0 {
936938
hasInitialized := false
939+
// TODO: Remove this code path as logically it is the subset of the next
940+
// code path.
937941
if !handleRestartableInitContainers {
938942
_, _, hasInitialized = findNextInitContainerToRun(pod, podStatus)
939943
} else {
@@ -952,6 +956,8 @@ func (m *kubeGenericRuntimeManager) computePodActions(ctx context.Context, pod *
952956
// state.
953957
if len(pod.Spec.InitContainers) != 0 {
954958
// Pod has init containers, return the first one.
959+
// TODO: Remove this code path as logically it is the subset of the next
960+
// code path.
955961
if !handleRestartableInitContainers {
956962
changes.NextInitContainerToStart = &pod.Spec.InitContainers[0]
957963
} else {
@@ -975,6 +981,8 @@ func (m *kubeGenericRuntimeManager) computePodActions(ctx context.Context, pod *
975981
}
976982

977983
// Check initialization progress.
984+
// TODO: Remove this code path as logically it is the subset of the next
985+
// code path.
978986
if !handleRestartableInitContainers {
979987
initLastStatus, next, done := findNextInitContainerToRun(pod, podStatus)
980988
if !done {
@@ -1095,6 +1103,8 @@ func (m *kubeGenericRuntimeManager) computePodActions(ctx context.Context, pod *
10951103

10961104
if keepCount == 0 && len(changes.ContainersToStart) == 0 {
10971105
changes.KillPod = true
1106+
// TODO: Remove this code path as logically it is the subset of the next
1107+
// code path.
10981108
if handleRestartableInitContainers {
10991109
// To prevent the restartable init containers to keep pod alive, we should
11001110
// not restart them.
@@ -1353,6 +1363,8 @@ func (m *kubeGenericRuntimeManager) SyncPod(ctx context.Context, pod *v1.Pod, po
13531363
start(ctx, "ephemeral container", metrics.EphemeralContainer, ephemeralContainerStartSpec(&pod.Spec.EphemeralContainers[idx]))
13541364
}
13551365

1366+
// TODO: Remove this code path as logically it is the subset of the next
1367+
// code path.
13561368
if !types.HasRestartableInitContainer(pod) {
13571369
// Step 6: start the init container.
13581370
if container := podContainerChanges.NextInitContainerToStart; container != nil {

0 commit comments

Comments
 (0)