diff --git a/cmd/nfd-topology-updater/main.go b/cmd/nfd-topology-updater/main.go index 1aa126097..db80d1138 100644 --- a/cmd/nfd-topology-updater/main.go +++ b/cmd/nfd-topology-updater/main.go @@ -60,7 +60,7 @@ func main() { klConfig, err := kubeconf.GetKubeletConfigFromLocalFile(resourcemonitorArgs.KubeletConfigFile) if err != nil { - klog.Fatalf("error reading kubelet config: %v", err) + klog.Exitf("error reading kubelet config: %v", err) } tmPolicy := string(topologypolicy.DetectTopologyPolicy(klConfig.TopologyManagerPolicy, klConfig.TopologyManagerScope)) klog.Infof("detected kubelet Topology Manager policy %q", tmPolicy) diff --git a/pkg/nfd-client/topology-updater/nfd-topology-updater.go b/pkg/nfd-client/topology-updater/nfd-topology-updater.go index 15c3ff433..d2293cb18 100644 --- a/pkg/nfd-client/topology-updater/nfd-topology-updater.go +++ b/pkg/nfd-client/topology-updater/nfd-topology-updater.go @@ -88,8 +88,7 @@ func (w *nfdTopologyUpdater) Run() error { podResClient, err := podres.GetPodResClient(w.resourcemonitorArgs.PodResourceSocketPath) if err != nil { - klog.Fatalf("failed to get PodResource Client: %w", err) - return err + return fmt.Errorf("failed to get PodResource Client: %w", err) } kubeApihelper := apihelper.K8sHelpers{Kubeconfig: w.args.KubeConfigFile} @@ -97,8 +96,7 @@ func (w *nfdTopologyUpdater) Run() error { resScan, err = resourcemonitor.NewPodResourcesScanner(w.resourcemonitorArgs.Namespace, podResClient, kubeApihelper) if err != nil { - klog.Fatalf("failed to initialize ResourceMonitor instance: %w", err) - return err + return fmt.Errorf("failed to initialize ResourceMonitor instance: %w", err) } // CAUTION: these resources are expected to change rarely - if ever. @@ -109,8 +107,7 @@ func (w *nfdTopologyUpdater) Run() error { resAggr, err := resourcemonitor.NewResourcesAggregator(podResClient) if err != nil { - klog.Fatalf("failed to obtain node resource information: %w", err) - return err + return fmt.Errorf("failed to obtain node resource information: %w", err) } klog.V(2).Infof("resAggr is: %v\n", resAggr) diff --git a/pkg/resourcemonitor/noderesourcesaggregator.go b/pkg/resourcemonitor/noderesourcesaggregator.go index edb5d0703..50187716b 100644 --- a/pkg/resourcemonitor/noderesourcesaggregator.go +++ b/pkg/resourcemonitor/noderesourcesaggregator.go @@ -75,7 +75,14 @@ func NewResourcesAggregator(podResourceClient podresourcesapi.PodResourcesLister // Pod Resource API client resp, err := podResourceClient.GetAllocatableResources(ctx, &podresourcesapi.AllocatableResourcesRequest{}) if err != nil { - return nil, fmt.Errorf("can't receive response: %v.Get(_) = _, %w", podResourceClient, err) + if strings.Contains(err.Error(), "API GetAllocatableResources disabled") { + klog.Error("Kubelet's pod resources 'GetAllocatableResources' functionality is disabled. " + + "Ensure feature flag 'KubeletPodResourcesGetAllocatable' is set to true. " + + "You can find more about the feature gates from the following URL - " + + "https://kubernetes.io/docs/reference/command-line-tools-reference/feature-gates/") + } + + return nil, fmt.Errorf("failed to get allocatable resources (ensure that KubeletPodResourcesGetAllocatable feature gate is enabled): %w", err) } return NewResourcesAggregatorFromData(topo, resp, memoryResourcesCapacityPerNUMA), nil