Skip to content

Commit cb537ff

Browse files
committed
Fixed types
1 parent 8e26997 commit cb537ff

File tree

3 files changed

+15
-13
lines changed

3 files changed

+15
-13
lines changed

pkg/operator/operands/scheduler/resources_for_shard.go

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import (
99
"strconv"
1010
"strings"
1111

12+
"github.com/spf13/pflag"
1213
"golang.org/x/exp/slices"
1314

1415
"gopkg.in/yaml.v3"
@@ -22,7 +23,7 @@ import (
2223
kaiv1 "github.com/NVIDIA/KAI-scheduler/pkg/apis/kai/v1"
2324
kaiConfigUtils "github.com/NVIDIA/KAI-scheduler/pkg/operator/config"
2425
"github.com/NVIDIA/KAI-scheduler/pkg/operator/operands/common"
25-
"github.com/spf13/pflag"
26+
"github.com/NVIDIA/KAI-scheduler/pkg/scheduler/conf"
2627
)
2728

2829
const (
@@ -125,7 +126,7 @@ func (s *SchedulerForShard) configMapForShard(
125126
APIVersion: "v1",
126127
}
127128
placementArguments := calculatePlacementArguments(shard.Spec.PlacementStrategy)
128-
innerConfig := config{}
129+
innerConfig := conf.SchedulerConfiguration{}
129130

130131
actions := []string{"allocate"}
131132
if placementArguments[gpuResource] != spreadStrategy && placementArguments[cpuResource] != spreadStrategy {
@@ -135,9 +136,9 @@ func (s *SchedulerForShard) configMapForShard(
135136

136137
innerConfig.Actions = strings.Join(actions, ", ")
137138

138-
innerConfig.Tiers = []tier{
139+
innerConfig.Tiers = []conf.Tier{
139140
{
140-
Plugins: []plugin{
141+
Plugins: []conf.PluginOption{
141142
{Name: "predicates"},
142143
{Name: "proportion"},
143144
{Name: "priority"},
@@ -160,8 +161,8 @@ func (s *SchedulerForShard) configMapForShard(
160161

161162
innerConfig.Tiers[0].Plugins = append(
162163
innerConfig.Tiers[0].Plugins,
163-
plugin{Name: fmt.Sprintf("gpu%s", strings.Replace(placementArguments[gpuResource], "bin", "", 1))},
164-
plugin{
164+
conf.PluginOption{Name: fmt.Sprintf("gpu%s", strings.Replace(placementArguments[gpuResource], "bin", "", 1))},
165+
conf.PluginOption{
165166
Name: "nodeplacement",
166167
Arguments: placementArguments,
167168
},
@@ -170,7 +171,7 @@ func (s *SchedulerForShard) configMapForShard(
170171
if placementArguments[gpuResource] == binpackStrategy {
171172
innerConfig.Tiers[0].Plugins = append(
172173
innerConfig.Tiers[0].Plugins,
173-
plugin{Name: "gpusharingorder"},
174+
conf.PluginOption{Name: "gpusharingorder"},
174175
)
175176
}
176177

@@ -195,7 +196,7 @@ func (s *SchedulerForShard) configMapForShard(
195196
return schedulerConfig, nil
196197
}
197198

198-
func validateJobDepthMap(shard *kaiv1.SchedulingShard, innerConfig config, actions []string) error {
199+
func validateJobDepthMap(shard *kaiv1.SchedulingShard, innerConfig conf.SchedulerConfiguration, actions []string) error {
199200
for actionToConfigure := range shard.Spec.QueueDepthPerAction {
200201
if !slices.Contains(actions, actionToConfigure) {
201202
return fmt.Errorf(invalidJobDepthMapError, innerConfig.Actions, actionToConfigure)
@@ -294,12 +295,12 @@ func calculatePlacementArguments(placementStrategy *kaiv1.PlacementStrategy) map
294295
}
295296
}
296297

297-
func addMinRuntimePluginIfNeeded(plugins *[]plugin, minRuntime *kaiv1.MinRuntime) {
298+
func addMinRuntimePluginIfNeeded(plugins *[]conf.PluginOption, minRuntime *kaiv1.MinRuntime) {
298299
if minRuntime == nil || (minRuntime.PreemptMinRuntime == nil && minRuntime.ReclaimMinRuntime == nil) {
299300
return
300301
}
301302

302-
minRuntimePlugin := plugin{Name: "minruntime", Arguments: map[string]string{}}
303+
minRuntimePlugin := conf.PluginOption{Name: "minruntime", Arguments: map[string]string{}}
303304

304305
if minRuntime.PreemptMinRuntime != nil {
305306
minRuntimePlugin.Arguments["defaultPreemptMinRuntime"] = *minRuntime.PreemptMinRuntime

pkg/operator/operands/scheduler/resources_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import (
1717
kaiv1 "github.com/NVIDIA/KAI-scheduler/pkg/apis/kai/v1"
1818
kaiv1qc "github.com/NVIDIA/KAI-scheduler/pkg/apis/kai/v1/queue_controller"
1919
kaiv1scheduler "github.com/NVIDIA/KAI-scheduler/pkg/apis/kai/v1/scheduler"
20+
"github.com/NVIDIA/KAI-scheduler/pkg/scheduler/conf"
2021

2122
"github.com/stretchr/testify/assert"
2223
"github.com/stretchr/testify/require"

pkg/scheduler/cache/usagedb/prometheus/prometheus.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ func (p *PrometheusClient) GetResourceUsage() (*queue_info.ClusterUsage, error)
139139
func (p *PrometheusClient) queryResourceCapacity(ctx context.Context, capacityMetric string, queryByWindow usageWindowQueryFunction) (float64, error) {
140140
decayedCapacityMetric := capacityMetric
141141
if p.usageParams.HalfLifePeriod != nil {
142-
decayedCapacityMetric = fmt.Sprintf("((%s) * (%s))", capacityMetric, getExponentialDecayQuery(p.usageParams.HalfLifePeriod))
142+
decayedCapacityMetric = fmt.Sprintf("((%s) * (%s))", capacityMetric, getExponentialDecayQuery(&p.usageParams.HalfLifePeriod.Duration))
143143
}
144144

145145
capacityResult, warnings, err := queryByWindow(ctx, decayedCapacityMetric)
@@ -170,7 +170,7 @@ func (p *PrometheusClient) queryResourceUsage(
170170

171171
decayedAllocationMetric := allocationMetric
172172
if p.usageParams.HalfLifePeriod != nil {
173-
decayedAllocationMetric = fmt.Sprintf("((%s) * (%s))", allocationMetric, getExponentialDecayQuery(p.usageParams.HalfLifePeriod))
173+
decayedAllocationMetric = fmt.Sprintf("((%s) * (%s))", allocationMetric, getExponentialDecayQuery(&p.usageParams.HalfLifePeriod.Duration))
174174
}
175175

176176
usageResult, warnings, err := queryByWindow(ctx, decayedAllocationMetric)
@@ -226,7 +226,7 @@ func (p *PrometheusClient) queryTumblingTimeWindow(ctx context.Context, decayedA
226226
}
227227

228228
func (p *PrometheusClient) getLatestUsageResetTime() time.Time {
229-
maxWindowStartingPoint := time.Now().Add(-*p.usageParams.WindowSize)
229+
maxWindowStartingPoint := time.Now().Add(-*&p.usageParams.WindowSize.Duration)
230230
lastUsageReset := maxWindowStartingPoint
231231
nextInWindowReset := maxWindowStartingPoint
232232

0 commit comments

Comments
 (0)