calico: Terminating Windows pods hangs on FailedKillPod: ... hcnDeleteNamespace: ... The specified request is unsupported

Terminating pods during regular deployment scale down on a Windows Calico worker gets stuck on an unusual error.

Expected Behavior

The pods should cleanly terminate. They sometimes do.

Current Behavior

Events:
  Type     Reason         Age                     From     Message
  ----     ------         ----                    ----     -------
  Warning  FailedKillPod  3m37s (x6055 over 22h)  kubelet  error killing pod: failed to "KillPodSandbox" for "241a6b05-c158-44c3-b027-b6bcb6ab4d0e" with KillPodSandboxError: "rpc error: code = Unknown desc = failed to remove network namespace for sandbox \"5d496ce20db3ecbc8e524531ab6e093936afc1392ed156bffb337b3cd36d9896\": hcnDeleteNamespace failed in Win32: The specified request is unsupported. (0x803b0015) {\"Success\":false,\"Error\":\"The specified request is unsupported. \",\"ErrorCode\":2151350293}"

The underlying process appears to have successfully exited.

Possible Solution

Not sure.

Steps to Reproduce (for bugs)

Challenging to reproduce. One note is that I run the core process as a Windows service in the Windows container. This may be interacting to cause a race condition.

Context

I experience a lot of issues using containers on Windows, and I am sophisticated, so I am not sure if Calico is strictly to blame here.

Your Environment

  • Calico version
C:/CalicoWindows # calicoctl version
Client Version:    v3.23.1
Git commit:        967e24543
Cluster Version:   v3.23.1
Cluster Type:      k8s,kdd,typha,operator,ecs,win
  • Orchestrator version (e.g. kubernetes, mesos, rkt):
C:/CalicoWindows # kubectl version
Client Version: version.Info{Major:"1", Minor:"22", GitVersion:"v1.22.6", GitCommit:"f59f5c2fda36e4036b49ec027e556a15456108f0", GitTreeState:"clean", BuildDate:"2022-01-19T17:33:06Z", GoVersion:"go1.16.12", Compiler:"gc", Platform:"windows/amd64"}
Server Version: version.Info{Major:"1", Minor:"22+", GitVersion:"v1.22.15-eks-fb459a0", GitCommit:"be82fa628e60d024275efaa239bfe53a9119c2d9", GitTreeState:"clean", BuildDate:"2022-10-24T20:33:23Z", GoVersion:"go1.16.15", Compiler:"gc", Platform:"linux/amd64"}

(1.22 on AWS EKS + on premises nodes)

  • Operating System and version: Windows 2022 LTSC

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Comments: 17 (10 by maintainers)

Commits related to this issue

Most upvoted comments

@coutinhop

Could you elaborate?

I have a CronJob that finds pods suffering from this error and force terminates them:

---
apiVersion: batch/v1
kind: CronJob
metadata:
  name: pod-cleanup-job
spec:
  schedule: "*/2 * * * *"
  jobTemplate:
    spec:
      template:
        spec:
          serviceAccountName: ...
          nodeSelector:
            kubernetes.io/os: linux
          containers:
            - name: kubectl
              image: bitnami/kubectl:latest
              command:
                - /bin/sh
                - -c
                - |
                  # calico 3.26 fixes
                  kubectl get pods --all-namespaces -o json | jq -r '
                    .items[] | 
                    select(.metadata.deletionTimestamp != null) |
                    select(
                      .status.phase == "Running" or 
                      .status.phase == "Failed" or 
                      (.status.phase == "Terminating" and (now - (.metadata.deletionTimestamp | fromdateiso8601)) > 3600)
                    ) |
                    select(
                      (.status.containerStatuses[0].state.terminated.reason == "Error" and .status.containerStatuses[0].state.terminated.exitCode == -1073741510) or
                      (.status.containerStatuses[0].state.terminated.reason == "StartError" and .status.containerStatuses[0].state.terminated.exitCode == 128) or
                      .status.containerStatuses[0].state.waiting.reason == "ContainerCreating"
                    ) |
                    "\(.metadata.namespace) \(.metadata.name)"
                  ' | while read namespace pod; do
                    if kubectl get events --field-selector involvedObject.name=$pod -n $namespace | grep -q 'FailedKillPod.*hcnDeleteNamespace.*The specified request is unsupported'; then
                      echo "Forcefully deleting pod $pod in namespace $namespace due to FailedKillPod"
                      kubectl delete pod $pod -n $namespace --force --grace-period=0
                    elif kubectl get events --field-selector involvedObject.name=$pod -n $namespace | grep -q 'StartError.*failed to create containerd task: failed to create shim task: hcs::CreateComputeSystem.*The endpoint was not found'; then
                      echo "Forcefully deleting pod $pod in namespace $namespace due to StartError"
                      kubectl delete pod $pod -n $namespace --force --grace-period=0
                    elif [ "$(kubectl get pod $pod -n $namespace -o jsonpath='{.status.phase}')" == "Terminating" ] && [ "$(kubectl get pod $pod -n $namespace -o jsonpath='{.status.containerStatuses[0].state.waiting.reason}')" == "ContainerCreating" ]; then
                      echo "Forcefully deleting pod $pod in namespace $namespace due to stuck in Terminating state"
                      kubectl delete pod $pod -n $namespace --force --grace-period=0
                    fi
                  done

I wish I comprehended what the error was actually saying or what was going wrong.

This issue persists with v3.26.4 which should include this change.