diff --git a/pkg/api/types.go b/pkg/api/types.go index f7289bbe0..249bcf328 100644 --- a/pkg/api/types.go +++ b/pkg/api/types.go @@ -49,7 +49,7 @@ type ReschedulerStrategy struct { // Only one of its members may be specified type StrategyParameters struct { - NodeResourceUtilizationThresholds *NodeResourceUtilizationThresholds + NodeResourceUtilizationThresholds NodeResourceUtilizationThresholds } type Percentage int diff --git a/pkg/api/v1alpha1/types.go b/pkg/api/v1alpha1/types.go index 8bb6f452b..843c44b99 100644 --- a/pkg/api/v1alpha1/types.go +++ b/pkg/api/v1alpha1/types.go @@ -49,7 +49,7 @@ type ReschedulerStrategy struct { // Only one of its members may be specified type StrategyParameters struct { - NodeResourceUtilizationThresholds *NodeResourceUtilizationThresholds `json:"nodeResourceUtilizationThresholds,omitempty"` + NodeResourceUtilizationThresholds NodeResourceUtilizationThresholds `json:"nodeResourceUtilizationThresholds,omitempty"` } type Percentage int diff --git a/pkg/rescheduler/resheduler.go b/pkg/rescheduler/resheduler.go index 26a9023bc..5171a1734 100644 --- a/pkg/rescheduler/resheduler.go +++ b/pkg/rescheduler/resheduler.go @@ -17,10 +17,11 @@ limitations under the License. package rescheduler import ( - "encoding/json" - //"fmt" - "io/ioutil" - //"os" + "fmt" + "os" + "path/filepath" + + "k8s.io/apimachinery/pkg/util/yaml" "github.com/aveshagarwal/rescheduler/cmd/rescheduler/app/options" "github.com/aveshagarwal/rescheduler/pkg/api/v1alpha1" @@ -38,15 +39,21 @@ func Run(rs *options.ReschedulerServer) error { reschedulerPolicy := v1alpha1.ReschedulerPolicy{} if len(rs.PolicyConfigFile) > 0 { - data, err := ioutil.ReadFile(rs.PolicyConfigFile) + filename, err := filepath.Abs(rs.PolicyConfigFile) if err != nil { return err } - if err := json.Unmarshal(data, &reschedulerPolicy); err != nil { + fd, err := os.Open(filename) + if err != nil { return err } - } + if err := yaml.NewYAMLOrJSONDecoder(fd, 4096).Decode(&reschedulerPolicy); err != nil { + return err + } + + } + fmt.Printf("\nreschedulerPolicy: %#v\n", reschedulerPolicy) policyGroupVersion, err := eutils.SupportEviction(rs.Client) if err != nil || len(policyGroupVersion) == 0 { return err