Skip to content

Commit

Permalink
Merge pull request #9 from k8stopologyawareschedwg/add-status-node-name
Browse files Browse the repository at this point in the history
[API] add NodeName field in status
  • Loading branch information
ffromani authored Mar 21, 2023
2 parents cac6601 + 44a5cb5 commit 80e6eb5
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
9 changes: 9 additions & 0 deletions tracing.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,13 @@ type Status struct {
FingerprintExpected string `json:"fingerprintExpected,omitempty"`
FingerprintComputed string `json:"fingerprintComputed,omitempty"`
Pods []NamespacedName `json:"pods,omitempty"`
NodeName string `json:"nodeName,omitempty"`
}

func MakeStatus(nodeName string) Status {
return Status{
NodeName: nodeName,
}
}

func (st *Status) Start(numPods int) {
Expand All @@ -90,6 +97,7 @@ func (st *Status) Check(expected string) {
func (st Status) Repr() string {
var sb strings.Builder

sb.WriteString(fmt.Sprintf("> processing node %q\n", st.NodeName))
sb.WriteString(fmt.Sprintf("> processing %d pods\n", len(st.Pods)))
for _, pod := range st.Pods {
sb.WriteString("+ " + pod.Namespace + "/" + pod.Name + "\n")
Expand All @@ -110,6 +118,7 @@ func (st Status) Clone() Status {
FingerprintExpected: st.FingerprintExpected,
FingerprintComputed: st.FingerprintComputed,
Pods: pods,
NodeName: st.NodeName,
}
return ret
}
Expand Down
5 changes: 3 additions & 2 deletions tracing_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,8 @@ func TestTraceStatusJSON(t *testing.T) {
}
}

var expectedStatusRepr = `> processing 5 pods
var expectedStatusRepr = `> processing node "test-node"
> processing 5 pods
+ ns1/n1
+ ns1/n2
+ ns2/n1
Expand Down Expand Up @@ -129,7 +130,7 @@ func TestTraceStatusRepr(t *testing.T) {
},
}

st := Status{}
st := MakeStatus("test-node")
fp := NewTracingFingerprint(len(pods), &st)
for _, pod := range pods {
fp.Add(pod.Namespace, pod.Name)
Expand Down

0 comments on commit 80e6eb5

Please sign in to comment.