Skip to content

Commit

Permalink
node: podresources: getallocatable: move to GA
Browse files Browse the repository at this point in the history
lock the feature gate to GA, and remove the now-redundant code.

Signed-off-by: Francesco Romani <fromani@redhat.com>
  • Loading branch information
ffromani committed Jul 12, 2023
1 parent 0da0b7a commit 01c3a51
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 38 deletions.
5 changes: 3 additions & 2 deletions pkg/features/kube_features.go
Expand Up @@ -435,9 +435,10 @@ const (
// Enable POD resources API with Get method
KubeletPodResourcesGet featuregate.Feature = "KubeletPodResourcesGet"

// owner: @fromanirh
// owner: @ffromani
// alpha: v1.21
// beta: v1.23
// GA: v1.28
// Enable POD resources API to return allocatable resources
KubeletPodResourcesGetAllocatable featuregate.Feature = "KubeletPodResourcesGetAllocatable"

Expand Down Expand Up @@ -972,7 +973,7 @@ var defaultKubernetesFeatureGates = map[featuregate.Feature]featuregate.FeatureS

KubeletPodResourcesGet: {Default: false, PreRelease: featuregate.Alpha},

KubeletPodResourcesGetAllocatable: {Default: true, PreRelease: featuregate.Beta},
KubeletPodResourcesGetAllocatable: {Default: true, PreRelease: featuregate.GA, LockToDefault: true}, // GA in 1.28, remove in 1.30

KubeletTracing: {Default: true, PreRelease: featuregate.Beta},

Expand Down
5 changes: 0 additions & 5 deletions pkg/kubelet/apis/podresources/server_v1.go
Expand Up @@ -90,11 +90,6 @@ func (p *v1PodResourcesServer) GetAllocatableResources(ctx context.Context, req
metrics.PodResourcesEndpointRequestsTotalCount.WithLabelValues("v1").Inc()
metrics.PodResourcesEndpointRequestsGetAllocatableCount.WithLabelValues("v1").Inc()

if !utilfeature.DefaultFeatureGate.Enabled(kubefeatures.KubeletPodResourcesGetAllocatable) {
metrics.PodResourcesEndpointErrorsGetAllocatableCount.WithLabelValues("v1").Inc()
return nil, fmt.Errorf("PodResources API GetAllocatableResources disabled")
}

response := &v1.AllocatableResourcesResponse{
Devices: p.devicesProvider.GetAllocatableDevices(),
CpuIds: p.cpusProvider.GetAllocatableCPUs(),
Expand Down
2 changes: 0 additions & 2 deletions pkg/kubelet/apis/podresources/server_v1_test.go
Expand Up @@ -251,8 +251,6 @@ func TestListPodResourcesV1(t *testing.T) {
}

func TestAllocatableResources(t *testing.T) {
defer featuregatetesting.SetFeatureGateDuringTest(t, utilfeature.DefaultFeatureGate, pkgfeatures.KubeletPodResourcesGetAllocatable, true)()

mockCtrl := gomock.NewController(t)
defer mockCtrl.Finish()

Expand Down
10 changes: 4 additions & 6 deletions pkg/kubelet/metrics/metrics.go
Expand Up @@ -777,12 +777,10 @@ func Register(collectors ...metrics.StableCollector) {
legacyregistry.MustRegister(RestartedPodTotal)
legacyregistry.MustRegister(ManagedEphemeralContainers)
legacyregistry.MustRegister(PodResourcesEndpointRequestsTotalCount)
if utilfeature.DefaultFeatureGate.Enabled(features.KubeletPodResourcesGetAllocatable) {
legacyregistry.MustRegister(PodResourcesEndpointRequestsListCount)
legacyregistry.MustRegister(PodResourcesEndpointRequestsGetAllocatableCount)
legacyregistry.MustRegister(PodResourcesEndpointErrorsListCount)
legacyregistry.MustRegister(PodResourcesEndpointErrorsGetAllocatableCount)
}
legacyregistry.MustRegister(PodResourcesEndpointRequestsListCount)
legacyregistry.MustRegister(PodResourcesEndpointRequestsGetAllocatableCount)
legacyregistry.MustRegister(PodResourcesEndpointErrorsListCount)
legacyregistry.MustRegister(PodResourcesEndpointErrorsGetAllocatableCount)
if utilfeature.DefaultFeatureGate.Enabled(features.KubeletPodResourcesGet) {
legacyregistry.MustRegister(PodResourcesEndpointRequestsGetCount)
legacyregistry.MustRegister(PodResourcesEndpointErrorsGetCount)
Expand Down
23 changes: 0 additions & 23 deletions test/e2e_node/podresources_test.go
Expand Up @@ -775,29 +775,6 @@ var _ = SIGDescribe("POD Resources [Serial] [Feature:PodResources][NodeFeature:P
})
})

ginkgo.Context("with disabled KubeletPodResourcesGetAllocatable feature gate", func() {
tempSetCurrentKubeletConfig(f, func(ctx context.Context, initialConfig *kubeletconfig.KubeletConfiguration) {
if initialConfig.FeatureGates == nil {
initialConfig.FeatureGates = make(map[string]bool)
}
initialConfig.FeatureGates[string(kubefeatures.KubeletPodResourcesGetAllocatable)] = false
})

ginkgo.It("should return the expected error with the feature gate disabled", func(ctx context.Context) {
endpoint, err := util.LocalEndpoint(defaultPodResourcesPath, podresources.Socket)
framework.ExpectNoError(err, "LocalEndpoint() failed err: %v", err)

cli, conn, err := podresources.GetV1Client(endpoint, defaultPodResourcesTimeout, defaultPodResourcesMaxSize)
framework.ExpectNoError(err, "GetV1Client() failed err: %v", err)
defer conn.Close()

ginkgo.By("checking GetAllocatableResources fail if the feature gate is not enabled")
allocatableRes, err := cli.GetAllocatableResources(ctx, &kubeletpodresourcesv1.AllocatableResourcesRequest{})
framework.Logf("GetAllocatableResources result: %v, err: %v", allocatableRes, err)
framework.ExpectError(err, "With feature gate disabled, the call must fail")
})
})

ginkgo.Context("with disabled KubeletPodResourcesGet feature gate", func() {

ginkgo.It("should return the expected error with the feature gate disabled", func(ctx context.Context) {
Expand Down

0 comments on commit 01c3a51

Please sign in to comment.