mirror of
https://github.com/containers/podman.git
synced 2025-11-29 09:37:38 +08:00
pkg/api/handlers/libpod/containers_stats.go: Remove Cgroups v1
Signed-off-by: Lokesh Mandvekar <lsm5@redhat.com>
This commit is contained in:
@@ -4,7 +4,6 @@ package libpod
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"errors"
|
|
||||||
"fmt"
|
"fmt"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
|
||||||
@@ -13,25 +12,14 @@ import (
|
|||||||
api "github.com/containers/podman/v6/pkg/api/types"
|
api "github.com/containers/podman/v6/pkg/api/types"
|
||||||
"github.com/containers/podman/v6/pkg/domain/entities"
|
"github.com/containers/podman/v6/pkg/domain/entities"
|
||||||
"github.com/containers/podman/v6/pkg/domain/infra/abi"
|
"github.com/containers/podman/v6/pkg/domain/infra/abi"
|
||||||
"github.com/containers/podman/v6/pkg/rootless"
|
|
||||||
"github.com/gorilla/schema"
|
"github.com/gorilla/schema"
|
||||||
"github.com/sirupsen/logrus"
|
"github.com/sirupsen/logrus"
|
||||||
"go.podman.io/common/pkg/cgroups"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func StatsContainer(w http.ResponseWriter, r *http.Request) {
|
func StatsContainer(w http.ResponseWriter, r *http.Request) {
|
||||||
runtime := r.Context().Value(api.RuntimeKey).(*libpod.Runtime)
|
runtime := r.Context().Value(api.RuntimeKey).(*libpod.Runtime)
|
||||||
decoder := r.Context().Value(api.DecoderKey).(*schema.Decoder)
|
decoder := r.Context().Value(api.DecoderKey).(*schema.Decoder)
|
||||||
|
|
||||||
// Check if service is running rootless (cheap check)
|
|
||||||
if rootless.IsRootless() {
|
|
||||||
// if so, then verify cgroup v2 available (more expensive check)
|
|
||||||
if isV2, _ := cgroups.IsCgroup2UnifiedMode(); !isV2 {
|
|
||||||
utils.Error(w, http.StatusConflict, errors.New("container stats resource only available for cgroup v2"))
|
|
||||||
return
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
query := struct {
|
query := struct {
|
||||||
Containers []string `schema:"containers"`
|
Containers []string `schema:"containers"`
|
||||||
Stream bool `schema:"stream"`
|
Stream bool `schema:"stream"`
|
||||||
|
|||||||
Reference in New Issue
Block a user