Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bugfix: Removes empty columns and fixes request details #93378

Merged
merged 1 commit into from Jul 29, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -58,7 +58,7 @@ func (cfgCtlr *configController) dumpPriorityLevels(w http.ResponseWriter, r *ht
"ExecutingRequests", // 6
}
tabPrint(tabWriter, rowForHeaders(columnHeaders))
endline(tabWriter)
endLine(tabWriter)
for _, plState := range cfgCtlr.priorityLevelStates {
if plState.queues == nil {
tabPrint(tabWriter, row(
Expand All @@ -69,7 +69,7 @@ func (cfgCtlr *configController) dumpPriorityLevels(w http.ResponseWriter, r *ht
"<none>", // 5
"<none>", // 6
))
endline(tabWriter)
endLine(tabWriter)
continue
}
queueSetDigest := plState.queues.Dump(false)
Expand All @@ -88,7 +88,7 @@ func (cfgCtlr *configController) dumpPriorityLevels(w http.ResponseWriter, r *ht
queueSetDigest.Waiting, // 5
queueSetDigest.Executing, // 6
))
endline(tabWriter)
endLine(tabWriter)
}
runtime.HandleError(tabWriter.Flush())
}
Expand All @@ -105,7 +105,7 @@ func (cfgCtlr *configController) dumpQueues(w http.ResponseWriter, r *http.Reque
"VirtualStart", // 5
}
tabPrint(tabWriter, rowForHeaders(columnHeaders))
endline(tabWriter)
endLine(tabWriter)
for _, plState := range cfgCtlr.priorityLevelStates {
if plState.queues == nil {
tabPrint(tabWriter, row(
Expand All @@ -115,7 +115,7 @@ func (cfgCtlr *configController) dumpQueues(w http.ResponseWriter, r *http.Reque
"<none>", // 4
"<none>", // 5
))
endline(tabWriter)
endLine(tabWriter)
continue
}
queueSetDigest := plState.queues.Dump(false)
Expand All @@ -127,7 +127,7 @@ func (cfgCtlr *configController) dumpQueues(w http.ResponseWriter, r *http.Reque
q.ExecutingRequests, // 4
q.VirtualStart, // 5
))
endline(tabWriter)
endLine(tabWriter)
}
}
runtime.HandleError(tabWriter.Flush())
Expand All @@ -149,6 +149,7 @@ func (cfgCtlr *configController) dumpRequests(w http.ResponseWriter, r *http.Req
"ArriveTime", // 6
}))
if includeRequestDetails {
continueLine(tabWriter)
tabPrint(tabWriter, rowForHeaders([]string{
"UserName", // 7
"Verb", // 8
Expand All @@ -160,7 +161,7 @@ func (cfgCtlr *configController) dumpRequests(w http.ResponseWriter, r *http.Req
"SubResource", // 14
}))
}
endline(tabWriter)
endLine(tabWriter)
for _, plState := range cfgCtlr.priorityLevelStates {
if plState.queues == nil {
tabPrint(tabWriter, row(
Expand All @@ -172,6 +173,7 @@ func (cfgCtlr *configController) dumpRequests(w http.ResponseWriter, r *http.Req
"<none>", // 6
))
if includeRequestDetails {
continueLine(tabWriter)
tabPrint(tabWriter, row(
"<none>", // 7
"<none>", // 8
Expand All @@ -183,7 +185,7 @@ func (cfgCtlr *configController) dumpRequests(w http.ResponseWriter, r *http.Req
"<none>", // 14
))
}
endline(tabWriter)
endLine(tabWriter)
continue
}
queueSetDigest := plState.queues.Dump(includeRequestDetails)
Expand All @@ -198,6 +200,7 @@ func (cfgCtlr *configController) dumpRequests(w http.ResponseWriter, r *http.Req
r.ArriveTime, // 6
))
if includeRequestDetails {
continueLine(tabWriter)
tabPrint(tabWriter, rowForRequestDetails(
r.UserName, // 7
r.RequestInfo.Verb, // 8
Expand All @@ -212,7 +215,7 @@ func (cfgCtlr *configController) dumpRequests(w http.ResponseWriter, r *http.Req
r.RequestInfo.Subresource, // 14
))
}
endline(tabWriter)
endLine(tabWriter)
}
}
}
Expand All @@ -223,7 +226,12 @@ func tabPrint(w io.Writer, row string) {
_, err := fmt.Fprint(w, row)
runtime.HandleError(err)
}
func endline(w io.Writer) {

func continueLine(w io.Writer) {
_, err := fmt.Fprint(w, ",\t")
runtime.HandleError(err)
}
func endLine(w io.Writer) {
_, err := fmt.Fprint(w, "\n")
runtime.HandleError(err)
}
Expand Down Expand Up @@ -269,9 +277,14 @@ func rowForRequestDetails(username, verb, path, namespace, name, apiVersion, res
username,
verb,
path,
namespace,
name,
apiVersion,
resource,
subResource,
)
}

func row(columns ...string) string {
return strings.Join(columns, ",\t") + ",\t"
return strings.Join(columns, ",\t")
}