Skip to content

Commit 7d7fc2d

Browse files
committed
Fix flaky test: Metrics should grab all metrics from kubelet /metrics/resource endpoint
Signed-off-by: carlory <[email protected]>
1 parent 88dfcb2 commit 7d7fc2d

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

test/e2e/framework/node/helper.go

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -188,10 +188,15 @@ func AddExtendedResource(ctx context.Context, clientSet clientset.Interface, nod
188188
extendedResourceList := v1.ResourceList{
189189
extendedResource: extendedResourceQuantity,
190190
}
191-
patchPayload, err := json.Marshal(v1.Node{
192-
Status: v1.NodeStatus{
193-
Capacity: extendedResourceList,
194-
Allocatable: extendedResourceList,
191+
192+
// This is a workaround for the fact that we shouldn't marshal a Node struct to JSON
193+
// because it wipes out some fields from node status like the daemonEndpoints and
194+
// nodeInfo which should not be changed at this time. We need to use a map instead.
195+
// See https://github.com/kubernetes/kubernetes/issues/131229
196+
patchPayload, err := json.Marshal(map[string]any{
197+
"status": map[string]any{
198+
"capacity": extendedResourceList,
199+
"allocatable": extendedResourceList,
195200
},
196201
})
197202
framework.ExpectNoError(err, "Failed to marshal node JSON")

0 commit comments

Comments
 (0)