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

feat: add log format annotation and helm value #4620

Merged
merged 2 commits into from
Jul 2, 2020

Conversation

naseemkullah
Copy link
Contributor

@naseemkullah naseemkullah commented Jun 17, 2020

Json log formatting has been added via linkerd/linkerd2-proxy#500
but wiring the option through as an annotation/helm value is still
necessary.

This PR adds the annotation and helm value to configure log format.

Closes #2491

Signed-off-by: Naseem naseem@transit.app

@naseemkullah naseemkullah force-pushed the log-format branch 2 times, most recently from 4434296 to cf5d490 Compare June 17, 2020 04:33
Copy link
Member

@zaharidichev zaharidichev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@naseemkullah Thanks! I see this is still a draft, but just as a note, I assume you are going to make it so LINKERD2_PROXY_LOG_FORMAT on the proxy is actually set. Also, we would ideally want a default value for that and an entry in values.yaml so we do not get a null in the config map

@naseemkullah naseemkullah force-pushed the log-format branch 7 times, most recently from 487e014 to c887835 Compare June 18, 2020 03:23
@naseemkullah naseemkullah marked this pull request as ready for review June 18, 2020 03:32
@naseemkullah naseemkullah requested review from olix0r and a team as code owners June 18, 2020 03:32
@naseemkullah naseemkullah changed the title wip: add log format annotation and cli flag feat: add log format annotation and cli flag Jun 18, 2020
@olix0r
Copy link
Member

olix0r commented Jun 18, 2020

@naseemkullah I think initially we should leave this out of the CLI flags and only support this via Helm & workload annotation. We may consider adding it there later, but for now I think we'd prefer to minimize configuration CLI code.

@naseemkullah naseemkullah changed the title feat: add log format annotation and cli flag feat: add log format annotation and helm value Jun 19, 2020
@naseemkullah naseemkullah force-pushed the log-format branch 3 times, most recently from f948a64 to e08a5f3 Compare June 19, 2020 02:02
@naseemkullah
Copy link
Contributor Author

naseemkullah commented Jun 19, 2020

@naseemkullah I think initially we should leave this out of the CLI flags and only support this via Helm & workload annotation. We may consider adding it there later, but for now I think we'd prefer to minimize configuration CLI code.

Sure, np! cli flag removed @olix0r ✅ ...ooc are there other options that are configurable via env var/helm value and/or annotation but not cli flag?

@zaharidichev
Copy link
Member

@olix0r this sounds good to me. i wonder however, instead of leaving this out of the CLI (much like dst get networks), would it make sense to just put it as a hidden flag?

@zaharidichev
Copy link
Member

@naseemkullah to answer your question, yes there is for example destinationGetNetworks

Copy link
Member

@alpeb alpeb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @naseemkullah !

A LogFormat entry is missing in the pb.Proxy struct returned in install.go's proxyConfig() that allows picking the default value from values.yaml when installing through the CLI.

Also it appears you didn't push your changes to config.proto as it's missing LogFormat. By looking at config.pb.go it seems you declared a new protobuf struct to house that, but I think a bare string is enough (I don't understand why we did that with LogLevel before 🤷‍♂️ )

charts/linkerd2/README.md Outdated Show resolved Hide resolved
cli/cmd/doc.go Outdated Show resolved Hide resolved
proto/config/config.proto Outdated Show resolved Hide resolved
@alpeb
Copy link
Member

alpeb commented Jun 23, 2020

@naseemkullah one more thing: charts/linkerd2/templates/_config.tpl needs logFormat to be added as well 😬

@alpeb
Copy link
Member

alpeb commented Jun 23, 2020

... aaaand also missing in install.go's buildValuesWithoutIdentity() function. I'll have to admit having to add an entry in 20 different places is not very dev friendly!

@alpeb
Copy link
Member

alpeb commented Jun 23, 2020

@naseemkullah I also realized the support for the webhook injector is missing. That should live under the injectPodSpec() function in pkg/inject/inject.go. And you can add the annotation into pkg/inject/inject_test.go so the unit test checks the mechanism is working.

@naseemkullah
Copy link
Contributor Author

naseemkullah commented Jun 23, 2020

... aaaand also missing in install.go's buildValuesWithoutIdentity() function. I'll have to admit having to add an entry in 20 different places is not very dev friendly

True!

edit: @alpeb I see no mention of proxy log level which I'm using as a reference in buildValuesWithoutIdentity(), is it normal that we will have mention of log format but not log level within it?

@olix0r olix0r changed the base branch from master to main June 24, 2020 18:37
@alpeb
Copy link
Member

alpeb commented Jun 24, 2020

I see no mention of proxy log level which I'm using as a reference in buildValuesWithoutIdentity(), is it normal that we will have mention of log format but not log level within it?

It's here

@naseemkullah
Copy link
Contributor Author

I see no mention of proxy log level which I'm using as a reference in buildValuesWithoutIdentity(), is it normal that we will have mention of log format but not log level within it?

It's here

Doh! Thanks @alpeb

@naseemkullah
Copy link
Contributor Author

Can someone please help me get tests to pass?

panic: mismatching message name: got linkerd2.config.Install, want linkerd2.config.LogFormat

goroutine 1 [running]:
google.golang.org/protobuf/internal/impl.legacyLoadMessageDesc(0x29d35a0, 0x25ac340, 0x26d738b, 0x19, 0x0, 0x0)
        /Users/naseemullah/go/pkg/mod/google.golang.org/protobuf@v1.24.0/internal/impl/legacy_message.go:136 +0x882
google.golang.org/protobuf/internal/impl.legacyLoadMessageInfo(0x29d35a0, 0x25ac340, 0x26d738b, 0x19, 0xc000120eb0)
        /Users/naseemullah/go/pkg/mod/google.golang.org/protobuf@v1.24.0/internal/impl/legacy_message.go:48 +0xbd
google.golang.org/protobuf/internal/impl.Export.LegacyMessageTypeOf(0x298d1c0, 0x0, 0x26d738b, 0x19, 0x25ac440, 0xc0001717c0)
        /Users/naseemullah/go/pkg/mod/google.golang.org/protobuf@v1.24.0/internal/impl/legacy_export.go:33 +0xa5
github.com/golang/protobuf/proto.RegisterType(0x298d1c0, 0x0, 0x26d738b, 0x19)
        /Users/naseemullah/go/pkg/mod/github.com/golang/protobuf@v1.4.2/proto/registry.go:186 +0x4d
github.com/linkerd/linkerd2/controller/gen/config.init.0()
        /Users/naseemullah/repos/github.com/linkerd/linkerd2/controller/gen/config/config.pb.go:825 +0x21b
FAIL    github.com/linkerd/linkerd2/cli/cmd     0.023s
FAIL

@alpeb
Copy link
Member

alpeb commented Jun 25, 2020

@naseemkullah it seems there are some issues with the latest protobuf lib update that happened in the main branch. I'll give that a look and let you know.

alpeb added a commit that referenced this pull request Jun 25, 2020
Regenerated protobuf files, using version 1.4.2 that was upgraded from
1.3.2 with the proxy-api update in #4614.

As of v1.4 protobuf messages are disallowed to be copied (because they
hold a mutex), so whenever a message is passed to or returned from a
function we need to use a pointer.

This affects _mostly_ test files.

This is required to unblock #4620 which is adding a field to the config
protobuf.
alpeb added a commit that referenced this pull request Jun 26, 2020
Regenerated protobuf files, using version 1.4.2 that was upgraded from
1.3.2 with the proxy-api update in #4614.

As of v1.4 protobuf messages are disallowed to be copied (because they
hold a mutex), so whenever a message is passed to or returned from a
function we need to use a pointer.

This affects _mostly_ test files.

This is required to unblock #4620 which is adding a field to the config
protobuf.
@alpeb
Copy link
Member

alpeb commented Jun 26, 2020

@naseemkullah you may now merge the changes from the main branch one more time and run bin/protoc-go.sh to include your changes.

Json log formatting has been added via linkerd/linkerd2-proxy#500
but wiring the option through as an annotation/helm value is still
necessary.

This PR adds the annotation and helm value to configure log format.

Closes linkerd#2491

Signed-off-by: Naseem <naseem@transit.app>
@naseemkullah naseemkullah force-pushed the log-format branch 2 times, most recently from 4c4368a to c4213d2 Compare June 27, 2020 00:29
Signed-off-by: Naseem <naseem@transit.app>
Copy link
Member

@alpeb alpeb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @naseemkullah , this looks good to me!

@naseemkullah
Copy link
Contributor Author

Thanks for your help as always @alpeb!

Copy link
Contributor

@Pothulapati Pothulapati left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

Tested overriding both at namespace and pod level

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add option for logging in json format
5 participants