Skip to content

Commit

Permalink
feat(ui): Add text filter to logs. Fixes #6059 (#6061)
Browse files Browse the repository at this point in the history
  • Loading branch information
alexec authored Jun 2, 2021
1 parent f1fcb43 commit 1f3493a
Show file tree
Hide file tree
Showing 10 changed files with 202 additions and 104 deletions.
10 changes: 10 additions & 0 deletions api/openapi-spec/swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -2971,6 +2971,11 @@
"description": "insecureSkipTLSVerifyBackend indicates that the apiserver should not confirm the validity of the\nserving certificate of the backend it is connecting to. This will make the HTTPS connection between the apiserver\nand the backend insecure. This means the apiserver cannot verify the log data it is receiving came from the real\nkubelet. If the kubelet is configured to verify the apiserver's TLS credentials, it does not mean the\nconnection to the real kubelet is vulnerable to a man in the middle attack (e.g. an attacker could not intercept\nthe actual log data coming from the real kubelet).\n+optional.",
"name": "logOptions.insecureSkipTLSVerifyBackend",
"in": "query"
},
{
"type": "string",
"name": "grep",
"in": "query"
}
],
"responses": {
Expand Down Expand Up @@ -3396,6 +3401,11 @@
"description": "insecureSkipTLSVerifyBackend indicates that the apiserver should not confirm the validity of the\nserving certificate of the backend it is connecting to. This will make the HTTPS connection between the apiserver\nand the backend insecure. This means the apiserver cannot verify the log data it is receiving came from the real\nkubelet. If the kubelet is configured to verify the apiserver's TLS credentials, it does not mean the\nconnection to the real kubelet is vulnerable to a man in the middle attack (e.g. an attacker could not intercept\nthe actual log data coming from the real kubelet).\n+optional.",
"name": "logOptions.insecureSkipTLSVerifyBackend",
"in": "query"
},
{
"type": "string",
"name": "grep",
"in": "query"
}
],
"responses": {
Expand Down
7 changes: 5 additions & 2 deletions cmd/argo/commands/logs.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ func NewLogsCommand() *cobra.Command {
since time.Duration
sinceTime string
tailLines int64
grep string
)
logOptions := &corev1.PodLogOptions{}
command := &cobra.Command{
Expand Down Expand Up @@ -91,7 +92,7 @@ func NewLogsCommand() *cobra.Command {
serviceClient := apiClient.NewWorkflowServiceClient()
namespace := client.Namespace()

logWorkflow(ctx, serviceClient, namespace, workflow, podName, logOptions)
logWorkflow(ctx, serviceClient, namespace, workflow, podName, grep, logOptions)
},
}
command.Flags().StringVarP(&logOptions.Container, "container", "c", "main", "Print the logs of this container")
Expand All @@ -100,18 +101,20 @@ func NewLogsCommand() *cobra.Command {
command.Flags().DurationVar(&since, "since", 0, "Only return logs newer than a relative duration like 5s, 2m, or 3h. Defaults to all logs. Only one of since-time / since may be used.")
command.Flags().StringVar(&sinceTime, "since-time", "", "Only return logs after a specific date (RFC3339). Defaults to all logs. Only one of since-time / since may be used.")
command.Flags().Int64Var(&tailLines, "tail", -1, "If set, the number of lines from the end of the logs to show. If not specified, logs are shown from the creation of the container or sinceSeconds or sinceTime")
command.Flags().StringVar(&grep, "grep", "", "grep for lines")
command.Flags().BoolVar(&logOptions.Timestamps, "timestamps", false, "Include timestamps on each line in the log output")
command.Flags().BoolVar(&noColor, "no-color", false, "Disable colorized output")
return command
}

func logWorkflow(ctx context.Context, serviceClient workflowpkg.WorkflowServiceClient, namespace, workflow, podName string, logOptions *corev1.PodLogOptions) {
func logWorkflow(ctx context.Context, serviceClient workflowpkg.WorkflowServiceClient, namespace, workflow, podName, grep string, logOptions *corev1.PodLogOptions) {
// logs
stream, err := serviceClient.WorkflowLogs(ctx, &workflowpkg.WorkflowLogRequest{
Name: workflow,
Namespace: namespace,
PodName: podName,
LogOptions: logOptions,
Grep: grep,
})
errors.CheckError(err)

Expand Down
2 changes: 1 addition & 1 deletion cmd/argo/commands/submit.go
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ func unmarshalWorkflows(wfBytes []byte, strict bool) []wfv1.Workflow {
func waitWatchOrLog(ctx context.Context, serviceClient workflowpkg.WorkflowServiceClient, namespace string, workflowNames []string, cliSubmitOpts cliSubmitOpts) {
if cliSubmitOpts.log {
for _, workflow := range workflowNames {
logWorkflow(ctx, serviceClient, namespace, workflow, "", &corev1.PodLogOptions{
logWorkflow(ctx, serviceClient, namespace, workflow, "", "", &corev1.PodLogOptions{
Container: common.MainContainerName,
Follow: true,
Previous: false,
Expand Down
1 change: 1 addition & 0 deletions docs/cli/argo_logs.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ argo logs WORKFLOW [POD] [flags]
```
-c, --container string Print the logs of this container (default "main")
-f, --follow Specify if the logs should be streamed.
--grep string grep for lines
-h, --help help for logs
--no-color Disable colorized output
-p, --previous Specify if the previously terminated container logs should be returned.
Expand Down
Loading

0 comments on commit 1f3493a

Please sign in to comment.