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

Clean up error reporting / logging logic #833

Open
bartoszmajsak opened this issue May 4, 2021 · 2 comments
Open

Clean up error reporting / logging logic #833

bartoszmajsak opened this issue May 4, 2021 · 2 comments
Assignees
Labels
kind/bug Kind: Not working as expected
Milestone

Comments

@bartoszmajsak
Copy link
Contributor

Issue Overview

CLI prints both an error and log with JSON struct. That's confusing and not easily digestable.

Expected Behaviour

Nice, HUMAN readable error.

Current Behaviour
❯ ./dist/ike develop -d ratings-v1 -p 9080 -r 'ruby details.rb 9080'  --route header:ike-session-id=feature-y --session user.name
0.109
Error: failed executing develop command: 2 errors occurred:
	* your suggested session name is not a valid k8s value
	* cause 1: a lowercase RFC 1123 label must consist of lower case alphanumeric characters or '-', and must start and end with an alphanumeric character (e.g. 'my-name',  or '123-abc', regex used for validation is '[a-z0-9]([-a-z0-9]*[a-z0-9])?')


>> failed executing command	{"error": "failed executing develop command: 2 errors occurred:\n\t* your suggested session name is not a valid k8s value\n\t* cause 1: a lowercase RFC 1123 label must consist of lower case alphanumeric characters or '-', and must start and end with an alphanumeric character (e.g. 'my-name',  or '123-abc', regex used for validation is '[a-z0-9]([-a-z0-9]*[a-z0-9])?')\n\n", "errorVerbose": "2 errors occurred:\n\t* your suggested session name is not a valid k8s value\n\t* cause 1: a lowercase RFC 1123 label must consist of lower case alphanumeric characters or '-', and must start and end with an alphanumeric character (e.g. 'my-name',  or '123-abc', regex used for validation is '[a-z0-9]([-a-z0-9]*[a-z0-9])?')\n\n\nfailed executing develop command\ngithub.com/maistra/istio-workspace/pkg/cmd/develop.NewCmd.func2\n\t/home/bartek/code/golang/src/github.com/maistra/istio-workspace/pkg/cmd/develop/cmd.go:48\ngithub.com/spf13/cobra.(*Command).execute\n\t/home/bartek/code/golang/src/github.com/maistra/istio-workspace/vendor/github.com/spf13/cobra/command.go:852\ngithub.com/spf13/cobra.(*Command).ExecuteC\n\t/home/bartek/code/golang/src/github.com/maistra/istio-workspace/vendor/github.com/spf13/cobra/command.go:960\ngithub.com/spf13/cobra.(*Command).Execute\n\t/home/bartek/code/golang/src/github.com/maistra/istio-workspace/vendor/github.com/spf13/cobra/command.go:897\nmain.main\n\t/home/bartek/code/golang/src/github.com/maistra/istio-workspace/cmd/ike/main.go:47\nruntime.main\n\t/home/bartek/.gvm/gos/go1.16.2/src/runtime/proc.go:225\nruntime.goexit\n\t/home/bartek/.gvm/gos/go1.16.2/src/runtime/asm_amd64.s:1371"}

Notice that

Error: failed executing develop command: 2 errors occurred:
	* your suggested session name is not a valid k8s value
	* cause 1: a lowercase RFC 1123 label must consist of lower case alphanumeric characters or '-', and must start and end with an alphanumeric character (e.g. 'my-name',  or '123-abc', regex used for validation is '[a-z0-9]([-a-z0-9]*[a-z0-9])?')

is a bug of printing an error on its own vs logging it (presumably).

@bartoszmajsak bartoszmajsak added the kind/bug Kind: Not working as expected label May 4, 2021
@aslakknutsen aslakknutsen added this to the v0.3.0 milestone May 10, 2021
@aslakknutsen aslakknutsen modified the milestones: v0.3.0, v0.4.0 May 18, 2021
@bartoszmajsak bartoszmajsak self-assigned this Aug 2, 2021
@bartoszmajsak
Copy link
Contributor Author

After cleaning up error handling with the introduction of emperror the logging is simplified and redundancy is removed.

Structured context, however, is still printed out as JSON, as this is how zapcore's ConsoleEncoder works. See discussion in #253

So the output now looks as follows:

❯ ike develop -d ratings-v1 -p 9080 -r 'ruby details.rb 9080'  --route header:ike-session-id=feature-y --session user.name
failed executing command	{"name": "user.name", "error": "failed setting up session: your suggested session name is not a valid k8s value: a lowercase RFC 1123 label must consist of lower case alphanumeric characters or '-', and must start and end with an alphanumeric character (e.g. 'my-name',  or '123-abc', regex used for validation is '[a-z0-9]([-a-z0-9]*[a-z0-9])?')", "errorVerbose": "a lowercase RFC 1123 label must consist of lower case alphanumeric characters or '-', and must start and end with an alphanumeric character (e.g. 'my-name',  or '123-abc', regex used for validation is '[a-z0-9]([-a-z0-9]*[a-z0-9])?')\ngithub.com/maistra/istio-workspace/pkg/internal/session.getOrCreateSessionName\n\t/home/bartek/code/golang/src/github.com/maistra/istio-workspace/pkg/internal/session/session.go:249\ngithub.com/maistra/istio-workspace/pkg/internal/session.CreateOrJoinHandler\n\t/home/bartek/code/golang/src/github.com/maistra/istio-workspace/pkg/internal/session/session.go:86\ngithub.com/maistra/istio-workspace/pkg/cmd/internal/session.Sessions\n\t/home/bartek/code/golang/src/github.com/maistra/istio-workspace/pkg/cmd/internal/session/session_func.go:33\ngithub.com/maistra/istio-workspace/pkg/cmd/develop.NewCmd.func2\n\t/home/bartek/code/golang/src/github.com/maistra/istio-workspace/pkg/cmd/develop/cmd.go:46\ngithub.com/spf13/cobra.(*Command).execute\n\t/home/bartek/code/golang/src/github.com/maistra/istio-workspace/vendor/github.com/spf13/cobra/command.go:852\ngithub.com/spf13/cobra.(*Command).ExecuteC\n\t/home/bartek/code/golang/src/github.com/maistra/istio-workspace/vendor/github.com/spf13/cobra/command.go:960\ngithub.com/spf13/cobra.(*Command).Execute\n\t/home/bartek/code/golang/src/github.com/maistra/istio-workspace/vendor/github.com/spf13/cobra/command.go:897\nmain.main\n\t/home/bartek/code/golang/src/github.com/maistra/istio-workspace/cmd/ike/main.go:47\nruntime.main\n\t/home/bartek/.gvm/gos/go1.16.5/src/runtime/proc.go:225\nruntime.goexit\n\t/home/bartek/.gvm/gos/go1.16.5/src/runtime/asm_amd64.s:1371\nyour suggested session name is not a valid k8s value\nfailed setting up session\ngithub.com/maistra/istio-workspace/pkg/cmd/develop.NewCmd.func2\n\t/home/bartek/code/golang/src/github.com/maistra/istio-workspace/pkg/cmd/develop/cmd.go:51\ngithub.com/spf13/cobra.(*Command).execute\n\t/home/bartek/code/golang/src/github.com/maistra/istio-workspace/vendor/github.com/spf13/cobra/command.go:852\ngithub.com/spf13/cobra.(*Command).ExecuteC\n\t/home/bartek/code/golang/src/github.com/maistra/istio-workspace/vendor/github.com/spf13/cobra/command.go:960\ngithub.com/spf13/cobra.(*Command).Execute\n\t/home/bartek/code/golang/src/github.com/maistra/istio-workspace/vendor/github.com/spf13/cobra/command.go:897\nmain.main\n\t/home/bartek/code/golang/src/github.com/maistra/istio-workspace/cmd/ike/main.go:47\nruntime.main\n\t/home/bartek/.gvm/gos/go1.16.5/src/runtime/proc.go:225\nruntime.goexit\n\t/home/bartek/.gvm/gos/go1.16.5/src/runtime/asm_amd64.s:1371"}

@bartoszmajsak
Copy link
Contributor Author

Leaving this issue open and removed from v0.4.0 milestone as we are still considering custom logging encoder for CLI side.

@bartoszmajsak bartoszmajsak added this to the v0.6.0 milestone Aug 2, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Kind: Not working as expected
Projects
None yet
Development

No branches or pull requests

2 participants