Skip to content

Commit 14fa2b3

Browse files
Fix the node log query
Signed-off-by: Neeraj Krishna Gopalakrishna <[email protected]>
1 parent 43c1762 commit 14fa2b3

File tree

1 file changed

+22
-16
lines changed

1 file changed

+22
-16
lines changed

pkg/mcp/nodes_test.go

Lines changed: 22 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -43,23 +43,29 @@ func (s *NodesSuite) TestNodesLog() {
4343
}`))
4444
return
4545
}
46-
// Get Empty Log response
47-
if req.URL.Path == "/api/v1/nodes/existing-node/proxy/logs/empty.log" {
48-
w.Header().Set("Content-Type", "text/plain")
49-
w.WriteHeader(http.StatusOK)
50-
_, _ = w.Write([]byte(``))
51-
return
52-
}
53-
// Get Kubelet Log response
54-
if req.URL.Path == "/api/v1/nodes/existing-node/proxy/logs/kubelet.log" {
55-
w.Header().Set("Content-Type", "text/plain")
56-
w.WriteHeader(http.StatusOK)
57-
logContent := "Line 1\nLine 2\nLine 3\nLine 4\nLine 5\n"
58-
if req.URL.Query().Get("tailLines") != "" {
59-
logContent = "Line 4\nLine 5\n"
46+
// Check for log proxy requests based on path and query parameters
47+
if req.URL.Path == "/api/v1/nodes/existing-node/proxy/logs" {
48+
logPath := req.URL.Query().Get("query")
49+
50+
// Get Empty Log response
51+
if logPath == "empty.log" {
52+
w.Header().Set("Content-Type", "text/plain")
53+
w.WriteHeader(http.StatusOK)
54+
_, _ = w.Write([]byte(``))
55+
return
56+
}
57+
58+
// Get Kubelet Log response
59+
if logPath == "kubelet.log" {
60+
w.Header().Set("Content-Type", "text/plain")
61+
w.WriteHeader(http.StatusOK)
62+
logContent := "Line 1\nLine 2\nLine 3\nLine 4\nLine 5\n"
63+
if req.URL.Query().Get("tailLines") != "" {
64+
logContent = "Line 4\nLine 5\n"
65+
}
66+
_, _ = w.Write([]byte(logContent))
67+
return
6068
}
61-
_, _ = w.Write([]byte(logContent))
62-
return
6369
}
6470
w.WriteHeader(http.StatusNotFound)
6571
}))

0 commit comments

Comments
 (0)