kubernetes: [FG:InPlacePodVerticalScaling] Pod Resize - resize stuck in "InProgress"

What happened?

I am trying the the feature gate “InPlacePodVerticalScaling”. I tried on multiple environment/versions and the result is always the same. Resize is forever stuck in “InProgress”.

I followed the doc: https://kubernetes.io/docs/tasks/configure-pod-container/resize-container-resources/

What did you expect to happen?

Resize field in pod status should go to complete

How can we reproduce it (as minimally and precisely as possible)?

Follow this doc: https://kubernetes.io/docs/tasks/configure-pod-container/resize-container-resources/

Anything else we need to know?

No response

Kubernetes version

I tested with kubernetes version 1.27 and 1.29 with the same result. containerd version being v1.6.28.

The 2 requirements being (from my understanding): kubernetes >=v1.27 containerd >=v1.6.9

Cloud provider

I tried on GKE and locally with Minikube

OS version

mac sonoma 14.1.2 (m1)

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Comments: 22 (17 by maintainers)

Most upvoted comments

The kubelet actually never touches the resize status field. The only reference is in PrepareForUpdate in the API server, which sets it to InProgress. It looks like this portion of the KEP was never really implemented.

EDIT: I don’t know why I thought that was the case… I must have been looking at the wrong version of the code. The status should be set here: https://github.com/kubernetes/kubernetes/blob/c6b5191c37f939d2d61e76de222a96ae5f5d9558/pkg/kubelet/kubelet.go#L2864-L2872

I hit a similar issue when I reproduced #124786. In this case, I set a too small value to the memory limit. Then, I hit the following error and the pod resize status got stuck in “InProgress”: https://github.com/kubernetes/kubernetes/blob/b5bc8025be6179ff49ea2edf654a6b855ae00119/pkg/kubelet/kuberuntime/kuberuntime_manager.go#L743

I guess you also hit one of failures in this doPodResizeAction(). In this case, you could see what happened only in the kubelet log.

In order to make the failures visible to users, more work seems necessary around PodSyncResult and ReasonCache: https://github.com/kubernetes/kubernetes/blob/b5bc8025be6179ff49ea2edf654a6b855ae00119/pkg/kubelet/kubelet.go#L1977-L1978 Emitting events might be another option.

After hitting a failure here, the pod worker retries to resize the pod periodically at regular resyncing because no error is returned: https://github.com/kubernetes/kubernetes/blob/b5bc8025be6179ff49ea2edf654a6b855ae00119/pkg/kubelet/kubelet.go#L1989 https://github.com/kubernetes/kubernetes/blob/b5bc8025be6179ff49ea2edf654a6b855ae00119/pkg/kubelet/pod_workers.go#L1493-L1494 So, the pod gets stuck in InProgress. I’m afraid I’m not sure whether this is an intended behavior or we should abort resizing because I haven’t dug this feature yet.

I verified same thing by spinning up local cluster using k8s hack/local-up-cluster.sh and its works as expected and I dont see any Inprogress resize status even after updating the cpu, I followed the same steps from here.

For reference Initially

  phase: Running
  podIP: 10.88.0.4
  podIPs:
  - ip: 10.88.0.4
  - ip: 2001:db8:4860::4
  qosClass: Guaranteed
  resize: InProgress
  startTime: "2024-03-06T10:27:27Z"

Eventually

# kubectl get pod qos-demo-5 --output=yaml --namespace=qos-example
apiVersion: v1
kind: Pod
metadata:
  creationTimestamp: "2024-03-06T10:27:27Z"
  name: qos-demo-5
  namespace: qos-example
  resourceVersion: "563"
  uid: b0f36536-92cb-4ea0-b80c-212fe695d2f8
spec:
  containers:
  - image: nginx
    imagePullPolicy: Always
    name: qos-demo-ctr-5
    resizePolicy:
    - resourceName: cpu
      restartPolicy: NotRequired
    - resourceName: memory
      restartPolicy: NotRequired
    resources:
      limits:
        cpu: 800m
        memory: 200Mi
      requests:
        cpu: 800m
        memory: 200Mi
    terminationMessagePath: /dev/termination-log
    terminationMessagePolicy: File
    volumeMounts:
    - mountPath: /var/run/secrets/kubernetes.io/serviceaccount
      name: kube-api-access-w7ddb
      readOnly: true
  dnsPolicy: ClusterFirst
  enableServiceLinks: true
  nodeName: 127.0.0.1
  preemptionPolicy: PreemptLowerPriority
  priority: 0
  restartPolicy: Always
  schedulerName: default-scheduler
  securityContext: {}
  serviceAccount: default
  serviceAccountName: default
  terminationGracePeriodSeconds: 30
  tolerations:
  - effect: NoExecute
    key: node.kubernetes.io/not-ready
    operator: Exists
    tolerationSeconds: 300
  - effect: NoExecute
    key: node.kubernetes.io/unreachable
    operator: Exists
    tolerationSeconds: 300
  volumes:
  - name: kube-api-access-w7ddb
    projected:
      defaultMode: 420
      sources:
      - serviceAccountToken:
          expirationSeconds: 3607
          path: token
      - configMap:
          items:
          - key: ca.crt
            path: ca.crt
          name: kube-root-ca.crt
      - downwardAPI:
          items:
          - fieldRef:
              apiVersion: v1
              fieldPath: metadata.namespace
            path: namespace
status:
  conditions:
  - lastProbeTime: null
    lastTransitionTime: "2024-03-06T10:27:31Z"
    status: "True"
    type: PodReadyToStartContainers
  - lastProbeTime: null
    lastTransitionTime: "2024-03-06T10:27:27Z"
    status: "True"
    type: Initialized
  - lastProbeTime: null
    lastTransitionTime: "2024-03-06T10:27:31Z"
    status: "True"
    type: Ready
  - lastProbeTime: null
    lastTransitionTime: "2024-03-06T10:27:31Z"
    status: "True"
    type: ContainersReady
  - lastProbeTime: null
    lastTransitionTime: "2024-03-06T10:27:27Z"
    status: "True"
    type: PodScheduled
  containerStatuses:
  - allocatedResources:
      cpu: 800m
      memory: 200Mi
    containerID: containerd://e4cde25e7305421229b0560b59907693d5df1aaa0a0bca9aae2544624e9070fe
    image: docker.io/library/nginx:latest
    imageID: docker.io/library/nginx@sha256:c26ae7472d624ba1fafd296e73cecc4f93f853088e6a9c13c0d52f6ca5865107
    lastState: {}
    name: qos-demo-ctr-5
    ready: true
    resources:
      limits:
        cpu: 800m
        memory: 200Mi
      requests:
        cpu: 800m
        memory: 200Mi
    restartCount: 0
    started: true
    state:
      running:
        startedAt: "2024-03-06T10:27:30Z"
  hostIP: 127.0.0.1
  hostIPs:
  - ip: 127.0.0.1
  phase: Running
  podIP: 10.88.0.4
  podIPs:
  - ip: 10.88.0.4
  - ip: 2001:db8:4860::4
  qosClass: Guaranteed