From 722e9da0ca33d5f9489ef21ff9954a8a89552202 Mon Sep 17 00:00:00 2001 From: Andrzej-Zukowski <150017073+Andrzej-Zukowski@users.noreply.github.com> Date: Mon, 26 Feb 2024 10:51:07 +0100 Subject: [PATCH] Feature issue 1096 (#1099) * [Issue-1084] Addjust scheduler extender algorithm Signed-off-by: Andrzej Zukowski * [Issue-1084] Fixes after review Signed-off-by: Andrzej Zukowski * [Issue-1091] 1.5.1 version (#1093) Signed-off-by: Andrzej Zukowski * Finding drive vid in lsblk vendor (#1094) * Finding drive vid in lsblk vendor * addressing review comments * Initializing device --------- Signed-off-by: Andrzej Zukowski * [ISSUE-1096] Fix lint and unit test error for resolution to atl-22498 (#1098) * [Issue #1096] - Fix lint error for bug atl-22498 Signed-off-by: Eddie Pavkovic * [Issue #1096] - Put code back that returned device if path set - to fix unit test Signed-off-by: Eddie Pavkovic * [ISSUE-1096] - Put back code from previous PR and removed invalid test case Signed-off-by: Eddie Pavkovic --------- Signed-off-by: Eddie Pavkovic Signed-off-by: Andrzej Zukowski * [ISSUE-1096] Change component version to 1.6.0 Signed-off-by: Andrzej Zukowski --------- Signed-off-by: Andrzej Zukowski Signed-off-by: Eddie Pavkovic Co-authored-by: PrasantDell <51162948+prasant123@users.noreply.github.com> Co-authored-by: eddiepavkovic --- pkg/base/linuxutils/lsblk/lsblk.go | 14 +++++--------- pkg/base/linuxutils/lsblk/lsblk_test.go | 10 +--------- pkg/scheduler/extender/extender.go | 18 ++++++++++++------ variables.mk | 2 +- 4 files changed, 19 insertions(+), 25 deletions(-) diff --git a/pkg/base/linuxutils/lsblk/lsblk.go b/pkg/base/linuxutils/lsblk/lsblk.go index 5ba5308b6..604a60d96 100644 --- a/pkg/base/linuxutils/lsblk/lsblk.go +++ b/pkg/base/linuxutils/lsblk/lsblk.go @@ -1,5 +1,5 @@ /* -Copyright © 2020 Dell Inc. or its subsidiaries. All Rights Reserved. +Copyright © 2020-2024 Dell Inc. or its subsidiaries. All Rights Reserved. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -161,12 +161,7 @@ func (l *LSBLK) GetBlockDevices(device string) ([]BlockDevice, error) { // Receives an instance of drivecrd.Drive struct // Returns drive's path based on provided drivecrd.Drive or error if something went wrong func (l *LSBLK) SearchDrivePath(drive *api.Drive) (string, error) { - // device path might be already set by hwmgr - device := drive.Path - if device != "" { - return device, nil - } - + device := "" // try to find it with lsblk lsblkOut, err := l.GetBlockDevices("") if err != nil { @@ -178,8 +173,9 @@ func (l *LSBLK) SearchDrivePath(drive *api.Drive) (string, error) { vid := drive.VID pid := drive.PID for _, l := range lsblkOut { - if strings.EqualFold(l.Serial, sn) && strings.EqualFold(l.Vendor, vid) && - strings.EqualFold(l.Model, pid) { + lvid := strings.TrimSpace(l.Vendor) + if strings.EqualFold(l.Serial, sn) && strings.EqualFold(lvid, vid) && + strings.HasPrefix(l.Model, pid) { device = l.Name break } diff --git a/pkg/base/linuxutils/lsblk/lsblk_test.go b/pkg/base/linuxutils/lsblk/lsblk_test.go index 8af5a93d9..71f191ca1 100644 --- a/pkg/base/linuxutils/lsblk/lsblk_test.go +++ b/pkg/base/linuxutils/lsblk/lsblk_test.go @@ -84,14 +84,6 @@ func TestLSBLK_SearchDrivePath_Success(t *testing.T) { e := &mocks.GoMockExecutor{} l := NewLSBLK(testLogger) l.e = e - // path is in drive spec - dCR := testDriveCR - path := "/dev/sda" - dCR.Spec.Path = path - - res, err := l.SearchDrivePath(&dCR.Spec) - assert.Nil(t, err) - assert.Equal(t, path, res) // got from lsblk output e.On("RunCmd", allDevicesCmd).Return(mocks.LsblkTwoDevicesStr, "", nil) @@ -100,7 +92,7 @@ func TestLSBLK_SearchDrivePath_Success(t *testing.T) { d2CR := testDriveCR d2CR.Spec.SerialNumber = sn - res, err = l.SearchDrivePath(&d2CR.Spec) + res, err := l.SearchDrivePath(&d2CR.Spec) assert.Nil(t, err) assert.Equal(t, expectedDevice, res) } diff --git a/pkg/scheduler/extender/extender.go b/pkg/scheduler/extender/extender.go index 11acf9cc6..bb2bfb6e9 100644 --- a/pkg/scheduler/extender/extender.go +++ b/pkg/scheduler/extender/extender.go @@ -195,14 +195,20 @@ func (e *Extender) PrioritizeHandler(w http.ResponseWriter, req *http.Request) { e.Lock() defer e.Unlock() - hostPriority, err := e.score(extenderArgs.Nodes.Items) - if err != nil { - ll.Errorf("Unable to score %v", err) - return + pod := extenderArgs.Pod + var hostPriority []schedulerapi.HostPriority + requests, err := e.gatherCapacityRequestsByProvisioner(req.Context(), pod) + if err == nil && len(requests) != 0 { + hostPriority, err = e.score(extenderArgs.Nodes.Items) + if err != nil { + ll.Errorf("Unable to score %v", err) + return + } + ll.Infof("Score results for pod %s: %v", pod, hostPriority) + } else { + ll.Infof("Skip skoring for pod: %s", pod) } - ll.Infof("Score results: %v", hostPriority) extenderRes := (schedulerapi.HostPriorityList)(hostPriority) - if err := resp.Encode(&extenderRes); err != nil { ll.Errorf("Unable to write response %v: %v", extenderRes, err) } diff --git a/variables.mk b/variables.mk index 49f93141f..25da0cd46 100644 --- a/variables.mk +++ b/variables.mk @@ -9,7 +9,7 @@ CRD_OPTIONS ?= crd ### version MAJOR := 1 -MINOR := 5 +MINOR := 6 PATCH := 0 PRODUCT_VERSION ?= ${MAJOR}.${MINOR}.${PATCH} BUILD_REL_A := $(shell git rev-list HEAD |wc -l)