Skip to content

Commit

Permalink
Feature issue 1096 (#1099)
Browse files Browse the repository at this point in the history
* [Issue-1084] Addjust scheduler extender algorithm

Signed-off-by: Andrzej Zukowski <[email protected]>

* [Issue-1084] Fixes after review

Signed-off-by: Andrzej Zukowski <[email protected]>

* [Issue-1091] 1.5.1 version (#1093)

Signed-off-by: Andrzej Zukowski <[email protected]>

* Finding drive vid in lsblk vendor (#1094)

* Finding drive vid in lsblk vendor

* addressing review comments

* Initializing device

---------

Signed-off-by: Andrzej Zukowski <[email protected]>

* [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 <[email protected]>

* [Issue #1096] - Put code back that returned device if path set
- to fix unit test

Signed-off-by: Eddie Pavkovic <[email protected]>

* [ISSUE-1096] - Put back code from previous PR and removed invalid test case

Signed-off-by: Eddie Pavkovic <[email protected]>

---------

Signed-off-by: Eddie Pavkovic <[email protected]>
Signed-off-by: Andrzej Zukowski <[email protected]>

* [ISSUE-1096] Change component version to 1.6.0

Signed-off-by: Andrzej Zukowski <[email protected]>

---------

Signed-off-by: Andrzej Zukowski <[email protected]>
Signed-off-by: Eddie Pavkovic <[email protected]>
Co-authored-by: PrasantDell <[email protected]>
Co-authored-by: eddiepavkovic <[email protected]>
  • Loading branch information
3 people authored Feb 26, 2024
1 parent d5847f2 commit 722e9da
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 25 deletions.
14 changes: 5 additions & 9 deletions pkg/base/linuxutils/lsblk/lsblk.go
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -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 {
Expand All @@ -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
}
Expand Down
10 changes: 1 addition & 9 deletions pkg/base/linuxutils/lsblk/lsblk_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
}
Expand Down
18 changes: 12 additions & 6 deletions pkg/scheduler/extender/extender.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
2 changes: 1 addition & 1 deletion variables.mk
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 722e9da

Please sign in to comment.