mirror of
https://github.com/k3s-io/kubernetes.git
synced 2026-07-17 11:28:58 +00:00
remove the featuregate checks
Signed-off-by: Swati Gupta <swatig@nvidia.com>
This commit is contained in:
@@ -120,11 +120,6 @@ func (p *v1PodResourcesServer) Get(ctx context.Context, req *podresourcesv1.GetP
|
||||
metrics.PodResourcesEndpointRequestsTotalCount.WithLabelValues("v1").Inc()
|
||||
metrics.PodResourcesEndpointRequestsGetCount.WithLabelValues("v1").Inc()
|
||||
|
||||
if !utilfeature.DefaultFeatureGate.Enabled(kubefeatures.KubeletPodResourcesGet) {
|
||||
metrics.PodResourcesEndpointErrorsGetCount.WithLabelValues("v1").Inc()
|
||||
return nil, fmt.Errorf("PodResources API Get method disabled")
|
||||
}
|
||||
|
||||
pod, exist := p.podsProvider.GetPodByName(req.PodNamespace, req.PodName)
|
||||
if !exist {
|
||||
metrics.PodResourcesEndpointErrorsGetCount.WithLabelValues("v1").Inc()
|
||||
@@ -158,14 +153,11 @@ func (p *v1PodResourcesServer) Get(ctx context.Context, req *podresourcesv1.GetP
|
||||
|
||||
func (p *v1PodResourcesServer) getContainerResources(pod *v1.Pod, container *v1.Container) *podresourcesv1.ContainerResources {
|
||||
containerResources := &podresourcesv1.ContainerResources{
|
||||
Name: container.Name,
|
||||
Devices: p.devicesProvider.GetDevices(string(pod.UID), container.Name),
|
||||
CpuIds: p.cpusProvider.GetCPUs(string(pod.UID), container.Name),
|
||||
Memory: p.memoryProvider.GetMemory(string(pod.UID), container.Name),
|
||||
Name: container.Name,
|
||||
Devices: p.devicesProvider.GetDevices(string(pod.UID), container.Name),
|
||||
CpuIds: p.cpusProvider.GetCPUs(string(pod.UID), container.Name),
|
||||
Memory: p.memoryProvider.GetMemory(string(pod.UID), container.Name),
|
||||
DynamicResources: p.dynamicResourcesProvider.GetDynamicResources(pod, container),
|
||||
}
|
||||
if utilfeature.DefaultFeatureGate.Enabled(kubefeatures.KubeletPodResourcesDynamicResources) {
|
||||
containerResources.DynamicResources = p.dynamicResourcesProvider.GetDynamicResources(pod, container)
|
||||
}
|
||||
|
||||
return containerResources
|
||||
}
|
||||
|
||||
@@ -28,17 +28,12 @@ import (
|
||||
v1 "k8s.io/api/core/v1"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/apimachinery/pkg/types"
|
||||
utilfeature "k8s.io/apiserver/pkg/util/feature"
|
||||
featuregatetesting "k8s.io/component-base/featuregate/testing"
|
||||
podresourcesapi "k8s.io/kubelet/pkg/apis/podresources/v1"
|
||||
pkgfeatures "k8s.io/kubernetes/pkg/features"
|
||||
podresourcetest "k8s.io/kubernetes/pkg/kubelet/apis/podresources/testing"
|
||||
"k8s.io/kubernetes/test/utils/ktesting"
|
||||
)
|
||||
|
||||
func TestListPodResourcesV1(t *testing.T) {
|
||||
featuregatetesting.SetFeatureGateDuringTest(t, utilfeature.DefaultFeatureGate, pkgfeatures.KubeletPodResourcesDynamicResources, true)
|
||||
|
||||
tCtx := ktesting.Init(t)
|
||||
podName := "pod-name"
|
||||
podNamespace := "pod-namespace"
|
||||
@@ -294,8 +289,6 @@ func collectNamespacedNamesFromPodResources(prs []*podresourcesapi.PodResources)
|
||||
}
|
||||
|
||||
func TestListPodResourcesUsesOnlyActivePodsV1(t *testing.T) {
|
||||
featuregatetesting.SetFeatureGateDuringTest(t, utilfeature.DefaultFeatureGate, pkgfeatures.KubeletPodResourcesDynamicResources, true)
|
||||
|
||||
tCtx := ktesting.Init(t)
|
||||
numaID := int64(1)
|
||||
|
||||
@@ -411,7 +404,6 @@ func TestListPodResourcesUsesOnlyActivePodsV1(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestListPodResourcesWithInitContainersV1(t *testing.T) {
|
||||
featuregatetesting.SetFeatureGateDuringTest(t, utilfeature.DefaultFeatureGate, pkgfeatures.KubeletPodResourcesDynamicResources, true)
|
||||
tCtx := ktesting.Init(t)
|
||||
podName := "pod-name"
|
||||
podNamespace := "pod-namespace"
|
||||
@@ -899,11 +891,6 @@ func TestAllocatableResources(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestGetPodResourcesV1(t *testing.T) {
|
||||
featuregatetesting.SetFeatureGatesDuringTest(t, utilfeature.DefaultFeatureGate, featuregatetesting.FeatureOverrides{
|
||||
pkgfeatures.KubeletPodResourcesGet: true,
|
||||
pkgfeatures.KubeletPodResourcesDynamicResources: true,
|
||||
})
|
||||
|
||||
tCtx := ktesting.Init(t)
|
||||
podName := "pod-name"
|
||||
podNamespace := "pod-namespace"
|
||||
@@ -1082,11 +1069,6 @@ func TestGetPodResourcesV1(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestGetPodResourcesWithInitContainersV1(t *testing.T) {
|
||||
featuregatetesting.SetFeatureGatesDuringTest(t, utilfeature.DefaultFeatureGate, featuregatetesting.FeatureOverrides{
|
||||
pkgfeatures.KubeletPodResourcesGet: true,
|
||||
pkgfeatures.KubeletPodResourcesDynamicResources: true,
|
||||
})
|
||||
|
||||
tCtx := ktesting.Init(t)
|
||||
podName := "pod-name"
|
||||
podNamespace := "pod-namespace"
|
||||
|
||||
@@ -1247,10 +1247,8 @@ func Register() {
|
||||
legacyregistry.MustRegister(PodResourcesEndpointRequestsGetAllocatableCount)
|
||||
legacyregistry.MustRegister(PodResourcesEndpointErrorsListCount)
|
||||
legacyregistry.MustRegister(PodResourcesEndpointErrorsGetAllocatableCount)
|
||||
if utilfeature.DefaultFeatureGate.Enabled(features.KubeletPodResourcesGet) {
|
||||
legacyregistry.MustRegister(PodResourcesEndpointRequestsGetCount)
|
||||
legacyregistry.MustRegister(PodResourcesEndpointErrorsGetCount)
|
||||
}
|
||||
legacyregistry.MustRegister(PodResourcesEndpointRequestsGetCount)
|
||||
legacyregistry.MustRegister(PodResourcesEndpointErrorsGetCount)
|
||||
if utilfeature.DefaultFeatureGate.Enabled(features.UserNamespacesSupport) {
|
||||
legacyregistry.MustRegister(StartedUserNamespacedPodsTotal)
|
||||
legacyregistry.MustRegister(StartedUserNamespacedPodsErrorsTotal)
|
||||
|
||||
Reference in New Issue
Block a user