Skip to content

Commit

Permalink
add examples
Browse files Browse the repository at this point in the history
  • Loading branch information
shijieqin committed Apr 20, 2022
1 parent c3be5d4 commit cb7704e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
2 changes: 1 addition & 1 deletion examples/noderesource-tsp-template.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ data:
resourceIdentifier: cpu
type: ExpressionQuery
expressionQuery:
expression: 'node_cpu_cannot_be_reclaimed_seconds{node=~"({{nodename}})(:\\d+)?"}'
expression: 'node_cpu_cannot_be_reclaimed_seconds{node=~"({{ .metadata.name }})(:\\d+)?"}'
predictionWindowSeconds: 180
kind: ConfigMap
metadata:
Expand Down
6 changes: 5 additions & 1 deletion pkg/agent/agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package agent
import (
"bytes"
"context"
"encoding/json"
"fmt"
"html/template"
"net/http"
Expand Down Expand Up @@ -167,7 +168,10 @@ func (a *Agent) CreateNodeResourceTsp() (string, error) {
return "", err
}
var buf bytes.Buffer
err = tpl.Execute(&buf, n)
raw, _ := json.Marshal(n)
var data interface{}
_ = json.Unmarshal(raw, &data)
err = tpl.Execute(&buf, data)
if err != nil {
klog.Errorf("Failed to convert spec template : %v", err)
return "", err
Expand Down

0 comments on commit cb7704e

Please sign in to comment.