Skip to content

Commit

Permalink
Fix handling of nil dontschedule strategy
Browse files Browse the repository at this point in the history
Correct handling when the dontschedule strategy is not defined
This makes an undefined dontschedule strategy in a policy
result in no filtering to the node list.

Signed-off-by: killianmuldoon <kmuldoon@vmware.com>
  • Loading branch information
killianmuldoon committed Feb 10, 2022
1 parent 8aa8285 commit 1a6c0f8
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 13 deletions.
9 changes: 0 additions & 9 deletions .github/e2e/e2e_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -307,15 +307,6 @@ func getTASPolicy(name string, str string, metric string, operator string, targe
},
},
}
if str != dontschedule.StrategyType {
pol.Spec.Strategies[dontschedule.StrategyType] =
api.TASPolicyStrategy{
PolicyName: "filter1",
Rules: []api.TASPolicyRule{
{Metricname: "filter1_metric", Operator: "Equals", Target: 2000000},
},
}
}
return pol
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,16 @@ import (
"net/http"
"strings"

v1 "k8s.io/api/core/v1"
"k8s.io/klog/v2"

"github.com/intel/platform-aware-scheduling/extender"
"github.com/intel/platform-aware-scheduling/telemetry-aware-scheduling/pkg/cache"
"github.com/intel/platform-aware-scheduling/telemetry-aware-scheduling/pkg/metrics"
"github.com/intel/platform-aware-scheduling/telemetry-aware-scheduling/pkg/strategies/core"
"github.com/intel/platform-aware-scheduling/telemetry-aware-scheduling/pkg/strategies/dontschedule"
"github.com/intel/platform-aware-scheduling/telemetry-aware-scheduling/pkg/strategies/scheduleonmetric"
telemetrypolicy "github.com/intel/platform-aware-scheduling/telemetry-aware-scheduling/pkg/telemetrypolicy/api/v1alpha1"
v1 "k8s.io/api/core/v1"
"k8s.io/klog/v2"
)

var tasPolicy = "telemetry-policy"
Expand Down Expand Up @@ -193,8 +194,10 @@ func (m MetricsExtender) filterNodes(args extender.Args) *extender.FilterResult
}
dontscheduleStrategy, err := m.getDontScheduleStrategy(policy)
if err != nil {
klog.V(2).InfoS("Don't scheduler strategy failed "+err.Error(), "component", "extender")
return nil
klog.V(4).InfoS("Returning all nodes "+err.Error(), "component", "extender")
return &extender.FilterResult{
Nodes: args.Nodes,
}
}
violatingNodes := dontscheduleStrategy.Violated(m.cache)
if len(args.Nodes.Items) == 0 {
Expand Down

0 comments on commit 1a6c0f8

Please sign in to comment.