Skip to content

Commit

Permalink
[YUNIKORN-2051] fix staticcheck errors
Browse files Browse the repository at this point in the history
Signed-off-by: PoAn Yang <[email protected]>
  • Loading branch information
FrankYang0529 committed Oct 24, 2023
1 parent 8997cc2 commit 13ebe3e
Show file tree
Hide file tree
Showing 11 changed files with 4 additions and 56 deletions.
9 changes: 0 additions & 9 deletions pkg/common/configs/configvalidator.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@ package configs
import (
"fmt"
"math"
"os"
"path/filepath"
"regexp"
"strings"
"time"
Expand Down Expand Up @@ -725,13 +723,6 @@ func checkDeprecatedStateDumpFilePath(partition *PartitionConfig) error {
return nil
}

func ensureDir(fileName string) error {
if err := os.MkdirAll(filepath.Dir(fileName), os.ModePerm); err != nil {
return err
}
return nil
}

// Check the partition configuration. Any parsing issues will return an error which means that the
// configuration is invalid. This *must* be called before the configuration is activated. Any
// configuration that does not pass must be rejected.
Expand Down
20 changes: 0 additions & 20 deletions pkg/rmproxy/rmproxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -407,23 +407,3 @@ func (rmp *RMProxy) UpdateConfiguration(request *si.UpdateConfigurationRequest)
}
return nil
}

// actual configuration reloader
type configurationReloader struct {
rmID string
rmProxy *RMProxy
}

func (cr configurationReloader) DoReloadConfiguration() error {
c := make(chan *rmevent.Result)
cr.rmProxy.EventHandlers.SchedulerEventHandler.HandleEvent(
&rmevent.RMConfigUpdateEvent{
RmID: cr.rmID,
Channel: c,
})
result := <-c
if !result.Succeeded {
return fmt.Errorf("failed to update configuration for RM %s, result: %v", cr.rmID, result)
}
return nil
}
6 changes: 0 additions & 6 deletions pkg/scheduler/context_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,6 @@ func newMockEventHandler() *mockEventHandler {
}
}

func (m *mockEventHandler) reset() {
m.eventHandled = false
m.rejectedNodes = make([]*si.RejectedNode, 0)
m.acceptedNodes = make([]*si.AcceptedNode, 0)
}

func (m *mockEventHandler) HandleEvent(ev interface{}) {
if nodeEvent, ok := ev.(*rmevent.RMNodeUpdateEvent); ok {
m.eventHandled = true
Expand Down
2 changes: 0 additions & 2 deletions pkg/scheduler/health_checker.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,6 @@ import (
"github.com/apache/yunikorn-core/pkg/webservice/dao"
)

const defaultPeriod = 30 * time.Second

type HealthChecker struct {
context *ClusterContext
confWatcherId string
Expand Down
9 changes: 0 additions & 9 deletions pkg/scheduler/objects/sorters_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -404,15 +404,6 @@ func assertAppList(t *testing.T, list []*Application, place []int, name string)
assert.Equal(t, "app-3", list[place[3]].ApplicationID, "test name: %s", name)
}

// list of application and the location of the named applications inside that list
// place[0] defines the location of the app-0 in the list of applications
func assertAskList(t *testing.T, list []*AllocationAsk, place []int, name string) {
assert.Equal(t, "ask-0", list[place[0]].GetAllocationKey(), "test name: %s", name)
assert.Equal(t, "ask-1", list[place[1]].GetAllocationKey(), "test name: %s", name)
assert.Equal(t, "ask-2", list[place[2]].GetAllocationKey(), "test name: %s", name)
assert.Equal(t, "ask-3", list[place[3]].GetAllocationKey(), "test name: %s", name)
}

func assertAppListLength(t *testing.T, list []*Application, apps []string, name string) {
assert.Equal(t, len(apps), len(list), "length of list differs, test: %s", name)
for i, app := range list {
Expand Down
4 changes: 0 additions & 4 deletions pkg/scheduler/partition.go
Original file line number Diff line number Diff line change
Expand Up @@ -254,10 +254,6 @@ func (pc *PartitionContext) isDraining() bool {
return pc.stateMachine.Current() == objects.Draining.String()
}

func (pc *PartitionContext) isRunning() bool {
return pc.stateMachine.Current() == objects.Active.String()
}

func (pc *PartitionContext) isStopped() bool {
return pc.stateMachine.Current() == objects.Stopped.String()
}
Expand Down
1 change: 1 addition & 0 deletions pkg/scheduler/partition_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1168,6 +1168,7 @@ func TestRemoveAppAllocs(t *testing.T) {
ask := newAllocationAsk("alloc-nr", appNotRemoved, appRes)
alloc := objects.NewAllocation("alloc-nr-uuid", nodeID1, ask)
err = partition.addAllocation(alloc)
assert.NilError(t, err, "add allocation to partition should not have failed")
assertLimits(t, getTestUserGroup(), appRes)

ask = newAllocationAsk("alloc-1", appNotRemoved, appRes)
Expand Down
4 changes: 2 additions & 2 deletions pkg/scheduler/tests/operation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ partitions:

// Check scheduling queue a
queueA := part.GetQueue("root.a")
assert.Assert(t, 150000000 == queueA.GetMaxResource().Resources[common.Memory])
assert.Equal(t, resources.Quantity(150000000), queueA.GetMaxResource().Resources[common.Memory])

// Add one application
err = ms.proxy.UpdateApplication(&si.ApplicationRequest{
Expand Down Expand Up @@ -196,7 +196,7 @@ partitions:

// Check scheduling queue a
queueA := part.GetQueue("root.a")
assert.Assert(t, 150000000 == queueA.GetMaxResource().Resources[common.Memory])
assert.Equal(t, resources.Quantity(150000000), queueA.GetMaxResource().Resources[common.Memory])

// Add one application
err = ms.proxy.UpdateApplication(&si.ApplicationRequest{
Expand Down
2 changes: 1 addition & 1 deletion pkg/scheduler/tests/recovery_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ func TestSchedulerRecovery(t *testing.T) {

// Check scheduling queue a
queue := part.GetQueue("root.a")
assert.Assert(t, 150 == queue.GetMaxResource().Resources[common.Memory])
assert.Equal(t, resources.Quantity(150), queue.GetMaxResource().Resources[common.Memory])

// Register nodes, and add apps
err = ms.proxy.UpdateNode(&si.NodeRequest{
Expand Down
1 change: 0 additions & 1 deletion pkg/webservice/handlers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,6 @@ const rmID = "rm-123"
const policyGroup = "default-policy-group"
const queueName = "root.default"
const nodeID = "node-1"
const instType = "itype-1"

var (
updatedExtraConf = map[string]string{
Expand Down
2 changes: 0 additions & 2 deletions pkg/webservice/webservice.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ package webservice
import (
"context"
"net/http"
"sync"
"time"

"github.com/julienschmidt/httprouter"
Expand All @@ -34,7 +33,6 @@ import (
)

var imHistory *history.InternalMetricsHistory
var lock sync.RWMutex
var schedulerContext *scheduler.ClusterContext

type WebService struct {
Expand Down

0 comments on commit 13ebe3e

Please sign in to comment.