You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@yunikorn.apache.org by "wilfred-s (via GitHub)" <gi...@apache.org> on 2023/02/06 02:14:57 UTC

[GitHub] [yunikorn-k8shim] wilfred-s commented on a diff in pull request #519: [YUNIKORN-1550] pass k8s node labels as attributes not json

wilfred-s commented on code in PR #519:
URL: https://github.com/apache/yunikorn-k8shim/pull/519#discussion_r1096883584


##########
pkg/cache/nodes.go:
##########
@@ -101,20 +100,13 @@ func (nc *schedulerNodes) addAndReportNode(node *v1.Node, reportNode bool) {
 
 	// add node to nodes map
 	if _, ok := nc.nodesMap[node.Name]; !ok {
-		var nodeLabels []byte
-		nodeLabels, err := json.Marshal(node.Labels) // A nil pointer encodes as the "null" JSON value.
-		if err != nil {
-			log.Logger().Error("failed to marshall node labels to json", zap.Error(err))
-			nodeLabels = make([]byte, 0)
-		}
-
 		log.Logger().Info("adding node to context",
 			zap.String("nodeName", node.Name),
-			zap.String("nodeLabels", string(nodeLabels)),
+			zap.String("nodeLabels", fmt.Sprintf("%v", node.Labels)),

Review Comment:
   Leverage zap.Any() it can handle the map with less overhead.
   There will be no string allocated etc if the level is not set to INFO.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@yunikorn.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org