Repository: kubernetes
Issue: Enabling feature PodAndContainerStatsFromCRI breaks metric collection
Labels: kind/bug,sig/node,priority/important-longterm,lifecycle/frozen,needs-triage

### What happened?

When running a cluster and enabling feature gate `PodAndContainerStatsFromCRI`, resource usage doesn't report any values:
```console
$ kubectl top pod -n kube-system
error: Metrics not available for pod kube-system/{POD_NAME}, age: 6h40m31.578500815s
```

When retrieving logs from metric server, we can see several errors with code 500 when it calls the `/stats/summary` API:
```console
$ kubectl logs `kubectl get pod -n kube-system | grep metrics-server | cut -f 1 -d ' '` metrics-server -n kube-system -f
E0720 02:37:41.817418       1 scraper.go:139] "Failed to scrape node" err="GET \"http://10.128.0.81:10255/stats/summary?only_cpu_and_memory=true\": bad status code \"500 Internal Server Error\"" node="{NODE_NAME}"
```

### What did you expect to happen?

Resource usage reports values:
```console
$ kubectl top pod -n kube-system
NAME                                             CPU(cores)   MEMORY(bytes)
fluentbit-gke-7zpf2                              8m           28Mi
konnectivity-agent-58f896556b-4jx67              1m           8Mi
--- MORE PODS ---
```

And metrics server doesn't fail with code 500 when calling `/stats/summary` API.

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

1. Create a cluster.
2. Enable feature gate `PodAndContainerStatsFromCRI`.
3. Retrieve metric server logs to confirm it's failing.
4. Attempt to display resource usage via `kubectl top pod -n kube-system` to confirm it's failing.

### Anything else we need to know?

This issue must block enhancement https://github.com/kubernetes/enhancements/issues/2371 from reaching beta.

### Kubernetes version

<details>

```console
$ kubectl version
Client Version: version.Info{Major:"1", Minor:"24", GitVersion:"v1.24.2", GitCommit:"f66044f4361b9f1f96f0053dd46cb7dce5e990a8", GitTreeState:"clean", BuildDate:"2022-06-15T14:22:29Z", GoVersion:"go1.18.3", Compiler:"gc", Platform:"linux/amd64"}
Kustomize Version: v4.5.4
Server Version: version.Info{Major:"1", Minor:"24", GitVersion:"v1.24.2-gke.200", GitCommit:"4654e8878d7e02fd623e08a7a3adb45ad4cab05e", GitTreeState:"clean", BuildDate:"2022-06-23T09:27:31Z", GoVersion:"go1.18.2b7", Compiler:"gc", Platform:"linux/amd64"}
```

</details>


### Cloud provider

<details>
GKE
</details>


### OS version

<details>

```console
$ cat /etc/os-release
NAME="Container-Optimized OS"
ID=cos
PRETTY_NAME="Container-Optimized OS from Google"
HOME_URL="https://cloud.google.com/container-optimized-os/docs"
BUG_REPORT_URL="https://cloud.google.com/container-optimized-os/docs/resources/support-policy#contact_us"
GOOGLE_METRICS_PRODUCT_ID=26
KERNEL_COMMIT_ID=43faebd3c60e6a1b27a930604bb55d4ebaa1aee3
GOOGLE_CRASH_ID=Lakitu
VERSION=97
VERSION_ID=97
BUILD_ID=16919.29.40

$ uname -a
Linux gke-b233861587-repro-reg-default-pool-b48a67e2-8n51 5.10.107+ #1 SMP Sat May 28 15:06:36 UTC 2022 x86_64 Intel(R) Xeon(R) CPU @ 2.30GHz GenuineIntel GNU/Linux
```

</details>


### Install tools

_No response_

### Container runtime (CRI) and version (if applicable)

<details>

```console
$ containerd --version
containerd github.com/containerd/containerd 1.6.2 de8046a5501db9e0e478e1c10cbcfb21af4c6b2d

$ crictl --version
crictl version v1.23.0
```

</details>


### Related plugins (CNI, CSI, ...) and versions (if applicable)

_No response_